From 9c42ab19d104fd327ffd11601fc14225142be6eb Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Thu, 21 Oct 2021 21:31:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(wxapi):=20=E6=96=B0=E5=A2=9E=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E8=83=BD=E5=8A=9B=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Events/MpGuide/GuideQrcodeScanEvent.cs | 4 +- .../Events/MpJob/FreePublishJobFinishEvent.cs | 110 +++++++++++++++++ ...lientExecuteCgibinFreePublishExtensions.cs | 114 ++++++++++++++++++ .../CgibinDraftBatchGetResponse.cs | 17 +-- .../CgibinFreePublishBatchGetRequest.cs | 34 ++++++ .../CgibinFreePublishBatchGetResponse.cs | 79 ++++++++++++ .../CgibinFreePublishDeleteRequest.cs | 25 ++++ .../CgibinFreePublishDeleteResponse.cs | 12 ++ .../CgibinFreePublishGetArticleRequest.cs | 18 +++ .../CgibinFreePublishGetArticleResponse.cs | 31 +++++ .../CgibinFreePublishGetRequest.cs | 18 +++ .../CgibinFreePublishGetResponse.cs | 86 +++++++++++++ .../CgibinFreePublishSubmitRequest.cs | 18 +++ .../CgibinFreePublishSubmitResponse.cs | 18 +++ .../MpJob/FreePublishJobFinishEvent.xml | 23 ++++ .../CgibinFreePublishBatchGetRequest.json | 5 + .../CgibinFreePublishBatchGetResponse.json | 27 +++++ .../CgibinFreePublishDeleteRequest.json | 4 + .../CgibinFreePublishDeleteResponse.json | 4 + .../CgibinFreePublishGetArticleRequest.json | 3 + .../CgibinFreePublishGetArticleResponse.json | 17 +++ .../CgibinFreePublishGetRequest.json | 3 + .../CgibinFreePublishGetResponse.json | 15 +++ .../CgibinFreePublishSubmitRequest.json | 3 + .../CgibinFreePublishSubmitResponse.json | 5 + 25 files changed, 679 insertions(+), 14 deletions(-) create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Events/MpJob/FreePublishJobFinishEvent.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinFreePublishExtensions.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishBatchGetRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishBatchGetResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishDeleteRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishDeleteResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetArticleRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetArticleResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetResponse.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishSubmitRequest.cs create mode 100644 src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishSubmitResponse.cs create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/EventSamples/MpJob/FreePublishJobFinishEvent.xml create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishBatchGetRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishBatchGetResponse.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishDeleteRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishDeleteResponse.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetArticleRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetArticleResponse.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetResponse.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishSubmitRequest.json create mode 100644 test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishSubmitResponse.json diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Events/MpGuide/GuideQrcodeScanEvent.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Events/MpGuide/GuideQrcodeScanEvent.cs index 69449edf..f02fea91 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Events/MpGuide/GuideQrcodeScanEvent.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Events/MpGuide/GuideQrcodeScanEvent.cs @@ -11,7 +11,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Events { public static class Types { - public class Data + public class EventData { /// /// 获取或设置顾问微信号。 @@ -61,6 +61,6 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Events [Newtonsoft.Json.JsonProperty("GuideScanEvent")] [System.Text.Json.Serialization.JsonPropertyName("GuideScanEvent")] [System.Xml.Serialization.XmlElement("GuideScanEvent")] - public Types.Data EventData { get; set; } = default!; + public Types.EventData EventData { get; set; } = default!; } } diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Events/MpJob/FreePublishJobFinishEvent.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Events/MpJob/FreePublishJobFinishEvent.cs new file mode 100644 index 00000000..556481b5 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Events/MpJob/FreePublishJobFinishEvent.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Events +{ + /// + /// 表示 EVENT.FREEPUBLISHJOBFINISH 事件的数据。 + /// REF: https://developers.weixin.qq.com/doc/offiaccount/Publish/Callback_on_finish.html + /// + public class FreePublishJobFinishEvent : WechatApiEvent, WechatApiEvent.Serialization.IJsonSerializable, WechatApiEvent.Serialization.IXmlSerializable + { + public static class Types + { + public class EventData + { + public static class Types + { + public class ArticleDetail + { + public static class Types + { + public class Item + { + /// + /// 获取或设置文章索引。 + /// + [Newtonsoft.Json.JsonProperty("idx")] + [System.Text.Json.Serialization.JsonPropertyName("idx")] + [System.Xml.Serialization.XmlElement("idx")] + public int Index { get; set; } + + /// + /// 获取或设置文章 URL。 + /// + [Newtonsoft.Json.JsonProperty("article_url")] + [System.Text.Json.Serialization.JsonPropertyName("article_url")] + [System.Xml.Serialization.XmlElement("article_url")] + public string ArticleUrl { get; set; } = default!; + } + } + + /// + /// 获取或设置文章数量。 + /// + [Newtonsoft.Json.JsonProperty("count")] + [System.Text.Json.Serialization.JsonPropertyName("count")] + [System.Xml.Serialization.XmlElement("count")] + public int Count { get; set; } + + /// + /// 获取或设置文章列表。 + /// + [Newtonsoft.Json.JsonProperty("item")] + [System.Text.Json.Serialization.JsonPropertyName("item")] + [System.Xml.Serialization.XmlArrayItem("item", Type = typeof(Types.Item))] + public Types.Item[] List { get; set; } = default!; + } + } + + /// + /// 获取或设置消息 ID。 + /// + [Newtonsoft.Json.JsonProperty("publish_id")] + [System.Text.Json.Serialization.JsonPropertyName("publish_id")] + [System.Xml.Serialization.XmlElement("publish_id")] + public string PublishId { get; set; } = default!; + + /// + /// 获取或设置发布状态。 + /// + [Newtonsoft.Json.JsonProperty("publish_status")] + [System.Text.Json.Serialization.JsonPropertyName("publish_status")] + [System.Xml.Serialization.XmlElement("publish_status")] + public int PublishStatus { get; set; } + + /// + /// 获取或设置图文消息的 ArticleId。 + /// + [Newtonsoft.Json.JsonProperty("article_id")] + [System.Text.Json.Serialization.JsonPropertyName("article_id")] + [System.Xml.Serialization.XmlElement("article_id")] + public string? ArticleId { get; set; } + + /// + /// 获取或设置图文消息的详细信息。 + /// + [Newtonsoft.Json.JsonProperty("article_detail")] + [System.Text.Json.Serialization.JsonPropertyName("article_detail")] + [System.Xml.Serialization.XmlElement("article_detail")] + public Types.ArticleDetail? ArticleDetail { get; set; } + + /// + /// 获取或设置不通过的文章索引列表。 + /// + [Newtonsoft.Json.JsonProperty("fail_idx")] + [System.Text.Json.Serialization.JsonPropertyName("fail_idx")] + [System.Xml.Serialization.XmlArrayItem("fail_idx", Type = typeof(int))] + public int[]? FailedIndexList { get; set; } + } + } + + /// + /// 获取或设置事件数据。 + /// + [Newtonsoft.Json.JsonProperty("PublishEventInfo")] + [System.Text.Json.Serialization.JsonPropertyName("PublishEventInfo")] + [System.Xml.Serialization.XmlElement("PublishEventInfo")] + public Types.EventData EventData { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinFreePublishExtensions.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinFreePublishExtensions.cs new file mode 100644 index 00000000..b04d35e1 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Extensions/WechatApiClientExecuteCgibinFreePublishExtensions.cs @@ -0,0 +1,114 @@ +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.Api +{ + public static class WechatApiClientExecuteCgibinFreePublishExtensions + { + /// + /// 异步调用 [POST] /cgi-bin/freepublish/submit 接口。 + /// REF: https://developers.weixin.qq.com/doc/offiaccount/Publish/Publish.html + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinFreePublishSubmitAsync(this WechatApiClient client, Models.CgibinFreePublishSubmitRequest 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", "freepublish", "submit") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/freepublish/get 接口。 + /// REF: https://developers.weixin.qq.com/doc/offiaccount/Publish/Get_status.html + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinFreePublishGetAsync(this WechatApiClient client, Models.CgibinFreePublishGetRequest 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", "freepublish", "get") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/freepublish/delete 接口。 + /// REF: https://developers.weixin.qq.com/doc/offiaccount/Publish/Delete_posts.html + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinFreePublishDeleteAsync(this WechatApiClient client, Models.CgibinFreePublishDeleteRequest 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", "freepublish", "delete") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/freepublish/getarticle 接口。 + /// REF: https://developers.weixin.qq.com/doc/offiaccount/Publish/Get_article_from_id.html + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinFreePublishGetArticleAsync(this WechatApiClient client, Models.CgibinFreePublishGetArticleRequest 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", "freepublish", "getarticle") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + + /// + /// 异步调用 [POST] /cgi-bin/freepublish/batchget 接口。 + /// REF: https://developers.weixin.qq.com/doc/offiaccount/Publish/Get_publication_records.html + /// + /// + /// + /// + /// + public static async Task ExecuteCgibinFreePublishBatchGetAsync(this WechatApiClient client, Models.CgibinFreePublishBatchGetRequest 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", "freepublish", "batchget") + .SetQueryParam("access_token", request.AccessToken); + + return await client.SendRequestWithJsonAsync(flurlReq, data: request, cancellationToken: cancellationToken); + } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinDraft/CgibinDraftBatchGetResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinDraft/CgibinDraftBatchGetResponse.cs index d27dfb84..e00d9d59 100644 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinDraft/CgibinDraftBatchGetResponse.cs +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinDraft/CgibinDraftBatchGetResponse.cs @@ -10,7 +10,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models { public static class Types { - public class Draft + public class Item { public static class Types { @@ -47,18 +47,11 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models public Types.Content? Content { get; set; } /// - /// 获取或设置修改时间戳。 + /// 获取或设置更新时间戳。 /// [Newtonsoft.Json.JsonProperty("update_time")] [System.Text.Json.Serialization.JsonPropertyName("update_time")] public long UpdateTimestamp { get; set; } - - /// - /// 获取或设置创建时间戳。 - /// - [Newtonsoft.Json.JsonProperty("create_time")] - [System.Text.Json.Serialization.JsonPropertyName("create_time")] - public long CreateTimestamp { get; set; } } } @@ -67,14 +60,14 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Models /// [Newtonsoft.Json.JsonProperty("item")] [System.Text.Json.Serialization.JsonPropertyName("item")] - public Types.Draft[] DraftList { get; set; } = default!; + public Types.Item[] List { get; set; } = default!; /// - /// 获取或设置本次草稿数量。 + /// 获取或设置本次数量。 /// [Newtonsoft.Json.JsonProperty("item_count")] [System.Text.Json.Serialization.JsonPropertyName("item_count")] - public int DraftCount { get; set; } = default!; + public int Count { get; set; } = default!; /// /// 获取或设置草稿总数。 diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishBatchGetRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishBatchGetRequest.cs new file mode 100644 index 00000000..7f577081 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishBatchGetRequest.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/batchget 接口的请求。 + /// + public class CgibinFreePublishBatchGetRequest : WechatApiRequest + { + /// + /// 获取或设置分页起始位置。 + /// + [Newtonsoft.Json.JsonProperty("offset")] + [System.Text.Json.Serialization.JsonPropertyName("offset")] + public int Offset { get; set; } + + /// + /// 获取或设置分页每页数量。 + /// + [Newtonsoft.Json.JsonProperty("count")] + [System.Text.Json.Serialization.JsonPropertyName("count")] + public int Limit { get; set; } = 10; + + /// + /// 获取或设置是否不返回内容。 + /// + [Newtonsoft.Json.JsonProperty("no_content")] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.NumericalNullableBooleanConverter))] + [System.Text.Json.Serialization.JsonPropertyName("no_content")] + [System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Converters.NumericalNullableBooleanConverter))] + public bool? RequireNoContent { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishBatchGetResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishBatchGetResponse.cs new file mode 100644 index 00000000..31a24152 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishBatchGetResponse.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/batchget 接口的响应。 + /// + public class CgibinFreePublishBatchGetResponse : WechatApiResponse + { + public static class Types + { + public class Item + { + public static class Types + { + public class Content + { + public static class Types + { + public class Article : CgibinFreePublishGetArticleResponse.Types.Article + { + } + } + + /// + /// 获取或设置草稿图文消息列表。 + /// + [Newtonsoft.Json.JsonProperty("news_item")] + [System.Text.Json.Serialization.JsonPropertyName("news_item")] + public Types.Article[] ArticleList { get; set; } = default!; + } + } + + /// + /// 获取或设置图文消息的 ArticleId。 + /// + [Newtonsoft.Json.JsonProperty("article_id")] + [System.Text.Json.Serialization.JsonPropertyName("article_id")] + public string ArticleId { get; set; } = default!; + + /// + /// 获取或设置草稿内容。 + /// + [Newtonsoft.Json.JsonProperty("content")] + [System.Text.Json.Serialization.JsonPropertyName("content")] + public Types.Content? Content { get; set; } + + /// + /// 获取或设置更新时间戳。 + /// + [Newtonsoft.Json.JsonProperty("update_time")] + [System.Text.Json.Serialization.JsonPropertyName("update_time")] + public long UpdateTimestamp { get; set; } + } + } + + /// + /// 获取或设置图文消息列表。 + /// + [Newtonsoft.Json.JsonProperty("item")] + [System.Text.Json.Serialization.JsonPropertyName("item")] + public Types.Item[] List { get; set; } = default!; + + /// + /// 获取或设置本次数量。 + /// + [Newtonsoft.Json.JsonProperty("item_count")] + [System.Text.Json.Serialization.JsonPropertyName("item_count")] + public int Count { get; set; } = default!; + + /// + /// 获取或设置草稿总数。 + /// + [Newtonsoft.Json.JsonProperty("total_count")] + [System.Text.Json.Serialization.JsonPropertyName("total_count")] + public int TotalCount { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishDeleteRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishDeleteRequest.cs new file mode 100644 index 00000000..e16f0ce4 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishDeleteRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/delete 接口的请求。 + /// + public class CgibinFreePublishDeleteRequest : WechatApiRequest + { + /// + /// 获取或设置图文消息的 ArticleId。 + /// + [Newtonsoft.Json.JsonProperty("article_id")] + [System.Text.Json.Serialization.JsonPropertyName("article_id")] + public string ArticleId { get; set; } = string.Empty; + + /// + /// 获取或设置要删除的文章在图文消息中的索引。 + /// + [Newtonsoft.Json.JsonProperty("index")] + [System.Text.Json.Serialization.JsonPropertyName("index")] + public int? Index { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishDeleteResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishDeleteResponse.cs new file mode 100644 index 00000000..8d2350dd --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishDeleteResponse.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/delete 接口的响应。 + /// + public class CgibinFreePublishDeleteResponse : WechatApiResponse + { + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetArticleRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetArticleRequest.cs new file mode 100644 index 00000000..f703b4f9 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetArticleRequest.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/getarticle 接口的请求。 + /// + public class CgibinFreePublishGetArticleRequest : WechatApiRequest + { + /// + /// 获取或设置图文消息的 ArticleId。 + /// + [Newtonsoft.Json.JsonProperty("article_id")] + [System.Text.Json.Serialization.JsonPropertyName("article_id")] + public string ArticleId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetArticleResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetArticleResponse.cs new file mode 100644 index 00000000..6d7ab784 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetArticleResponse.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/getarticle 接口的响应。 + /// + public class CgibinFreePublishGetArticleResponse : WechatApiResponse + { + public static class Types + { + public class Article : CgibinDraftGetResponse.Types.Article + { + /// + /// 获取或设置是否已删除。 + /// + [Newtonsoft.Json.JsonProperty("is_deleted")] + [System.Text.Json.Serialization.JsonPropertyName("is_deleted")] + public bool IsDeleted { get; set; } + } + } + + /// + /// 获取或设置图文消息列表。 + /// + [Newtonsoft.Json.JsonProperty("news_item")] + [System.Text.Json.Serialization.JsonPropertyName("news_item")] + public Types.Article[] ArticleList { get; set; } = default!; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetRequest.cs new file mode 100644 index 00000000..fc19f7b5 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetRequest.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/get 接口的请求。 + /// + public class CgibinFreePublishGetRequest : WechatApiRequest + { + /// + /// 获取或设置发布任务 ID。 + /// + [Newtonsoft.Json.JsonProperty("publish_id")] + [System.Text.Json.Serialization.JsonPropertyName("publish_id")] + public string PublishId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetResponse.cs new file mode 100644 index 00000000..63e11faa --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishGetResponse.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/get 接口的响应。 + /// + public class CgibinFreePublishGetResponse : WechatApiResponse + { + public static class Types + { + public class ArticleDetail + { + public static class Types + { + public class Item + { + /// + /// 获取或设置文章索引。 + /// + [Newtonsoft.Json.JsonProperty("idx")] + [System.Text.Json.Serialization.JsonPropertyName("idx")] + public int Index { get; set; } + + /// + /// 获取或设置文章 URL。 + /// + [Newtonsoft.Json.JsonProperty("article_url")] + [System.Text.Json.Serialization.JsonPropertyName("article_url")] + public string ArticleUrl { get; set; } = default!; + } + } + + /// + /// 获取或设置文章数量。 + /// + [Newtonsoft.Json.JsonProperty("count")] + [System.Text.Json.Serialization.JsonPropertyName("count")] + public int Count { get; set; } + + /// + /// 获取或设置文章列表。 + /// + [Newtonsoft.Json.JsonProperty("item")] + [System.Text.Json.Serialization.JsonPropertyName("item")] + public Types.Item[] List { get; set; } = default!; + } + } + + /// + /// 获取或设置发布任务 ID。 + /// + [Newtonsoft.Json.JsonProperty("publish_id")] + [System.Text.Json.Serialization.JsonPropertyName("publish_id")] + public string PublishId { get; set; } = default!; + + /// + /// 获取或设置发布状态。 + /// + [Newtonsoft.Json.JsonProperty("publish_status")] + [System.Text.Json.Serialization.JsonPropertyName("publish_status")] + public int PublishStatus { get; set; } + + /// + /// 获取或设置图文消息的 ArticleId。 + /// + [Newtonsoft.Json.JsonProperty("article_id")] + [System.Text.Json.Serialization.JsonPropertyName("article_id")] + public string? ArticleId { get; set; } + + /// + /// 获取或设置图文消息的详细信息。 + /// + [Newtonsoft.Json.JsonProperty("article_detail")] + [System.Text.Json.Serialization.JsonPropertyName("article_detail")] + public Types.ArticleDetail? ArticleDetail { get; set; } + + /// + /// 获取或设置不通过的文章索引列表。 + /// + [Newtonsoft.Json.JsonProperty("fail_idx")] + [System.Text.Json.Serialization.JsonPropertyName("fail_idx")] + public int[]? FailedIndexList { get; set; } + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishSubmitRequest.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishSubmitRequest.cs new file mode 100644 index 00000000..1dc1c3b5 --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishSubmitRequest.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/submit 接口的请求。 + /// + public class CgibinFreePublishSubmitRequest : WechatApiRequest + { + /// + /// 获取或设置草稿的 MediaId。 + /// + [Newtonsoft.Json.JsonProperty("media_id")] + [System.Text.Json.Serialization.JsonPropertyName("media_id")] + public string MediaId { get; set; } = string.Empty; + } +} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishSubmitResponse.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishSubmitResponse.cs new file mode 100644 index 00000000..d0034a7b --- /dev/null +++ b/src/SKIT.FlurlHttpClient.Wechat.Api/Models/CgibinFreePublish/CgibinFreePublishSubmitResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace SKIT.FlurlHttpClient.Wechat.Api.Models +{ + /// + /// 表示 [POST] /cgi-bin/freepublish/submit 接口的响应。 + /// + public class CgibinFreePublishSubmitResponse : WechatApiResponse + { + /// + /// 获取或设置发布任务 ID。 + /// + [Newtonsoft.Json.JsonProperty("publish_id")] + [System.Text.Json.Serialization.JsonPropertyName("publish_id")] + public string PublishId { get; set; } = default!; + } +} diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/EventSamples/MpJob/FreePublishJobFinishEvent.xml b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/EventSamples/MpJob/FreePublishJobFinishEvent.xml new file mode 100644 index 00000000..fec8690e --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/EventSamples/MpJob/FreePublishJobFinishEvent.xml @@ -0,0 +1,23 @@ + + + + 1481013459 + + + + 2247503051 + 0 + + + + + 1 + + 1 + + + + 1 + 2 + + \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishBatchGetRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishBatchGetRequest.json new file mode 100644 index 00000000..31c031bb --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishBatchGetRequest.json @@ -0,0 +1,5 @@ +{ + "offset": 0, + "count": 0, + "no_content": 0 +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishBatchGetResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishBatchGetResponse.json new file mode 100644 index 00000000..2bdd821a --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishBatchGetResponse.json @@ -0,0 +1,27 @@ +{ + "total_count": 0, + "item_count": 0, + "item": [ + { + "article_id": "ARTICLE_ID", + "content": { + "news_item": [ + { + "title": "TITLE", + "author": "AUTHOR", + "digest": "DIGEST", + "content": "CONTENT", + "content_source_url": "CONTENT_SOURCE_URL", + "thumb_media_id": "THUMB_MEDIA_ID", + "show_cover_pic": 1, + "need_open_comment": 0, + "only_fans_can_comment": 0, + "url": "URL", + "is_deleted": false + } + ] + }, + "update_time": 0 + } + ] +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishDeleteRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishDeleteRequest.json new file mode 100644 index 00000000..2b3a2a36 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishDeleteRequest.json @@ -0,0 +1,4 @@ +{ + "article_id": "ARTICLE_ID", + "index": 1 +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishDeleteResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishDeleteResponse.json new file mode 100644 index 00000000..d59db342 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishDeleteResponse.json @@ -0,0 +1,4 @@ +{ + "errcode": 0, + "errmsg": "ERRMSG" +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetArticleRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetArticleRequest.json new file mode 100644 index 00000000..c983d0de --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetArticleRequest.json @@ -0,0 +1,3 @@ +{ + "article_id": "ARTICLE_ID" +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetArticleResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetArticleResponse.json new file mode 100644 index 00000000..5fbe0b2f --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetArticleResponse.json @@ -0,0 +1,17 @@ +{ + "news_item": [ + { + "title": "TITLE", + "author": "AUTHOR", + "digest": "DIGEST", + "content": "CONTENT", + "content_source_url": "CONTENT_SOURCE_URL", + "thumb_media_id": "THUMB_MEDIA_ID", + "show_cover_pic": 1, + "need_open_comment": 0, + "only_fans_can_comment": 0, + "url": "URL", + "is_deleted": false + } + ] +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetRequest.json new file mode 100644 index 00000000..f7602de7 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetRequest.json @@ -0,0 +1,3 @@ +{ + "publish_id": "100000001" +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetResponse.json new file mode 100644 index 00000000..7c4b70cc --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishGetResponse.json @@ -0,0 +1,15 @@ +{ + "publish_id": "100000001", + "publish_status": 0, + "article_id": "ARTICLE_ID", + "article_detail": { + "count": 1, + "item": [ + { + "idx": 1, + "article_url": "ARTICLE_URL" + } + ] + }, + "fail_idx": [] +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishSubmitRequest.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishSubmitRequest.json new file mode 100644 index 00000000..eac4910f --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishSubmitRequest.json @@ -0,0 +1,3 @@ +{ + "media_id": "MEDIA_ID" +} \ No newline at end of file diff --git a/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishSubmitResponse.json b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishSubmitResponse.json new file mode 100644 index 00000000..e7aa2b87 --- /dev/null +++ b/test/SKIT.FlurlHttpClient.Wechat.Api.UnitTests/ModelSamples/CgibinFreePublish/CgibinFreePublishSubmitResponse.json @@ -0,0 +1,5 @@ +{ + "errcode": 0, + "errmsg": "ok", + "publish_id": "100000001" +} \ No newline at end of file