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.Work { public static class WechatWorkClientExecuteCgibinLivingExtensions { /// /// 异步调用 [POST] /cgi-bin/living/create 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93637 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93717 /// /// /// /// /// public static async Task ExecuteCgibinLivingCreateAsync(this WechatWorkClient client, Models.CgibinLivingCreateRequest 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, "cgi-bin", "living", "create") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /cgi-bin/living/modify 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93640 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93720 /// /// /// /// /// public static async Task ExecuteCgibinLivingModifyAsync(this WechatWorkClient client, Models.CgibinLivingModifyRequest 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, "cgi-bin", "living", "modify") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /cgi-bin/living/cancel 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93638 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93718 /// /// /// /// /// public static async Task ExecuteCgibinLivingCancelAsync(this WechatWorkClient client, Models.CgibinLivingCancelRequest 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, "cgi-bin", "living", "cancel") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /cgi-bin/living/delete_replay_data 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93874 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93719 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93743 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93860 /// /// /// /// /// public static async Task ExecuteCgibinLivingDeleteReplayDataAsync(this WechatWorkClient client, Models.CgibinLivingDeleteReplayDataRequest 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, "cgi-bin", "living", "delete_replay_data") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [GET] /cgi-bin/living/get_living_info 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93635 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93715 /// /// /// /// /// public static async Task ExecuteCgibinLivingGetLivingInfoAsync(this WechatWorkClient client, Models.CgibinLivingGetLivingInfoRequest 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, "cgi-bin", "living", "get_living_info") .SetQueryParam("access_token", request.AccessToken) .SetQueryParam("livingid", request.LivingId); return await client.SendRequestWithJsonAsync(flurlReq, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /cgi-bin/living/get_living_code 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93641 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93721 /// /// /// /// /// public static async Task ExecuteCgibinLivingGetLivingCodeAsync(this WechatWorkClient client, Models.CgibinLivingGetLivingCodeRequest 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, "cgi-bin", "living", "get_living_code") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /cgi-bin/living/get_living_share_info 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/94442 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/94578 /// /// /// /// /// public static async Task ExecuteCgibinLivingGetLivingShareInfoAsync(this WechatWorkClient client, Models.CgibinLivingGetLivingShareInfoRequest 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, "cgi-bin", "living", "get_living_share_info") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /cgi-bin/living/get_user_all_livingid 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93634 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93714 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93739 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93856 /// /// /// /// /// public static async Task ExecuteCgibinLivingGetUserAllLivingIdAsync(this WechatWorkClient client, Models.CgibinLivingGetUserAllLivingIdRequest 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, "cgi-bin", "living", "get_user_all_livingid") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } /// /// 异步调用 [POST] /cgi-bin/living/get_watch_stat 接口。 /// REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93636 /// REF: https://open.work.weixin.qq.com/api/doc/90001/90143/93716 /// /// /// /// /// public static async Task ExecuteCgibinLivingGetWatchStatisticsAsync(this WechatWorkClient client, Models.CgibinLivingGetWatchStatisticsRequest 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, "cgi-bin", "living", "get_watch_stat") .SetQueryParam("access_token", request.AccessToken); return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); } } }