diff --git a/.gitignore b/.gitignore index 16c63edc7d..2e788d8be6 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ bak.zip *.pdb *.tmp +# JetBrains Rider +.idea/ + #/Tools/* *.DotSettings .vs diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/CustomerTag/CorpTagJson.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/CustomerTag/CorpTagJson.cs new file mode 100644 index 0000000000..142cf515b7 --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/CustomerTag/CorpTagJson.cs @@ -0,0 +1,65 @@ +using System.Collections.Generic; +using Senparc.Weixin.Entities; + +namespace Senparc.Weixin.Work.AdvancedAPIs.CustomerTag +{ + public class GetCorpTagListResult : WorkJsonResult + { + public List tag_group { get; set; } + } + + public class AddCorpCustomerTagResult : WorkJsonResult + { + public CorpTagGroup tag_group { get; set; } + } + + public class EditCorpCustomerTagRequest + { + /// + /// 标签或标签组的id + /// + public string id { get; set; } + /// + /// 新的标签或标签组名称,最长为30个字符 + /// + public string name { get; set; } + /// + /// 标签/标签组的次序值 + /// order值大的排序靠前。有效的值范围是[0, 2^32) + /// + public int order { get; set; } + } + + public class DeleteCorpCustomerTagRequest + { + public List tag_id { get; set; } + public List group_id { get; set; } + } + + public class ExternalContactMarkTagRequest + { + public string userid { get; set; } + public string external_userid { get; set; } + public List add_tag { get; set; } + public List remove_tag { get; set; } + } + + public class CorpTagGroup + { + public string group_id { get; set; } + public string group_name { get; set; } + public long create_time { get; set; } + public long order { get; set; } + public bool deleted { get; set; } + public List tag { get; set; } + } + + public class CorpTag + { + public string id { get; set; } + public string name { get; set; } + public long create_time { get; set; } + public long order { get; set; } + public bool deleted { get; set; } + } +} \ No newline at end of file diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/CustomerTag/CustomerTagApi.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/CustomerTag/CustomerTagApi.cs new file mode 100644 index 0000000000..cb64350a21 --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/CustomerTag/CustomerTagApi.cs @@ -0,0 +1,199 @@ +using System.Threading.Tasks; +using Senparc.CO2NET.Extensions; +using Senparc.NeuChar; +using Senparc.Weixin.Entities; + +namespace Senparc.Weixin.Work.AdvancedAPIs.CustomerTag +{ + /// + /// 客户标签管理Api + /// + public class CustomerTagApi + { + + #region 同步方法 + + /// + /// 获取企业标签库 + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.GetCustomerTagList", true)] + public static GetCorpTagListResult GetCustomerTagList(string accessTokenOrAppKey, int timeOut = Config.TIME_OUT) + { + return ApiHandlerWapper.TryCommonApi(accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/get_corp_tag_list?access_token={0}", accessToken.AsUrlData()); + + return Senparc.Weixin.CommonAPIs.CommonJsonSend.Send(accessToken, url, null, CommonJsonSendType.POST, timeOut); + }, accessTokenOrAppKey); + } + + /// + /// 添加企业客户标签 + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.AddCorpCustomerTag", true)] + public static AddCorpCustomerTagResult AddCorpCustomerTag(string accessTokenOrAppKey, CorpTagGroup data, int timeOut = Config.TIME_OUT) + { + return ApiHandlerWapper.TryCommonApi(accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/add_corp_tag?access_token={0}", accessToken.AsUrlData()); + + return Senparc.Weixin.CommonAPIs.CommonJsonSend.Send(accessToken, url, data, timeOut: timeOut); + }, accessTokenOrAppKey); + } + + /// + /// 编辑企业客户标签 + /// + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.EditCorpCustomerTag", true)] + public static WorkJsonResult EditCorpCustomerTag(string accessTokenOrAppKey, EditCorpCustomerTagRequest data, int timeOut = Config.TIME_OUT) + { + return ApiHandlerWapper.TryCommonApi(accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/edit_corp_tag?access_token={0}", accessToken.AsUrlData()); + + return Senparc.Weixin.CommonAPIs.CommonJsonSend.Send(accessToken, url, data, timeOut: timeOut); + }, accessTokenOrAppKey); + } + + /// + /// 删除企业客户标签 + /// + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.DeleteCorpCustomerTag", true)] + public static WorkJsonResult DeleteCorpCustomerTag(string accessTokenOrAppKey, DeleteCorpCustomerTagRequest data, int timeOut = Config.TIME_OUT) + { + return ApiHandlerWapper.TryCommonApi(accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/del_corp_tag?access_token={0}", accessToken.AsUrlData()); + + return Senparc.Weixin.CommonAPIs.CommonJsonSend.Send(accessToken, url, data, timeOut: timeOut); + }, accessTokenOrAppKey); + } + + /// + /// 编辑客户企业标签标签 + /// + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.ExternalContactMarkTag", true)] + public static WorkJsonResult ExternalContactMarkTag(string accessTokenOrAppKey, ExternalContactMarkTagRequest data, int timeOut = Config.TIME_OUT) + { + return ApiHandlerWapper.TryCommonApi(accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/mark_tag?access_token={0}", accessToken.AsUrlData()); + + return Senparc.Weixin.CommonAPIs.CommonJsonSend.Send(accessToken, url, data, timeOut: timeOut); + }, accessTokenOrAppKey); + } + + #endregion + + #region 异步方法 + + /// + /// 获取企业标签库 + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.GetCustomerTagListAsync", true)] + public static async Task GetCustomerTagListAsync(string accessTokenOrAppkey, int timeOut = Config.TIME_OUT) + { + return await ApiHandlerWapper.TryCommonApiAsync(async accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/get_corp_tag_list?access_token={0}", accessToken.AsUrlData()); + + return await Weixin.CommonAPIs.CommonJsonSend.SendAsync(accessToken, url, null, CommonJsonSendType.POST, timeOut).ConfigureAwait(false); + }, accessTokenOrAppkey).ConfigureAwait(false); + } + + /// + /// 添加企业客户标签 + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.AddCorpCustomerTagAsync", true)] + public static async Task AddCorpCustomerTagAsync(string accessTokenOrAppKey, CorpTagGroup data, int timeOut = Config.TIME_OUT) + { + return await ApiHandlerWapper.TryCommonApiAsync(async accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/add_corp_tag?access_token={0}", accessToken.AsUrlData()); + + return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync(accessToken, url, data, timeOut: timeOut).ConfigureAwait(false); + }, accessTokenOrAppKey).ConfigureAwait(false); + } + + /// + /// 编辑企业客户标签 + /// + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.EditCorpCustomerTagAsync", true)] + public static async Task EditCorpCustomerTagAsync(string accessTokenOrAppKey, EditCorpCustomerTagRequest data, int timeOut = Config.TIME_OUT) + { + return await ApiHandlerWapper.TryCommonApiAsync(async accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/edit_corp_tag?access_token={0}", accessToken.AsUrlData()); + + return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync(accessToken, url, data, timeOut: timeOut).ConfigureAwait(false); + }, accessTokenOrAppKey).ConfigureAwait(false); + } + + /// + /// 删除企业客户标签 + /// + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.DeleteCorpCustomerTagAsync", true)] + public static async Task DeleteCorpCustomerTagAsync(string accessTokenOrAppKey, DeleteCorpCustomerTagRequest data, int timeOut = Config.TIME_OUT) + { + return await ApiHandlerWapper.TryCommonApiAsync(async accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/del_corp_tag?access_token={0}", accessToken.AsUrlData()); + + return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync(accessToken, url, data, timeOut: timeOut).ConfigureAwait(false); + }, accessTokenOrAppKey).ConfigureAwait(false); + } + + /// + /// 编辑客户企业标签标签 + /// + /// + /// + /// + /// + [ApiBind(NeuChar.PlatformType.WeChat_Work, "CustomerTagApi.ExternalContactMarkTagAsync", true)] + public static async Task ExternalContactMarkTagAsync(string accessTokenOrAppKey, ExternalContactMarkTagRequest data, int timeOut = Config.TIME_OUT) + { + return await ApiHandlerWapper.TryCommonApiAsync(async accessToken => + { + var url = string.Format(Config.ApiWorkHost + "/cgi-bin/externalcontact/mark_tag?access_token={0}", accessToken.AsUrlData()); + + return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync(accessToken, url, data, timeOut: timeOut).ConfigureAwait(false); + }, accessTokenOrAppKey).ConfigureAwait(false); + } + + #endregion + + } +} \ No newline at end of file diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/AddMsgTemplateRequest.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/AddMsgTemplateRequest.cs new file mode 100644 index 0000000000..4e1de236af --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/AddMsgTemplateRequest.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using Senparc.Weixin.Work.Entities.Models; + +namespace Senparc.Weixin.Work.AdvancedAPIs.External.ExternalJson +{ + /// + /// 添加企业群发消息任务参数实体 + /// + public class AddMsgTemplateRequest + { + /// + /// 群发任务的类型,默认为single,表示发送给客户,group表示发送给客户群 + /// + public string chat_type { get; set; } = "single"; + /// + /// 客户的外部联系人id列表,仅在chat_type为single时有效,不可与sender同时为空,最多可传入1万个客户 + /// + public List external_userid { get; set; } + /// + /// 发送企业群发消息的成员userid,当类型为发送给客户群时必填 + /// + public string sender { get; set; } + /// + /// 文本消息 + /// + public MessageText text { get; set; } + /// + /// 图片消息 + /// + public MessageImage image { get; set; } + /// + /// 图文消息 + /// + public MessageLink link { get; set; } + /// + /// 小程序消息 + /// + public MessageMiniprogram miniprogram { get; set; } + } +} \ No newline at end of file diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/AddMsgTemplateResult.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/AddMsgTemplateResult.cs new file mode 100644 index 0000000000..b108e26a68 --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/AddMsgTemplateResult.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using Senparc.Weixin.Entities; + +namespace Senparc.Weixin.Work.AdvancedAPIs.External.ExternalJson +{ + /// + /// + /// + public class AddMsgTemplateResult : WorkJsonResult + { + public List fail_list { get; set; } + public string msgid { get; set; } + } +} \ No newline at end of file diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/ExternalContactResult.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/ExternalContactResult.cs new file mode 100644 index 0000000000..c57762017d --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/ExternalContactResult.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Senparc.Weixin.Entities; + +namespace Senparc.Weixin.Work.AdvancedAPIs.External.ExternalJson +{ + public class GetExternalContactInfoResult : WorkJsonResult + { + public ExternalContactInfo external_contact { get; set; } + public FollowUserInfo follow_user { get; set; } + } + + public class ExternalContactInfo + { + public string external_userid { get; set; } + public string name { get; set; } + public int type { get; set; } + public string avatar { get; set; } + public int gender { get; set; } + public string unionid { get; set; } + } + + public class FollowUserInfo + { + public string remark { get; set; } + public string description { get; set; } + public long creattime { get; set; } + public string[] tag_id { get; set; } + public string[] remark_mobiles { get; set; } + public int add_way { get; set; } + public string remark_corp_name { get; set; } + public string oper_userid { get; set; } + public string state { get; set; } + } +} diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/GroupMsgResult.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/GroupMsgResult.cs new file mode 100644 index 0000000000..232be9b96a --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/GroupMsgResult.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using Senparc.Weixin.Entities; + +namespace Senparc.Weixin.Work.AdvancedAPIs.External.ExternalJson +{ + /// + /// 获取企业群发消息发送结果返回参数 + /// + public class GroupMsgResult : WorkJsonResult + { + /// + /// 返回结果明细 + /// + public List detail_list { get; set; } + } + + public class GroupMsgResultDetail + { + /// + /// 外部联系人userid + /// + public string external_userid { get; set; } + /// + /// 外部客户群id + /// + public string chat_id { get; set; } + /// + /// 企业服务人员的userid + /// + public string userid { get; set; } + /// + /// 发送状态 0-未发送 1-已发送 2-因客户不是好友导致发送失败 3-因客户已经收到其他群发消息导致发送失败 + /// + public GroupTaskSentStatus status { get; set; } + /// + /// 发送时间,发送状态为1时返回 + /// + public long send_time { get; set; } + } +} \ No newline at end of file diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/SendWelcomeMessageRequest.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/SendWelcomeMessageRequest.cs new file mode 100644 index 0000000000..680a231a9e --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/ExternalJson/SendWelcomeMessageRequest.cs @@ -0,0 +1,13 @@ +using Senparc.Weixin.Work.Entities.Models; + +namespace Senparc.Weixin.Work.AdvancedAPIs.External.ExternalJson +{ + public class SendWelcomeMessageRequest + { + public string welcome_code { get; set; } + public MessageText text { get; set; } + public MessageImage image { get; set; } + public MessageLink link { get; set; } + public MessageMiniprogram miniprogram { get; set; } + } +} \ No newline at end of file diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/GetExternalContactResult.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/GetExternalContactResult.cs index d6af3643e7..2fc3232b96 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/GetExternalContactResult.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/External/GetExternalContactResult.cs @@ -15,6 +15,7 @@ ----------------------------------------------------------------*/ +using System.Collections.Generic; using Senparc.Weixin.Entities; namespace Senparc.Weixin.Work.AdvancedAPIs.External @@ -182,6 +183,14 @@ public class Follow_User public Follow_User_Tags[] tags { get; set; } } + + public class Follow_User_Tag + { + public string group_name { get; set; } + public string tag_name { get; set; } + public string tag_id { get; set; } + public int type { get; set; } + } public class Follow_User_Tags { diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Mass/MassResult.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Mass/MassResult.cs index e8ae590f17..2c5ca0c3ed 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Mass/MassResult.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Mass/MassResult.cs @@ -90,20 +90,48 @@ public class SendMiniProgramNoticeData public class SendTaskCardNoticeData { + /// + /// 成员ID列表(消息接收者,多个接收者用‘|’分隔,最多支持1000个) + /// 特殊情况:指定为@all,则向关注该企业应用的全部成员发送 + /// public string touser { get; set; } + /// + /// 部门ID列表,多个接收者用‘|’分隔,最多支持100个 + /// 当touser为@all时忽略本参数 + /// public string toparty { get; set; } + /// + /// 标签ID列表,多个接收者用‘|’分隔,最多支持100个 + /// 当touser为@all时忽略本参数 + /// public string totag { get; set; } - public string msgtype { get; set; } + /// + /// 消息类型,此时固定为:interactive_taskcard + /// + public string msgtype => "interactive_taskcard"; + /// + /// 企业应用的id,整型 + /// 企业内部开发,可在应用的设置页面查看; + /// 第三方服务商,可通过接口 获取企业授权信息 获取该参数值 + /// public int agentid { get; set; } + /// + /// 卡片内容 + /// + public Taskcard_Notice interactive_taskcard { get; set; } public Taskcard_Notice taskcard { get; set; } /// + /// 表示是否开启id转译,0表示否,1表示是,默认0 + /// + public int? enable_id_trans { get; set; } + /// /// 表示是否开启重复消息检查,0表示否,1表示是,默认0 /// - public int enableDuplicateCheck { get; set; } + public int? enable_duplicate_check { get; set; } /// /// 表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时 /// - public int duplicateCheckInterval { get; set; } = 1800; + public int? duplicate_check_interval { get; set; } = 1800; } /// @@ -115,6 +143,7 @@ public class UpdateTaskCardData public int agentid { get; set; } public string task_id { get; set; } public string clicked_key { get; set; } + public string replace_name { get; set; } } diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Schedule/ScheduleApi.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Schedule/ScheduleApi.cs index 21ca004fa0..c5be8a07af 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Schedule/ScheduleApi.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Schedule/ScheduleApi.cs @@ -34,17 +34,12 @@ public static class ScheduleApi /// 日程信息 /// /// - public static AddScheduleJsonResult Add(string accessTokenOrAppKey, ScheduleJson.Schedule schedule, int timeOut = Config.TIME_OUT) + public static AddScheduleJsonResult Add(string accessTokenOrAppKey, ScheduleJson.ScheduleAdd data, int timeOut = Config.TIME_OUT) { return ApiHandlerWapper.TryCommonApi(accessToken => { var url = Config.ApiWorkHost + "/cgi-bin/oa/schedule/add?access_token={0}"; - var data = new - { - schedule - }; - return Senparc.Weixin.CommonAPIs.CommonJsonSend.Send(accessToken, url, data, CommonJsonSendType.POST, timeOut); }, accessTokenOrAppKey); } @@ -121,17 +116,12 @@ public static GetScheduleJsonResult Get(string accessTokenOrAppKey, List /// 日程信息 /// /// - public static async Task AddAsync(string accessTokenOrAppKey, ScheduleJson.Schedule schedule, int timeOut = Config.TIME_OUT) + public static async Task AddAsync(string accessTokenOrAppKey, ScheduleJson.ScheduleAdd data, int timeOut = Config.TIME_OUT) { return await ApiHandlerWapper.TryCommonApiAsync(async accessToken => { var url = Config.ApiWorkHost + "/cgi-bin/oa/schedule/add?access_token={0}"; - var data = new - { - schedule - }; - return await Weixin.CommonAPIs.CommonJsonSend.SendAsync(accessToken, url, data, CommonJsonSendType.POST, timeOut).ConfigureAwait(false); }, accessTokenOrAppKey).ConfigureAwait(false); } diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Schedule/ScheduleJson/Schedule.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Schedule/ScheduleJson/Schedule.cs index ebfbbdb9d6..0f891f2fd3 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Schedule/ScheduleJson/Schedule.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/AdvancedAPIs/Schedule/ScheduleJson/Schedule.cs @@ -33,6 +33,16 @@ public enum Repeat_Type 每年 = 5, 工作日 = 7 } + public enum RepeatDayOfWeek + { + Monday = 1, + Tuesday = 2, + Wednesday = 3, + Thursday = 4, + Friday = 5, + Saturday = 6, + Sunday = 7 + } /// /// 日程信息 /// @@ -70,6 +80,11 @@ public class Schedule /// 日程地址。0 ~ 128 字符 /// public string location { get; set; } + /// + /// 日程所属日历ID + /// 第三方应用必须指定cal_id + /// + public string cal_id { get; set; } } public class Reminders @@ -90,6 +105,42 @@ public class Reminders /// 重复类型,当is_repeat为1时有效。 /// public Repeat_Type repeat_type { get; set; } + /// + /// 重复结束时刻,Unix时间戳。不填或填0表示一直重复 + /// + public int repeat_unit { get; set; } + /// + /// 是否自定义重复。0-否;1-是 + /// + public ushort is_custom_repeat { get; set; } + /// + /// 重复间隔 + /// 仅当指定为自定义重复时有效 + /// 该字段随repeat_type不同而含义不同 + /// 例如: + /// repeat_interval指定为3,repeat_type指定为每周重复,那么每3周重复一次; + /// repeat_interval指定为3,repeat_type指定为每月重复,那么每3个月重复一次 + /// + public int repeat_interval { get; set; } + /// + /// 每周周几重复 + /// 仅当指定为自定义重复且重复类型为每周时有效 + /// 取值范围:1 ~ 7,分别表示周一至周日 + /// + public RepeatDayOfWeek[] repeat_day_of_week { get; set; } + /// + /// 每月哪几天重复 + /// 仅当指定为自定义重复且重复类型为每月时有效 + /// 取值范围:1 ~ 31,分别表示1~31号 + /// + public int[] repeat_day_of_month { get; set; } + /// + /// 时区。UTC偏移量表示(即偏离零时区的小时数),东区为正数,西区为负数。 + /// 例如:+8 表示北京时间东八区 + /// 默认为北京时间东八区 + /// 取值范围:-12 ~ +12 + /// + public int timezone { get; set; } = 8; } public class Attendee @@ -99,6 +150,17 @@ public class Attendee /// public string userid { get; set; } } + public class ScheduleAdd + { + /// + /// 日程信息 + /// + public Schedule schedule { get; set; } + /// + /// 授权方安装的应用agentid + /// + public int agentid { get; set; } + } /// /// 注意,更新日程,不可变更组织者 /// diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/JsonResult/ExternalProfile.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/JsonResult/ExternalProfile.cs new file mode 100644 index 0000000000..7df783782e --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/JsonResult/ExternalProfile.cs @@ -0,0 +1,77 @@ +namespace Senparc.Weixin.Work.Entities.JsonResult +{ + public class ExternalProfile + { + public string external_corp_name { get; set; } + public ExternalAttribute external_attr { get; set; } + } + + public class ExternalAttribute + { + /// + /// 属性类型: 0-文本 1-网页 2-小程序 + /// + public ExternalAttributeType type { get; set; } + /// + /// 属性名称 + /// + public string name { get; set; } + /// + /// 文本类型的属性 + /// + public ExternalAttrText text { get; set; } + /// + /// 网页类型的属性,url和title字段要么同时为空表示清除该属性,要么同时不为空 + /// + public ExternalAttrWeb web { get; set; } + /// + /// 小程序类型的属性,appid和title字段要么同时为空表示清除改属性,要么同时不为空 + /// + public ExternalAttrMiniprogram miniprogram { get; set; } + } + + /// + /// 文本类型的属性 + /// + public class ExternalAttrText + { + /// + /// 文本属性内容,长度限制12个UTF8字符 + /// + public string value { get; set; } + } + + /// + /// 网页类型的属性 + /// + public class ExternalAttrWeb + { + /// + /// 网页的url,必须包含http或者https头 + /// + public string url { get; set; } + /// + /// 网页的展示标题,长度限制12个UTF8字符 + /// + public string title { get; set; } + } + + /// + /// 小程序类型的属性 + /// + public class ExternalAttrMiniprogram + { + /// + /// 小程序appid,必须是有在本企业安装授权的小程序,否则会被忽略 + /// + public string appid { get; set; } + /// + /// 小程序的页面路径 + /// + public string pagepath { get; set; } + /// + /// 小程序的展示标题,长度限制12个UTF8字符 + /// + public string title { get; set; } + } +} \ No newline at end of file diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/Models/MessageContentModels.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/Models/MessageContentModels.cs new file mode 100644 index 0000000000..bcd6fc0c20 --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/Models/MessageContentModels.cs @@ -0,0 +1,74 @@ +namespace Senparc.Weixin.Work.Entities.Models +{ + /// + /// 文本消息 + /// + public class MessageText + { + /// + /// 文本消息内容,最长为4000字节 + /// + public string content { get; set; } + } + + /// + /// 图片消息 + /// + public class MessageImage + { + /// + /// 图片的media_id,可以通过素材管理接口获得 + /// + public string media_id { get; set; } + /// + /// 图片的链接,仅可使用上传图片接口得到的链接 + /// + public string pic_url { get; set; } + } + + /// + /// 图文消息 + /// + public class MessageLink + { + /// + /// 图文消息标题,最长为128字节 + /// + public string title { get; set; } + /// + /// 图文消息封面的url + /// + public string picurl { get; set; } + /// + /// 图文消息的描述,最长为512字节 + /// + public string desc { get; set; } + /// + /// 图文消息的链接 + /// + public string url { get; set; } + } + + /// + /// 小程序消息 + /// + public class MessageMiniprogram + { + /// + /// 小程序消息标题,最长为64字节 + /// + public string title { get; set; } + /// + /// 小程序消息封面的mediaid,封面图建议尺寸为520*416 + /// + public string pic_media_id { get; set; } + /// + /// 小程序appid,必须是关联到企业的小程序应用 + /// + public string appid { get; set; } + /// + /// 小程序page路径 + /// + public string page { get; set; } + } +} diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/MsgTypeHelper.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/MsgTypeHelper.cs index 46361f8b0e..450af8bb18 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/MsgTypeHelper.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/MsgTypeHelper.cs @@ -33,6 +33,7 @@ and limitations under the License. using System; using System.Xml.Linq; +using Senparc.Weixin.Work.Entities.Request.Event; namespace Senparc.Weixin.Work.Helpers { @@ -59,6 +60,27 @@ public static ThirdPartyInfo GetThirdPartyInfo(string str) } #endregion + + #region ExternalContactChangeType + + /// + /// 根据xml信息,返回ExternalContactChangeType + /// + /// + public static ExternalContactChangeType GetExternalContactChangeType(XDocument doc) + { + return GetExternalContactChangeType(doc.Root.Element("ChangeType").Value); + } + /// + /// 根据xml信息,返回ExternalContactChangeType + /// + /// + public static ExternalContactChangeType GetExternalContactChangeType(string str) + { + return (ExternalContactChangeType)Enum.Parse(typeof(ExternalContactChangeType), str, true); + } + + #endregion } } diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/Request/Event/RequestMessageEvent_TaskCardClick.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/Request/Event/RequestMessageEvent_TaskCardClick.cs new file mode 100644 index 0000000000..1b76ac9c04 --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/Request/Event/RequestMessageEvent_TaskCardClick.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Senparc.Weixin.Work.Entities +{ + public class RequestMessageEvent_TaskCardClick : RequestMessageEventBase, IRequestMessageEventBase, IRequestMessageEventKey + { + /// + /// 事件类型 + /// + public override Event Event + { + get { return Event.TASKCARD_CLICK; } + } + + /// + /// 事件KEY值,与自定义菜单接口中KEY值对应 + /// + public string EventKey { get; set; } + } +} diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/Response/ResponseMessageUpdateTaskCard.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/Response/ResponseMessageUpdateTaskCard.cs new file mode 100644 index 0000000000..419af411a4 --- /dev/null +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Entities/Response/ResponseMessageUpdateTaskCard.cs @@ -0,0 +1,25 @@ +using Senparc.NeuChar; +using Senparc.NeuChar.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Senparc.Weixin.Work.Entities.Response +{ + public class ResponseMessageUpdateTaskCard : WorkResponseMessageBase, IResponseMessageTaskCard + { + public new virtual ResponseMsgType MsgType + { + get { return ResponseMsgType.TaskCard; } + } + + public TaskCard TaskCard { get; set; } + + public ResponseMessageUpdateTaskCard() + { + TaskCard = new TaskCard(); + } + } +} diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Enums.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Enums.cs index 98164de582..9d056fd062 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Enums.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Enums.cs @@ -93,7 +93,10 @@ public enum Event /// 自定义菜单点击事件 /// CLICK, - + /// + /// 任务卡片事件推送 + /// + TASKCARD_CLICK, /// /// 二维码扫描 /// @@ -182,6 +185,22 @@ public enum Event OPEN_APPROVAL_CHANGE #endregion } + + public enum TencentGender + { + /// + /// 未知 + /// + Unknown = 0, + /// + /// 男 + /// + Male = 1, + /// + /// 女 + /// + Female = 2 + } public enum ThirdPartyInfo { @@ -229,6 +248,40 @@ public enum ThirdPartyInfo /// RESET_PERMANENT_CODE } + + public enum ExternalAttributeType + { + Text, + Web, + Miniprogram + } + + public enum GroupChatJoinScene + { + /// + /// 由成员邀请入群(直接邀请入群) + /// + INVITE_BY_DIRECT = 1, + /// + /// 由成员邀请入群(通过邀请链接入群) + /// + INVITE_BY_LINK = 2, + /// + /// 通过扫描群二维码入群 + /// + QR_CODE = 3 + } + + /// + /// 群发任务发送状态 + /// + public enum GroupTaskSentStatus + { + 未发送, + 已发送, + 因客户不是好友导致发送失败, + 因客户已经收到其他群发消息导致发送失败, + } /////