2022-10-12 15:19:33 +02:00
|
|
|
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<StoreRateConfiguration> GetStoreRateConfiguration(string storeId,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
using var response = await _httpClient.SendAsync(
|
|
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/rates/configuration", method: HttpMethod.Get),
|
|
|
|
token);
|
|
|
|
return await HandleResponse<StoreRateConfiguration>(response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual async Task<List<RateSource>> GetRateSources(
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
using var response = await _httpClient.SendAsync(
|
|
|
|
CreateHttpRequest($"misc/rate-sources", method: HttpMethod.Get),
|
|
|
|
token);
|
|
|
|
return await HandleResponse<List<RateSource>>(response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual async Task<StoreRateConfiguration> UpdateStoreRateConfiguration(string storeId,
|
|
|
|
StoreRateConfiguration request,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
using var response = await _httpClient.SendAsync(
|
|
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/rates/configuration", bodyPayload: request,
|
|
|
|
method: HttpMethod.Put),
|
|
|
|
token);
|
|
|
|
return await HandleResponse<StoreRateConfiguration>(response);
|
|
|
|
}
|
|
|
|
|
2023-01-31 06:42:25 +01:00
|
|
|
public virtual async Task<List<StoreRateResult>> PreviewUpdateStoreRateConfiguration(string storeId,
|
2022-10-12 15:19:33 +02:00
|
|
|
StoreRateConfiguration request,
|
|
|
|
string[] currencyPair,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
using var response = await _httpClient.SendAsync(
|
|
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/rates/configuration/preview", bodyPayload: request,
|
2023-01-06 14:18:07 +01:00
|
|
|
queryPayload: new Dictionary<string, object>() { { "currencyPair", currencyPair } },
|
2022-10-12 15:19:33 +02:00
|
|
|
method: HttpMethod.Post),
|
|
|
|
token);
|
2023-01-31 06:42:25 +01:00
|
|
|
return await HandleResponse<List<StoreRateResult>>(response);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual async Task<List<StoreRateResult>> GetStoreRates(string storeId, string[] currencyPair,
|
|
|
|
CancellationToken token = default)
|
|
|
|
{
|
|
|
|
using var response = await _httpClient.SendAsync(
|
2023-04-10 04:07:03 +02:00
|
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/rates",
|
2023-01-31 06:42:25 +01:00
|
|
|
queryPayload: new Dictionary<string, object>() { { "currencyPair", currencyPair } },
|
|
|
|
method: HttpMethod.Get),
|
|
|
|
token);
|
|
|
|
return await HandleResponse<List<StoreRateResult>>(response);
|
2022-10-12 15:19:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|