feat(tenpayv3): 新增消费者投诉图片下载接口

This commit is contained in:
Fu Diwei 2021-08-30 12:48:26 +08:00
parent a48c79c996
commit 8885be2f80
4 changed files with 57 additions and 1 deletions

View File

@ -123,7 +123,8 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
if (request is null) throw new ArgumentNullException(nameof(request));
IFlurlRequest flurlReq = client
.CreateRequest(request, HttpMethod.Get, request.DownloadUrl);
.CreateRequest(request, HttpMethod.Get);
flurlReq.Url = new Url(new Uri(request.DownloadUrl));
return await client.SendRequestWithJsonAsync<Models.DownloadBillFileResponse>(flurlReq, cancellationToken: cancellationToken);
}

View File

@ -257,5 +257,26 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
return await client.SendRequestAsync<Models.UploadMerchantServiceImageResponse>(flurlReq, httpContent: httpContent, cancellationToken: cancellationToken);
}
/// <summary>
/// <para>异步调用 [GET] /{download_url} 接口。</para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter10_2_18.shtml </para>
/// <para>REF: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter10_2_18.shtml </para>
/// </summary>
/// <param name="client"></param>
/// <param name="request"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static async Task<Models.DownloadMerchantServiceImageResponse> ExecuteDownloadMerchantServiceImageAsync(this WechatTenpayClient client, Models.DownloadMerchantServiceImageRequest 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);
flurlReq.Url = new Url(new Uri(request.DownloadUrl));
return await client.SendRequestWithJsonAsync<Models.DownloadMerchantServiceImageResponse>(flurlReq, cancellationToken: cancellationToken);
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /{download_url} 接口的请求。</para>
/// </summary>
public class DownloadMerchantServiceImageRequest : WechatTenpayRequest
{
/// <summary>
/// 获取或设置图片下载地址。
/// </summary>
[Newtonsoft.Json.JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
public string DownloadUrl { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Models
{
/// <summary>
/// <para>表示 [GET] /{download_url} 接口的响应。</para>
/// </summary>
public class DownloadMerchantServiceImageResponse : WechatTenpayResponse
{
public override bool IsSuccessful()
{
return base.IsSuccessful() && RawBytes.Length > 0;
}
}
}