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: https://pay.weixin.qq.com/docs/merchant/apis/jsapi-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/in-app-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/h5-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/native-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/mini-program-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/combine-payment/refunds/create.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/refund/refunds/create.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/weixin-pay-score/refunds/create.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/wexin-pay-score-parking/create.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/wexin-pay-score-parking/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-in-app-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-h5-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-native-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-mini-program-payment/create.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/combine-payment/refunds/create.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/refund/refunds/create.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/wexin-pay-score-parking/create.html
///
///
///
///
///
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: https://pay.weixin.qq.com/docs/merchant/apis/jsapi-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/in-app-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/h5-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/native-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/mini-program-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/combine-payment/refunds/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/refund/refunds/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/merchant/apis/weixin-pay-score/refunds/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-jsapi-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-in-app-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-h5-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-native-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/partner-mini-program-payment/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/refund/refunds/create.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/refund/refunds/query-by-out-refund-no.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/wexin-pay-score-parking/query-by-out-refund-no.html
///
///
///
///
///
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: https://pay.weixin.qq.com/docs/merchant/apis/refund/refunds/create-abnormal-refund.html
/// REF: https://pay.weixin.qq.com/docs/partner/apis/refund/refunds/create-abnormal-refund.html
///
///
///
///
///
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);
}
}
}