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 WechatTenpayClientExecuteMerchantFundExtensions { #region Balance /// /// 异步调用 [GET] /merchant/fund/balance/{account_type} 接口。 /// /// REF:
///
/// ///
///
/// /// /// /// public static async Task ExecuteGetMerchantFundBalanceAsync(this WechatTenpayClient client, Models.GetMerchantFundBalanceRequest 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, "merchant", "fund", "balance", request.AccountType); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } /// /// 异步调用 [GET] /merchant/fund/dayendbalance/{account_type} 接口。 /// /// REF:
///
/// ///
///
/// /// /// /// public static async Task ExecuteGetMerchantFundDayendBalanceAsync(this WechatTenpayClient client, Models.GetMerchantFundDayendBalanceRequest 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, "merchant", "fund", "dayendbalance", request.AccountType) .SetQueryParam("date", request.DateString); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } #endregion #region IncomeRecords /// /// 异步调用 [GET] /merchantfund/merchant/income-records 接口。 /// /// REF:
///
/// ///
///
/// /// /// /// public static async Task ExecuteQueryMerchantFundMerchantIncomeRecordsAsync(this WechatTenpayClient client, Models.QueryMerchantFundMerchantIncomeRecordsRequest 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, "merchantfund", "merchant", "income-records") .SetQueryParam("account_type", request.AccountType) .SetQueryParam("date", request.DateString) .SetQueryParam("limit", request.Limit) .SetQueryParam("offset", request.Offset); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } /// /// 异步调用 [GET] /merchantfund/partner/income-records 接口。 /// /// REF:
/// ///
///
/// /// /// /// public static async Task ExecuteQueryMerchantFundPartnerIncomeRecordsAsync(this WechatTenpayClient client, Models.QueryMerchantFundPartnerIncomeRecordsRequest 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, "merchantfund", "partner", "income-records") .SetQueryParam("sub_mchid", request.SubMerchantId) .SetQueryParam("account_type", request.AccountType) .SetQueryParam("date", request.DateString) .SetQueryParam("limit", request.Limit) .SetQueryParam("offset", request.Offset); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } #endregion #region Withdraw /// /// 异步调用 [POST] /merchant/fund/withdraw 接口。 /// /// REF:
/// ///
///
/// /// /// /// public static async Task ExecuteCreateMerchantFundWithdrawAsync(this WechatTenpayClient client, Models.CreateMerchantFundWithdrawRequest 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, "merchant", "fund", "withdraw"); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } /// /// 异步调用 [GET] /merchant/fund/withdraw/out-request-no/{out_request_no} 接口。 /// /// REF:
/// ///
///
/// /// /// /// public static async Task ExecuteGetMerchantFundWithdrawByOutRequestNumberAsync(this WechatTenpayClient client, Models.GetMerchantFundWithdrawByOutRequestNumberRequest 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, "merchant", "fund", "withdraw", "out-request-no", request.OutRequestNumber); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } /// /// 异步调用 [GET] /merchant/fund/withdraw/{withdraw_id} 接口。 /// /// REF:
/// ///
///
/// /// /// /// public static async Task ExecuteGetMerchantFundWithdrawByWithdrawIdAsync(this WechatTenpayClient client, Models.GetMerchantFundWithdrawByWithdrawIdRequest 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, "merchant", "fund", "withdraw", request.WithdrawId); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } /// /// 异步调用 [GET] /merchant/fund/withdraw/bill-type/{bill_type} 接口。 /// /// REF:
///
/// ///
///
/// /// /// /// public static async Task ExecuteGetMerchantFundWithdrawBillAsync(this WechatTenpayClient client, Models.GetMerchantFundWithdrawBillRequest 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, "merchant", "fund", "withdraw", "bill-type", request.BillType) .SetQueryParam("bill_date", request.BillDateString) .SetQueryParam("tar_type", request.TarType); return await client.SendFlurlRequestAsJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken).ConfigureAwait(false); } #endregion } }