mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 01:43:50 +01:00
f8f98ab7f0
* Allow overrides on all methods * Add non-returning SendHttpRequest methods * Use SendHttpRequest consistently * Use file-scoped namespace * Rates: Set default null value for currencyPair * Ensure it works with instances which have BTCPAY_ROOTPATH set
41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net.Http;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Client.Models;
|
|
|
|
namespace BTCPayServer.Client;
|
|
|
|
public partial class BTCPayServerClient
|
|
{
|
|
public virtual async Task<IEnumerable<StoreData>> GetStores(CancellationToken token = default)
|
|
{
|
|
return await SendHttpRequest<IEnumerable<StoreData>>("api/v1/stores", null, HttpMethod.Get, token);
|
|
}
|
|
|
|
public virtual async Task<StoreData> GetStore(string storeId, CancellationToken token = default)
|
|
{
|
|
return await SendHttpRequest<StoreData>($"api/v1/stores/{storeId}", null, HttpMethod.Get, token);
|
|
}
|
|
|
|
public virtual async Task RemoveStore(string storeId, CancellationToken token = default)
|
|
{
|
|
await SendHttpRequest($"api/v1/stores/{storeId}", null, HttpMethod.Delete, token);
|
|
}
|
|
|
|
public virtual async Task<StoreData> CreateStore(CreateStoreRequest request, CancellationToken token = default)
|
|
{
|
|
if (request == null) throw new ArgumentNullException(nameof(request));
|
|
return await SendHttpRequest<StoreData>("api/v1/stores", request, HttpMethod.Post, token);
|
|
}
|
|
|
|
public virtual async Task<StoreData> UpdateStore(string storeId, UpdateStoreRequest request, CancellationToken token = default)
|
|
{
|
|
if (request == null) throw new ArgumentNullException(nameof(request));
|
|
if (storeId == null) throw new ArgumentNullException(nameof(storeId));
|
|
return await SendHttpRequest<StoreData>($"api/v1/stores/{storeId}", request, HttpMethod.Put, token);
|
|
}
|
|
|
|
}
|