mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
1d2bebf17a
* Greenfield: Lightning addresses API * add docs * Apply suggestions from code review Co-authored-by: d11n <mail@dennisreimann.de>
49 lines
2.0 KiB
C#
49 lines
2.0 KiB
C#
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<LightningAddressData[]> GetStoreLightningAddresses(string storeId,
|
|
CancellationToken token = default)
|
|
{
|
|
var response = await _httpClient.SendAsync(
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/lightning-addresses",
|
|
method: HttpMethod.Get), token);
|
|
return await HandleResponse<LightningAddressData[]>(response);
|
|
}
|
|
|
|
public virtual async Task<LightningAddressData> GetStoreLightningAddress(string storeId, string username,
|
|
CancellationToken token = default)
|
|
{
|
|
var response = await _httpClient.SendAsync(
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/lightning-addresses/{username}",
|
|
method: HttpMethod.Get), token);
|
|
return await HandleResponse<LightningAddressData>(response);
|
|
}
|
|
|
|
public virtual async Task RemoveStoreLightningAddress(string storeId, string username,
|
|
CancellationToken token = default)
|
|
{
|
|
var response = await _httpClient.SendAsync(
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/lightning-addresses/{username}",
|
|
method: HttpMethod.Delete), token);
|
|
await HandleResponse(response);
|
|
}
|
|
|
|
public virtual async Task<LightningAddressData> AddOrUpdateStoreLightningAddress(string storeId,
|
|
string username, LightningAddressData data,
|
|
CancellationToken token = default)
|
|
{
|
|
var response = await _httpClient.SendAsync(
|
|
CreateHttpRequest($"api/v1/stores/{storeId}/lightning-addresses/{username}",
|
|
method: HttpMethod.Post, bodyPayload: data), token);
|
|
|
|
return await HandleResponse<LightningAddressData>(response);
|
|
}
|
|
}
|
|
}
|