mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 18:04:42 +08:00
feat(wxapi): 新增城市服务相关 API 封装
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
{
|
||||
public static class WechatApiClientExecuteCityServiceExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cityservice/sendmsgdata 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/framework/cityservice/cityservice-results-page.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CityServiceSendMessageDataResponse> ExecuteCityServiceSendMessageDataAsync(this WechatApiClient client, Models.CityServiceSendMessageDataRequest 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(HttpMethod.Post, "cityservice", "sendmsgdata")
|
||||
.SetOptions(request)
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CityServiceSendMessageDataResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,5 +31,26 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.IntpRealNameGetAuthUrlResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /intp/realname/checkrealnameinfo 接口。</para>
|
||||
/// <para>REF: https://developers.weixin.qq.com/miniprogram/dev/framework/cityservice/cityservice-checkrealnameinfo.html </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.IntpRealNameCheckRealNameInfoResponse> ExecuteIntpRealNameCheckRealNameInfoAsync(this WechatApiClient client, Models.IntpRealNameCheckRealNameInfoRequest 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(HttpMethod.Post, "intp", "realname", "checkrealnameinfo")
|
||||
.SetOptions(request)
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.IntpRealNameCheckRealNameInfoResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cityservice/sendmsgdata 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CityServiceSendMessageDataRequest : WechatApiRequest
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class DataItem : CgibinMessageTemplateSendRequest.Types.DataItem
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置用户唯一标识。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置城市服务分配的模板 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("biz_template_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("biz_template_id")]
|
||||
public string BusinessTemplateId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置结果页样式 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("result_page_style_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("result_page_style_id")]
|
||||
public string? ResultPageStyleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置办事记录样式 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("deal_msg_style_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("deal_msg_style_id")]
|
||||
public string? DealMessageStyleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置页卡样式 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("card_style_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("card_style_id")]
|
||||
public string? CardStyleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置订单号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("order_no")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("order_no")]
|
||||
public string OrderNumber { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置跳转链接 URL。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("url")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("url")]
|
||||
public string? Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置消息正文。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("data")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("data")]
|
||||
public IDictionary<string, Types.DataItem>? Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cityservice/sendmsgdata 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CityServiceSendMessageDataResponse : WechatApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置结果页 URL。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("result_page_url")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("result_page_url")]
|
||||
public string? ResultPageUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /intp/realname/checkrealnameinfo 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class IntpRealNameCheckRealNameInfoRequest : WechatApiRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置用户唯一标识。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("openid")]
|
||||
public string OpenId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置需要校验的姓名。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("real_name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("real_name")]
|
||||
public string RealName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// <para>获取或设置需要校验的证件类型。</para>
|
||||
/// <para>默认值:1</para>
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("cred_type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("cred_type")]
|
||||
public int CredentialType { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置需要校验的证件号。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("cred_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("cred_id")]
|
||||
public string CredentialId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置通过小程序回跳获取的 Code。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("code")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("code")]
|
||||
public string Code { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /intp/realname/checkrealnameinfo 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class IntpRealNameCheckRealNameInfoResponse : IntpMarketCodeActiveCodeQueryResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置 OpenId 验证结果,使用分号分隔。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("verify_openid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("verify_openid")]
|
||||
public string VerifyOpenIdResults { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置实名验证结果。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("verify_real_name")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("verify_real_name")]
|
||||
public string? VerifyRealNameResult { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user