using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
{
///
/// 为 提供连锁品牌分账相关的 API 扩展方法。
///
public static class WechatTenpayClientExecuteBrandProfitSharingExtensions
{
///
/// 异步调用 [POST] /brand/profitsharing/orders 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_1.shtml
///
///
///
///
///
public static async Task ExecuteCreateBrandProfitSharingOrderAsync(this WechatTenpayClient client, Models.CreateBrandProfitSharingOrderRequest 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
.CreateRequest(request, HttpMethod.Post, "brand", "profitsharing", "orders");
return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken);
}
///
/// 异步调用 [GET] /brand/profitsharing/orders 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_2.shtml
///
///
///
///
///
public static async Task ExecuteGetBrandProfitSharingOrderByOutOrderNumberAsync(this WechatTenpayClient client, Models.GetBrandProfitSharingOrderByOutOrderNumberRequest 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
.CreateRequest(request, HttpMethod.Get, "brand", "profitsharing", "orders")
.SetQueryParam("sub_mchid", request.SubMerchantId)
.SetQueryParam("transaction_id", request.TransactionId)
.SetQueryParam("out_order_no", request.OutOrderNumber);
return await client.SendRequestWithJsonAsync(flurlReq, cancellationToken: cancellationToken);
}
///
/// 异步调用 [POST] /brand/profitsharing/returnorders 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_3.shtml
///
///
///
///
///
public static async Task ExecuteCreateBrandProfitSharingReturnOrderAsync(this WechatTenpayClient client, Models.CreateBrandProfitSharingReturnOrderRequest 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
.CreateRequest(request, HttpMethod.Post, "brand", "profitsharing", "returnorders");
return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken);
}
///
/// 异步调用 [GET] /brand/profitsharing/returnorders 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_4.shtml
///
///
///
///
///
public static async Task ExecuteGetBrandProfitSharingReturnOrderByOutOrderNumberAsync(this WechatTenpayClient client, Models.GetBrandProfitSharingReturnOrderByOutOrderNumberRequest 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
.CreateRequest(request, HttpMethod.Get, "brand", "profitsharing", "returnorders")
.SetQueryParam("sub_mchid", request.SubMerchantId)
.SetQueryParam("out_order_no", request.OutOrderNumber)
.SetQueryParam("out_return_no", request.OutReturnNumber);
return await client.SendRequestWithJsonAsync(flurlReq, cancellationToken: cancellationToken);
}
///
/// 异步调用 [GET] /brand/profitsharing/returnorders 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_4.shtml
///
///
///
///
///
public static async Task ExecuteGetBrandProfitSharingReturnOrderByOrderIdAsync(this WechatTenpayClient client, Models.GetBrandProfitSharingReturnOrderByOrderIdRequest 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
.CreateRequest(request, HttpMethod.Get, "brand", "profitsharing", "returnorders")
.SetQueryParam("sub_mchid", request.SubMerchantId)
.SetQueryParam("order_id", request.OrderId)
.SetQueryParam("out_return_no", request.OutReturnNumber);
return await client.SendRequestWithJsonAsync(flurlReq, cancellationToken: cancellationToken);
}
///
/// 异步调用 [POST] /brand/profitsharing/finish-order 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_5.shtml
///
///
///
///
///
public static async Task ExecuteSetBrandProfitSharingOrderFinishAsync(this WechatTenpayClient client, Models.SetBrandProfitSharingOrderFinishRequest 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
.CreateRequest(request, HttpMethod.Post, "brand", "profitsharing", "finish-order");
return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken);
}
///
/// 异步调用 [GET] /brand/profitsharing/orders/{transaction_id}/amounts 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_9.shtml
///
///
///
///
///
public static async Task ExecuteGetBrandProfitSharingOrderAmountsAsync(this WechatTenpayClient client, Models.GetBrandProfitSharingOrderAmountsRequest 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
.CreateRequest(request, HttpMethod.Get, "brand", "profitsharing", "orders", request.TransactionId, "amounts");
return await client.SendRequestWithJsonAsync(flurlReq, cancellationToken: cancellationToken);
}
///
/// 异步调用 [GET] /brand/profitsharing/brand-configs/{brand_mchid} 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_10.shtml
///
///
///
///
///
public static async Task ExecuteGetBrandProfitSharingBrandConfigsAsync(this WechatTenpayClient client, Models.GetBrandProfitSharingBrandConfigsRequest 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
.CreateRequest(request, HttpMethod.Get, "brand", "profitsharing", "brand-configs", request.BrandMerchantId);
return await client.SendRequestWithJsonAsync(flurlReq, cancellationToken: cancellationToken);
}
///
/// 异步调用 [POST] /brand/profitsharing/receivers/add 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_7.shtml
///
///
///
///
///
public static async Task ExecuteAddBrandProfitSharingReceiverAsync(this WechatTenpayClient client, Models.AddBrandProfitSharingReceiverRequest 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
.CreateRequest(request, HttpMethod.Post, "brand", "profitsharing", "receivers", "add");
return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken);
}
///
/// 异步调用 [POST] /brand/profitsharing/receivers/delete 接口。
/// REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_7_8.shtml
///
///
///
///
///
public static async Task ExecuteDeleteBrandProfitSharingReceiverAsync(this WechatTenpayClient client, Models.DeleteBrandProfitSharingReceiverRequest 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
.CreateRequest(request, HttpMethod.Post, "brand", "profitsharing", "receivers", "delete");
return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken);
}
}
}