mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
* Greenfield: Store Rates Config * FIX SWAGGER * rebase fix * Apply suggestions from code review Co-authored-by: d11n <mail@dennisreimann.de> * Update BTCPayServer/wwwroot/swagger/v1/swagger.template.stores-rates-config.json Co-authored-by: d11n <mail@dennisreimann.de> * Fix: Spread isn't converted from/to percentage, rename some fields, and move some routes * Fix error handling Co-authored-by: d11n <mail@dennisreimann.de> Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
53 lines
2.2 KiB
C#
53 lines
2.2 KiB
C#
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);
|
|
}
|
|
|
|
public virtual async Task<List<StoreRatePreviewResult>> PreviewUpdateStoreRateConfiguration(string storeId,
|
|
StoreRateConfiguration request,
|
|
string[] currencyPair,
|
|
CancellationToken token = default)
|
|
{
|
|
using var response = await _httpClient.SendAsync(
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/rates/configuration/preview", bodyPayload: request,
|
|
queryPayload: new Dictionary<string, object>() {{"currencyPair", currencyPair}},
|
|
method: HttpMethod.Post),
|
|
token);
|
|
return await HandleResponse<List<StoreRatePreviewResult>>(response);
|
|
}
|
|
}
|
|
}
|