mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 13:26:47 +01:00
25ae6df095
* Greenfield: Add file endpoints and upload - Endpoints for server files - File upload using `multipart/form-data` Closes #6074. Can also be tested using cURL: - `curl --location 'https://localhost:14142/api/v1/files' --header 'Authorization: token MY_API_TOKEN' --form 'file=@"LOCAL_FILEPATH"'` - `curl --location 'https://localhost:14142/api/v1/users/me/picture' --header 'Authorization: token MY_API_TOKEN' --form 'file=@"LOCAL_FILEPATH"'` * Revert UnresolvedUri changes * Add upload for store logo
50 lines
2.0 KiB
C#
50 lines
2.0 KiB
C#
using System;
|
|
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<IEnumerable<StoreData>> GetStores(CancellationToken token = default)
|
|
{
|
|
return await SendHttpRequest<IEnumerable<StoreData>>("api/v1/stores", null, HttpMethod.Get, token);
|
|
}
|
|
|
|
public virtual async Task<StoreData> GetStore(string storeId, CancellationToken token = default)
|
|
{
|
|
return await SendHttpRequest<StoreData>($"api/v1/stores/{storeId}", null, HttpMethod.Get, token);
|
|
}
|
|
|
|
public virtual async Task RemoveStore(string storeId, CancellationToken token = default)
|
|
{
|
|
await SendHttpRequest($"api/v1/stores/{storeId}", null, HttpMethod.Delete, token);
|
|
}
|
|
|
|
public virtual async Task<StoreData> CreateStore(CreateStoreRequest request, CancellationToken token = default)
|
|
{
|
|
if (request == null) throw new ArgumentNullException(nameof(request));
|
|
return await SendHttpRequest<StoreData>("api/v1/stores", request, HttpMethod.Post, token);
|
|
}
|
|
|
|
public virtual async Task<StoreData> UpdateStore(string storeId, UpdateStoreRequest request, CancellationToken token = default)
|
|
{
|
|
if (request == null) throw new ArgumentNullException(nameof(request));
|
|
if (storeId == null) throw new ArgumentNullException(nameof(storeId));
|
|
return await SendHttpRequest<StoreData>($"api/v1/stores/{storeId}", request, HttpMethod.Put, token);
|
|
}
|
|
|
|
public virtual async Task<StoreData> UploadStoreLogo(string storeId, string filePath, string mimeType, CancellationToken token = default)
|
|
{
|
|
return await UploadFileRequest<StoreData>($"api/v1/stores/{storeId}/logo", filePath, mimeType, "file", HttpMethod.Post, token);
|
|
}
|
|
|
|
public virtual async Task DeleteStoreLogo(string storeId, CancellationToken token = default)
|
|
{
|
|
await SendHttpRequest($"api/v1/stores/{storeId}/logo", null, HttpMethod.Delete, token);
|
|
}
|
|
}
|