mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2026-02-17 21:56:26 +08:00
feat(work): 封装部分企业微信接口
This commit is contained in:
@@ -25,7 +25,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
if (request is null) throw new ArgumentNullException(nameof(request));
|
||||
|
||||
IFlurlRequest flurlReq = client
|
||||
.CreateRequest(HttpMethod.Get, "cgi-bin", "token")
|
||||
.CreateRequest(HttpMethod.Get, "cgi-bin", "gettoken")
|
||||
.SetOptions(request)
|
||||
.SetQueryParam("corpid", client.CorpId)
|
||||
.SetQueryParam("corpsecret", client.AgentSecret);
|
||||
@@ -75,5 +75,50 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
|
||||
return await client.SendRequestAsync<Models.CgibinGetApiDomainIpResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /cgi-bin/get_jsapi_ticket 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90136/90506 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90144/90539 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinGetJsapiTicketResponse> ExecuteCgibinGetJsapiTicketAsync(this WechatWorkClient client, Models.CgibinGetJsapiTicketRequest 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.Get, "cgi-bin", "get_jsapi_ticket")
|
||||
.SetOptions(request)
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestAsync<Models.CgibinGetJsapiTicketResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [GET] /cgi-bin/ticket/get 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90136/90506 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90144/90539 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinTicketGetResponse> ExecuteCgibinTicketGetAsync(this WechatWorkClient client, Models.CgibinTicketGetRequest 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.Get, "cgi-bin", "ticket", "get")
|
||||
.SetOptions(request)
|
||||
.SetQueryParam("access_token", request.AccessToken)
|
||||
.SetQueryParam("type", request.Type);
|
||||
|
||||
return await client.SendRequestAsync<Models.CgibinTicketGetResponse>(flurlReq, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user