2021-07-23 10:05:15 +02:00
|
|
|
using System.Collections.Generic;
|
2024-04-04 09:31:04 +02:00
|
|
|
using System.Net.Http;
|
2021-07-23 10:05:15 +02:00
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using BTCPayServer.Client.Models;
|
|
|
|
|
2024-06-19 15:25:33 +02:00
|
|
|
namespace BTCPayServer.Client;
|
|
|
|
|
|
|
|
public partial class BTCPayServerClient
|
2021-07-23 10:05:15 +02:00
|
|
|
{
|
2024-06-19 15:25:33 +02:00
|
|
|
public virtual async Task<GenericPaymentMethodData> UpdateStorePaymentMethod(string storeId, string paymentMethodId, UpdatePaymentMethodRequest request, CancellationToken token = default)
|
2021-07-23 10:05:15 +02:00
|
|
|
{
|
2024-06-19 15:25:33 +02:00
|
|
|
return await SendHttpRequest<GenericPaymentMethodData>($"api/v1/stores/{storeId}/payment-methods/{paymentMethodId}", request, HttpMethod.Put, token);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual async Task RemoveStorePaymentMethod(string storeId, string paymentMethodId)
|
|
|
|
{
|
|
|
|
await SendHttpRequest($"api/v1/stores/{storeId}/payment-methods/{paymentMethodId}", null, HttpMethod.Delete, CancellationToken.None);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual async Task<GenericPaymentMethodData> GetStorePaymentMethod(string storeId, string paymentMethodId, bool? includeConfig = null, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
var query = new Dictionary<string, object>();
|
|
|
|
if (includeConfig != null)
|
2024-04-04 09:31:04 +02:00
|
|
|
{
|
2024-06-19 15:25:33 +02:00
|
|
|
query.Add(nameof(includeConfig), includeConfig);
|
2024-04-04 09:31:04 +02:00
|
|
|
}
|
2024-06-19 15:25:33 +02:00
|
|
|
return await SendHttpRequest<GenericPaymentMethodData>($"api/v1/stores/{storeId}/payment-methods/{paymentMethodId}", query, HttpMethod.Get, token);
|
|
|
|
}
|
2024-04-04 09:31:04 +02:00
|
|
|
|
2024-06-19 15:25:33 +02:00
|
|
|
public virtual async Task<GenericPaymentMethodData[]> GetStorePaymentMethods(string storeId, bool? onlyEnabled = null, bool? includeConfig = null, CancellationToken token = default)
|
|
|
|
{
|
|
|
|
var query = new Dictionary<string, object>();
|
|
|
|
if (onlyEnabled != null)
|
2024-04-04 09:31:04 +02:00
|
|
|
{
|
2024-06-19 15:25:33 +02:00
|
|
|
query.Add(nameof(onlyEnabled), onlyEnabled);
|
2024-04-04 09:31:04 +02:00
|
|
|
}
|
2024-06-19 15:25:33 +02:00
|
|
|
if (includeConfig != null)
|
2021-07-23 10:05:15 +02:00
|
|
|
{
|
2024-06-19 15:25:33 +02:00
|
|
|
query.Add(nameof(includeConfig), includeConfig);
|
2021-07-23 10:05:15 +02:00
|
|
|
}
|
2024-06-19 15:25:33 +02:00
|
|
|
|
|
|
|
return await SendHttpRequest<GenericPaymentMethodData[]>($"api/v1/stores/{storeId}/payment-methods", query, HttpMethod.Get, token);
|
2021-07-23 10:05:15 +02:00
|
|
|
}
|
|
|
|
}
|