using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Flurl; using Flurl.Http; namespace SKIT.FlurlHttpClient.Wechat.TenpayV3 { public static class WechatTenpayClientExecuteRefundExtensions { /// /// 异步调用 [POST] /refund/domestic/refunds 接口。 /// /// REF:
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
/// ///
///
/// /// /// /// public static async Task ExecuteCreateRefundDomesticRefundAsync(this WechatTenpayClient client, Models.CreateRefundDomesticRefundRequest request, CancellationToken cancellationToken = default) { if (client is null) throw new ArgumentNullException(nameof(client)); if (request is null) throw new ArgumentNullException(nameof(request)); IFlurlRequest flurlReq = client .CreateFlurlRequest(request, HttpMethod.Post, "refund", "domestic", "refunds"); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /refund/domestic/refunds/{out_refund_no} 接口。 /// /// REF:
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
/// ///
///
/// /// /// /// public static async Task ExecuteGetRefundDomesticRefundByOutRefundNumberAsync(this WechatTenpayClient client, Models.GetRefundDomesticRefundByOutRefundNumberRequest request, CancellationToken cancellationToken = default) { if (client is null) throw new ArgumentNullException(nameof(client)); if (request is null) throw new ArgumentNullException(nameof(request)); IFlurlRequest flurlReq = client .CreateFlurlRequest(request, HttpMethod.Get, "refund", "domestic", "refunds", request.OutRefundNumber); if (request.SubMerchantId is not null) flurlReq.SetQueryParam("sub_mchid", request.SubMerchantId); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /refund/domestic/refunds/{refund_id}/apply-abnormal-refund 接口。 /// /// REF:
///
/// ///
///
/// /// /// /// public static async Task ExecuteCreateRefundDomesticAbnormalRefundApplyAsync(this WechatTenpayClient client, Models.CreateRefundDomesticAbnormalRefundApplyRequest request, CancellationToken cancellationToken = default) { if (client is null) throw new ArgumentNullException(nameof(client)); if (request is null) throw new ArgumentNullException(nameof(request)); IFlurlRequest flurlReq = client .CreateFlurlRequest(request, HttpMethod.Post, "refund", "domestic", "refunds", request.RefundId, "apply-abnormal-refund"); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } } }