#nullable enable using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; using BTCPayServer.Client.Models; namespace BTCPayServer.Client; public partial class BTCPayServerClient { public async Task CreateOffering(string storeId, OfferingModel offering, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings", offering, HttpMethod.Post, token); public async Task UpdateOffering(string storeId, string offeringId, OfferingModel offering, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}", offering, HttpMethod.Put, token); public async Task CreateOfferingPlan(string storeId, string offeringId, CreatePlanRequest request, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/plans", request, HttpMethod.Post, token); public async Task UpdateOfferingPlan(string storeId, string offeringId, string planId, CreatePlanRequest request, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/plans/{planId}", request, HttpMethod.Put, token); public async Task GetOfferingPlan(string storeId, string offeringId, string planId, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/plans/{planId}", null, HttpMethod.Get, token); public async Task GetOffering(string storeId, string offeringId, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}", null, HttpMethod.Get, token); public async Task GetOfferings(string storeId, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings", null, HttpMethod.Get, token); public async Task CreatePlanCheckout(CreatePlanCheckoutRequest request, CancellationToken token = default) => await SendHttpRequest($"api/v1/plan-checkout", request, HttpMethod.Post, token); public async Task GetPlanCheckout(string checkoutId, CancellationToken token = default) => await SendHttpRequest($"api/v1/plan-checkout/{checkoutId}", null, HttpMethod.Get, token); public async Task GetCredit(string storeId, string offeringId, string customerSelector, string currency, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/subscribers/{Uri.EscapeDataString(customerSelector)}/credits/{currency}", null, HttpMethod.Get, token); public async Task UpdateCredit(string storeId, string offeringId, string customerSelector, string currency, UpdateCreditRequest request, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/subscribers/{Uri.EscapeDataString(customerSelector)}/credits/{currency}", request, HttpMethod.Post, token); public async Task ProceedPlanCheckout(string checkoutId, string? email = null, CancellationToken token = default) { if (email is not null) return await SendHttpRequest($"api/v1/plan-checkout/{checkoutId}?email={Uri.EscapeDataString(email)}", null, HttpMethod.Post, token); else return await SendHttpRequest($"api/v1/plan-checkout/{checkoutId}", null, HttpMethod.Post, token); } public async Task GetSubscriber(string storeId, string offeringId, string customerSelector, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/subscribers/{Uri.EscapeDataString(customerSelector)}", null, HttpMethod.Get, token); public async Task DeleteSubscriber(string storeId, string offeringId, string customerSelector, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/subscribers/{Uri.EscapeDataString(customerSelector)}", null, HttpMethod.Delete, token); public async Task SuspendSubscriber(string storeId, string offeringId, string customerSelector, string? reason = null, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/subscribers/{Uri.EscapeDataString(customerSelector)}/suspend", new SuspendSubscriberRequest() { Reason = reason }, HttpMethod.Post, token); public async Task UnsuspendSubscriber(string storeId, string offeringId, string customerSelector, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/subscribers/{customerSelector}/unsuspend", null, HttpMethod.Post, token); public async Task UpdateSubscriberDates(string storeId, string offeringId, string customerSelector, UpdateSubscriberDatesRequest request, CancellationToken token = default) => await SendHttpRequest($"api/v1/stores/{storeId}/offerings/{offeringId}/subscribers/{Uri.EscapeDataString(customerSelector)}/dates", request, HttpMethod.Put, token); public async Task CreatePortalSession(CreatePortalSessionRequest request, CancellationToken token = default) => await SendHttpRequest($"api/v1/subscriber-portal", request, HttpMethod.Post, token); public async Task GetPortalSession(string portalSessionId, CancellationToken token = default) => await SendHttpRequest($"api/v1/subscriber-portal/{portalSessionId}", null, HttpMethod.Get, token); }