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> GetStoreOnChainPaymentMethods(string storeId, bool? enabled = null, CancellationToken token = default) { var query = new Dictionary(); if (enabled != null) { query.Add(nameof(enabled), enabled); } var response = await _httpClient.SendAsync( CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain", query), token); return await HandleResponse>(response); } public virtual async Task GetStoreOnChainPaymentMethod(string storeId, string cryptoCode, CancellationToken token = default) { var response = await _httpClient.SendAsync( CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}"), token); return await HandleResponse(response); } public virtual async Task RemoveStoreOnChainPaymentMethod(string storeId, string cryptoCode, CancellationToken token = default) { var response = await _httpClient.SendAsync( CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}", method: HttpMethod.Delete), token); await HandleResponse(response); } public virtual async Task UpdateStoreOnChainPaymentMethod(string storeId, string cryptoCode, UpdateOnChainPaymentMethodRequest paymentMethod, CancellationToken token = default) { var response = await _httpClient.SendAsync( CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}", bodyPayload: paymentMethod, method: HttpMethod.Put), token); return await HandleResponse(response); } public virtual async Task PreviewProposedStoreOnChainPaymentMethodAddresses( string storeId, string cryptoCode, UpdateOnChainPaymentMethodRequest paymentMethod, int offset = 0, int amount = 10, CancellationToken token = default) { var response = await _httpClient.SendAsync( CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/preview", bodyPayload: paymentMethod, queryPayload: new Dictionary() { { "offset", offset }, { "amount", amount } }, method: HttpMethod.Post), token); return await HandleResponse(response); } public virtual async Task PreviewStoreOnChainPaymentMethodAddresses( string storeId, string cryptoCode, int offset = 0, int amount = 10, CancellationToken token = default) { var response = await _httpClient.SendAsync( CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/preview", queryPayload: new Dictionary() { { "offset", offset }, { "amount", amount } }, method: HttpMethod.Get), token); return await HandleResponse(response); } public virtual async Task GenerateOnChainWallet(string storeId, string cryptoCode, GenerateOnChainWalletRequest request, CancellationToken token = default) { var response = await _httpClient.SendAsync( CreateHttpRequest($"api/v1/stores/{storeId}/payment-methods/onchain/{cryptoCode}/generate", bodyPayload: request, method: HttpMethod.Post), token); return await HandleResponse(response); } } }