mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-09-20 02:29:40 +08:00
feat(work): 新增企业发表内容到客户的朋友圈相关接口
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl;
|
||||
@@ -674,6 +672,27 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactGetMomentListResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/externalcontact/add_moment_task 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/95094 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95095 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinExternalContactAddMomentTaskResponse> ExecuteCgibinExternalContactAddMomentTaskAsync(this WechatWorkClient client, Models.CgibinExternalContactAddMomentTaskRequest 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", "externalcontact", "add_moment_task")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactAddMomentTaskResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/externalcontact/get_moment_task 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93333 </para>
|
||||
@@ -695,6 +714,27 @@ namespace SKIT.FlurlHttpClient.Wechat.Work
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactGetMomentTaskResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/externalcontact/get_moment_task_result 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/95094 </para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90001/90143/95095 </para>
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<Models.CgibinExternalContactGetMomentTaskResultResponse> ExecuteCgibinExternalContactGetMomentTaskResultAsync(this WechatWorkClient client, Models.CgibinExternalContactGetMomentTaskResultRequest 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", "externalcontact", "get_moment_task_result")
|
||||
.SetQueryParam("access_token", request.AccessToken);
|
||||
|
||||
return await client.SendRequestWithJsonAsync<Models.CgibinExternalContactGetMomentTaskResultResponse>(flurlReq, data: request, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>异步调用 [POST] /cgi-bin/externalcontact/get_moment_customer_list 接口。</para>
|
||||
/// <para>REF: https://open.work.weixin.qq.com/api/doc/90000/90135/93333 </para>
|
||||
|
@@ -0,0 +1,169 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/externalcontact/add_moment_task 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinExternalContactAddMomentTaskRequest : WechatWorkRequest
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Text
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置文本消息内容。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("content")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("content")]
|
||||
public string Content { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class Attachment
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Image
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置图片 MediaId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("media_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("media_id")]
|
||||
public string MediaId { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class Link
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置图文消息标题。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("title")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("title")]
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置图文消息 URL。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("url")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("url")]
|
||||
public string Url { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置图文消息封面 MediaId。。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("media_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("media_id")]
|
||||
public string? PictureMediaId { get; set; }
|
||||
}
|
||||
|
||||
public class Video
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置视频 MediaId。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("media_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("media_id")]
|
||||
public string MediaId { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置附件类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("msgtype")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("msgtype")]
|
||||
public string Type { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置图片附件信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("image")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("image")]
|
||||
public Types.Image? Image { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置图文消息附件信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("link")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("link")]
|
||||
public Types.Link? Link { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置视频附件信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("video")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("video")]
|
||||
public Types.Video? Video { get; set; }
|
||||
}
|
||||
|
||||
public class VisibleRange
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Sender
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置发表任务的执行者用户 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("user_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("user_list")]
|
||||
public IList<string>? UserIdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置发表任务的执行者部门 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("department_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("department_list")]
|
||||
public IList<int>? DepartmentIdList { get; set; }
|
||||
}
|
||||
|
||||
public class ExternalContact
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置可见到该朋友圈的客户标签 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("tag_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("tag_list")]
|
||||
public IList<int>? TagIdList { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置发表任务的执行者信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("sender_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("sender_list")]
|
||||
public Types.Sender? Sender { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置可见到该朋友圈的客户信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("external_contact_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("external_contact_list")]
|
||||
public Types.ExternalContact? ExternalContact { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置文本消息信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("text")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("text")]
|
||||
public Types.Text? Text { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置附件列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("attachments")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("attachments")]
|
||||
public IList<Types.Attachment>? AttachmentList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置发表范围信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("visible_range")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("visible_range")]
|
||||
public Types.VisibleRange? VisibleRange { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/externalcontact/add_moment_task 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinExternalContactAddMomentTaskResponse : WechatWorkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置异步任务 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("jobid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
|
||||
public string JobId { get; set; } = default!;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/externalcontact/get_moment_task_result 接口的请求。</para>
|
||||
/// </summary>
|
||||
public class CgibinExternalContactGetMomentTaskResultRequest : WechatWorkRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置异步任务 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("jobid")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("jobid")]
|
||||
public string JobId { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Work.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>表示 [POST] /cgi-bin/externalcontact/get_moment_task_result 接口的响应。</para>
|
||||
/// </summary>
|
||||
public class CgibinExternalContactGetMomentTaskResultResponse : WechatWorkResponse
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Result
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public class Sender
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置发表任务的执行者用户 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("user_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("user_list")]
|
||||
public string[]? UserIdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置发表任务的执行者部门 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("department_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("department_list")]
|
||||
public int[]? DepartmentIdList { get; set; }
|
||||
}
|
||||
|
||||
public class ExternalContact
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置可见到该朋友圈的客户标签 ID 列表。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("tag_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("tag_list")]
|
||||
public int[]? TagIdList { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置错误码。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("errcode")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("errcode")]
|
||||
public int ErrorCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置错误信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("errmsg")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("errmsg")]
|
||||
public string ErrorMessage { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置朋友圈 ID。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("moment_id")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("moment_id")]
|
||||
public string MomentId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置不合法的执行者信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("invalid_sender_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("invalid_sender_list")]
|
||||
public Types.Sender? InvalidSender { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置不合法的客户信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("invalid_external_contact_list")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("invalid_external_contact_list")]
|
||||
public Types.ExternalContact? InvalidExternalContact { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置操作类型。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("type")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("type")]
|
||||
public string Type { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置任务状态。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("status")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("status")]
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置处理结果信息。
|
||||
/// </summary>
|
||||
[Newtonsoft.Json.JsonProperty("result")]
|
||||
[System.Text.Json.Serialization.JsonPropertyName("result")]
|
||||
public Types.Result Result { get; set; } = default!;
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"text": {
|
||||
"content": "文本消息内容"
|
||||
},
|
||||
"attachments": [
|
||||
{
|
||||
"msgtype": "image",
|
||||
"image": {
|
||||
"media_id": "MEDIA_ID"
|
||||
}
|
||||
},
|
||||
{
|
||||
"msgtype": "video",
|
||||
"video": {
|
||||
"media_id": "MEDIA_ID"
|
||||
}
|
||||
},
|
||||
{
|
||||
"msgtype": "link",
|
||||
"link": {
|
||||
"title": "消息标题",
|
||||
"url": "https://example.link.com/path",
|
||||
"media_id": "MEDIA_ID"
|
||||
}
|
||||
}
|
||||
],
|
||||
"visible_range": {
|
||||
"sender_list": {
|
||||
"user_list": [
|
||||
"zhangshan",
|
||||
"lisi"
|
||||
],
|
||||
"department_list": [
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
"external_contact_list": {
|
||||
"tag_list": [
|
||||
1,
|
||||
2
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"errcode":0,
|
||||
"errmsg":"ok",
|
||||
"jobid":"xxxx"
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"jobid": "xxxx"
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"status": 1,
|
||||
"type": "add_moment_task",
|
||||
"result": {
|
||||
"errcode": 0,
|
||||
"errmsg": "ok",
|
||||
"moment_id": "xxxx",
|
||||
"invalid_sender_list": {
|
||||
"user_list": [
|
||||
"zhangshan",
|
||||
"lisi"
|
||||
],
|
||||
"department_list": [
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
"invalid_external_contact_list": {
|
||||
"tag_list": [
|
||||
1
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user