代码修改后的版本,全部提交

This commit is contained in:
ss001
2026-02-07 15:48:27 +08:00
parent cccbaa37c9
commit c2cda58c65
15604 changed files with 2455502 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Jiguang.JPush.Model
{
/// <summary>
/// 推送目标。
/// <see cref="https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#audience"/>
/// </summary>
public class Audience
{
/// <summary>
/// 多个标签之间取并集OR
/// 每次最多推送 20 个。
/// </summary>
[JsonProperty("tag", NullValueHandling = NullValueHandling.Ignore)]
public List<string> Tag { get; set; }
/// <summary>
/// 多个标签之间取交集AND
/// 每次最多推送 20 个。
/// </summary>
[JsonProperty("tag_and", NullValueHandling = NullValueHandling.Ignore)]
public List<string> TagAnd { get; set; }
/// <summary>
/// 多个标签之间,先取并集,再对结果取补集。
/// 每次最多推送 20 个。
/// </summary>
[JsonProperty("tag_not", NullValueHandling = NullValueHandling.Ignore)]
public List<string> TagNot { get; set; }
/// <summary>
/// 多个别名之间取并集OR
/// 每次最多同时推送 1000 个。
/// </summary>
[JsonProperty("alias", NullValueHandling = NullValueHandling.Ignore)]
public List<string> Alias { get; set; }
/// <summary>
/// 多个 registration id 之间取并集OR
/// 每次最多同时推送 1000 个。
/// </summary>
[JsonProperty("registration_id", NullValueHandling = NullValueHandling.Ignore)]
public List<string> RegistrationId { get; set; }
/// <summary>
/// 在页面创建的用户分群 ID。
/// 目前一次只能推送一个。
/// </summary>
[JsonProperty("segment", NullValueHandling = NullValueHandling.Ignore)]
public List<string> Segment { get; set; }
/// <summary>
/// 在页面创建的 A/B 测试 ID。
/// 目前一次只能推送一个。
/// </summary>
[JsonProperty("abtest", NullValueHandling = NullValueHandling.Ignore)]
public List<string> Abtest { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Jiguang.JPush.Model
{
public class BatchPushPayload
{
[JsonProperty("pushlist")]
public Dictionary<string, SinglePayload> Pushlist { get; set; }
internal string GetJson()
{
return JsonConvert.SerializeObject(this, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
});
}
public override string ToString()
{
return GetJson();
}
}
}

View File

@@ -0,0 +1,31 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Jiguang.JPush.Model
{
public class DevicePayload
{
[JsonProperty("alias")]
public string Alias { get; set; }
[JsonProperty("mobile")]
public string Mobile { get; set; }
[JsonProperty("tags")]
public Dictionary<string, object> Tags { get; set;}
private string GetJson()
{
return JsonConvert.SerializeObject(this, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
});
}
public override string ToString()
{
return GetJson();
}
}
}

View File

@@ -0,0 +1,19 @@
using System.Net;
using System.Net.Http.Headers;
namespace Jiguang.JPush.Model
{
public class HttpResponse
{
public HttpStatusCode StatusCode { get; set; }
public HttpResponseHeaders Headers { get; set; }
public string Content { get; set; }
public HttpResponse(HttpStatusCode statusCode, HttpResponseHeaders headers, string content)
{
StatusCode = statusCode;
Headers = headers;
Content = content;
}
}
}

View File

@@ -0,0 +1,27 @@
using Newtonsoft.Json;
using System.Collections;
namespace Jiguang.JPush.Model
{
/// <summary>
/// 自定义消息。
/// <see cref="https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#message"/>
/// </summary>
public class Message
{
/// <summary>
/// 消息内容本身(必填)。
/// </summary>
[JsonProperty("msg_content")]
public string Content { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("content_type")]
public string ContentType { get; set; }
[JsonProperty("extras")]
public IDictionary Extras { get; set; }
}
}

View File

@@ -0,0 +1,120 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Jiguang.JPush.Model
{
/// <summary>
/// <see cref="https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#notification"/>
/// </summary>
public class Notification
{
[JsonProperty("alert")]
public string Alert { get; set; }
[JsonProperty("android", NullValueHandling = NullValueHandling.Ignore)]
public Android Android { get; set; }
[JsonProperty("ios", NullValueHandling = NullValueHandling.Ignore)]
public IOS IOS { get; set; }
}
public class Android
{
/// <summary>
/// 必填。
/// </summary>
[JsonProperty("alert")]
public string Alert { get; set; }
[JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
public string Title { get; set; }
[JsonProperty("builder_id", NullValueHandling = NullValueHandling.Ignore)]
public int? BuilderId { get; set; }
[JsonProperty("channel_id", NullValueHandling = NullValueHandling.Ignore)]
public string ChannelId { get; set; }
[JsonProperty("priority", NullValueHandling = NullValueHandling.Ignore)]
public int? Priority { get; set; }
[JsonProperty("category", NullValueHandling = NullValueHandling.Ignore)]
public string Category { get; set; }
[JsonProperty("style", NullValueHandling = NullValueHandling.Ignore)]
public int? Style { get; set; }
[JsonProperty("alert_type", NullValueHandling = NullValueHandling.Ignore)]
public int? AlertType { get; set; }
[JsonProperty("big_text", NullValueHandling = NullValueHandling.Ignore)]
public string BigText { get; set; }
[JsonProperty("inbox", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, object> Inbox { get; set; }
[JsonProperty("big_pic_path", NullValueHandling = NullValueHandling.Ignore)]
public string BigPicturePath { get; set; }
[JsonProperty("large_icon", NullValueHandling = NullValueHandling.Ignore)]
public string LargeIcon { get; set; }
[JsonProperty("intent", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, object> Indent { get; set; }
[JsonProperty("extras", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, object> Extras { get; set; }
/// <summary>
/// (VIP only)指定开发者想要打开的 Activity值为 <activity> 节点的 "android:name" 属性值。
/// </summary>
[JsonProperty("uri_activity", NullValueHandling = NullValueHandling.Ignore)]
public string URIActivity { get; set; }
/// <summary>
/// (VIP only)指定打开 Activity 的方式,值为 Intent.java 中预定义的 "access flags" 的取值范围。
/// </summary>
[JsonProperty("uri_flag", NullValueHandling = NullValueHandling.Ignore)]
public string URIFlag { get; set; }
/// <summary>
/// (VIP only)指定开发者想要打开的 Activity值为 <activity> -> <intent-filter> -> <action> 节点中的 "android:name" 属性值。
/// </summary>
[JsonProperty("uri_action", NullValueHandling = NullValueHandling.Ignore)]
public string URIAction { get; set; }
}
public class IOS
{
/// <summary>
/// 可以是 string也可以是 Apple 官方定义的 alert payload 结构。
/// <para><see ="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW5"/></para>
/// </summary>
[JsonProperty("alert")]
public object Alert { get; set; }
[JsonProperty("sound", NullValueHandling = NullValueHandling.Ignore)]
public string Sound { get; set; }
/// <summary>
/// 默认角标 +1。
/// </summary>
[JsonProperty("badge")]
public string Badge { get; set; } = "+1";
[JsonProperty("content-available", NullValueHandling = NullValueHandling.Ignore)]
public bool? ContentAvailable { get; set; }
[JsonProperty("mutable-content", NullValueHandling = NullValueHandling.Ignore)]
public bool? MutableContent { get; set; }
[JsonProperty("category", NullValueHandling = NullValueHandling.Ignore)]
public string Category { get; set; }
[JsonProperty("extras", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, object> Extras { get; set; }
[JsonProperty("thread-id", NullValueHandling = NullValueHandling.Ignore)]
public string ThreadId { get; set; }
}
}

View File

@@ -0,0 +1,127 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Reflection;
using System.Collections.Generic;
namespace Jiguang.JPush.Model
{
/// <summary>
/// <see cref="https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#options"/>
/// </summary>
public class Options
{
/// <summary>
/// 推送序号。
/// <para>用来作为 API 调用标识API 返回时被原样返回,以方便 API 调用方匹配请求与返回。不能为 0。</para>
/// </summary>
[JsonProperty("sendno", NullValueHandling = NullValueHandling.Ignore)]
public int? SendNo { get; set; }
/// <summary>
/// 离线消息保留时长(秒)。
/// <para>推送当前用户不在线时,为该用户保留多长时间的离线消息,以便其上线时再次推送。默认 86400 1 天),最长 10 天。设置为 0 表示不保留离线消息,只有推送当前在线的用户可以收到。</para>
/// </summary>
[JsonProperty("time_to_live", NullValueHandling = NullValueHandling.Ignore)]
public int? TimeToLive { get; set; }
/// <summary>
/// 要覆盖的消息 ID。
/// <para>如果当前的推送要覆盖之前的一条推送,这里填写前一条推送的 msg_id 就会产生覆盖效果。覆盖功能起作用的时限是1 天。</para>
/// </summary>
[JsonProperty("override_msg_id", NullValueHandling = NullValueHandling.Ignore)]
public long? OverrideMessageId { get; set; }
/// <summary>
/// iOS 推送是否为生产环境。默认为 false - 开发环境。
/// <para>true: 生产环境false: 开发环境。</para>
/// </summary>
[JsonProperty("apns_production", DefaultValueHandling = DefaultValueHandling.Include)]
public bool IsApnsProduction { get; set; } = false;
/// <summary>
/// 更新 iOS 通知的标识符。
/// <para>APNs 新通知如果匹配到当前通知中心有相同 apns-collapse-id 字段的通知则会用新通知内容来更新它并使其置于通知中心首位。collapse id 长度不可超过 64 bytes。</para>
/// </summary>
[JsonProperty("apns_collapse_id", NullValueHandling = NullValueHandling.Ignore)]
public string ApnsCollapseId { get; set; }
/// <summary>
/// 定速推送时长(分钟)。
/// 又名缓慢推送。把原本尽可能快的推送速度,降低下来,给定的 n 分钟内,均匀地向这次推送的目标用户推送。最大值为 1400未设置则不是定速推送。
/// </summary>
[JsonProperty("big_push_duration", NullValueHandling = NullValueHandling.Ignore)]
public int? BigPushDuration { get; set; }
/// <summary>
/// 自定义参数
/// </summary>
public Dictionary<string, object> Dict { get; set; }
public void Add(string key, object value) {
if (Dict == null) {
Dict = new Dictionary<string, object>();
}
Dict.Add(key, value);
}
}
public class OptionsJsonConvert : JsonConverter
{
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
throw new Exception("Unsupport ReadJson convert.");
}
public override bool CanConvert(Type objectType)
{
if (objectType.FullName == typeof(Options).FullName)
{
return true;
}
else {
return false;
}
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value == null)
{
writer.WriteNull();
return;
}
writer.WriteStartObject();
Options options = (Options) value;
if (options.SendNo != null) {
writer.WritePropertyName("sendno");
writer.WriteValue(options.SendNo);
}
if (options.TimeToLive != null) {
writer.WritePropertyName("time_to_live");
writer.WriteValue(options.TimeToLive);
}
if (options.OverrideMessageId != null) {
writer.WritePropertyName("override_msg_id");
writer.WriteValue(options.OverrideMessageId);
}
writer.WritePropertyName("apns_production");
writer.WriteValue(options.IsApnsProduction);
if (options.ApnsCollapseId != null) {
writer.WritePropertyName("apns_collapse_id");
writer.WriteValue(options.ApnsCollapseId);
}
if (options.BigPushDuration != null) {
writer.WritePropertyName("big_push_duration");
writer.WriteValue(options.BigPushDuration);
}
if (options.Dict != null) {
foreach (KeyValuePair<string, object> item in options.Dict)
{
writer.WritePropertyName(item.Key);
serializer.Serialize(writer, item.Value);
}
}
}
}
}

View File

@@ -0,0 +1,50 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Jiguang.JPush.Model
{
public class PushPayload
{
[JsonProperty("cid", NullValueHandling = NullValueHandling.Ignore)]
public string CId { get; set; }
/// <summary>
/// 推送平台。可以为 "android" / "ios" / "all"。
/// </summary>
[JsonProperty("platform", DefaultValueHandling = DefaultValueHandling.Include)]
public object Platform { get; set; } = "all";
[JsonProperty("audience", DefaultValueHandling = DefaultValueHandling.Include)]
public object Audience { get; set; } = "all";
[JsonProperty("notification", NullValueHandling = NullValueHandling.Ignore)]
public Notification Notification { get; set; }
[JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)]
public Message Message { get; set; }
[JsonProperty("sms_message", NullValueHandling = NullValueHandling.Ignore)]
public SmsMessage SMSMessage { get; set; }
[JsonProperty("options", DefaultValueHandling = DefaultValueHandling.Include)]
[JsonConverter(typeof(OptionsJsonConvert))]
public Options Options { get; set; } = new Options
{
IsApnsProduction = false
};
internal string GetJson()
{
return JsonConvert.SerializeObject(this, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
});
}
public override string ToString()
{
return GetJson();
}
}
}

View File

@@ -0,0 +1,50 @@
using Newtonsoft.Json;
namespace Jiguang.JPush.Model
{
public class SinglePayload
{
/// <summary>
/// 推送平台。可以为 "android" / "ios" / "all"。
/// </summary>
[JsonProperty("platform", DefaultValueHandling = DefaultValueHandling.Include)]
public object Platform { get; set; } = "all";
/// <summary>
/// 推送设备指定。
/// 如果是调用RegID方式批量单推接口/v3/push/batch/regid/single那此处就是指定regid值
/// 如果是调用Alias方式批量单推接口/v3/push/batch/alias/single那此处就是指定alias值。
/// </summary>
[JsonProperty("target", DefaultValueHandling = DefaultValueHandling.Include)]
public string Target { get; set; }
[JsonProperty("notification", NullValueHandling = NullValueHandling.Ignore)]
public Notification Notification { get; set; }
[JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)]
public Message Message { get; set; }
[JsonProperty("sms_message", NullValueHandling = NullValueHandling.Ignore)]
public SmsMessage SMSMessage { get; set; }
[JsonProperty("options", DefaultValueHandling = DefaultValueHandling.Include)]
public Options Options { get; set; } = new Options
{
IsApnsProduction = false
};
internal string GetJson()
{
return JsonConvert.SerializeObject(this, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
});
}
public override string ToString()
{
return GetJson();
}
}
}

View File

@@ -0,0 +1,27 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Jiguang.JPush.Model
{
/// <summary>
/// 短信补充。
/// <see cref="https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#sms_message"/>
/// </summary>
public class SmsMessage
{
[JsonProperty("delay_time", DefaultValueHandling = DefaultValueHandling.Include)]
public int DelayTime { get; set; }
[JsonProperty("signid", NullValueHandling = NullValueHandling.Ignore)]
public int Signid { get; set; }
[JsonProperty("temp_id", DefaultValueHandling = DefaultValueHandling.Include)]
public long TempId { get; set; }
[JsonProperty("temp_para", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, object> TempPara { get; set; }
[JsonProperty("active_filter", NullValueHandling = NullValueHandling.Ignore)]
public bool? ActiveFilter { get; set; }
}
}

View File

@@ -0,0 +1,69 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Jiguang.JPush.Model
{
/// <summary>
/// 定期任务触发器。
/// <see cref="https://docs.jiguang.cn/jpush/server/push/rest_api_push_schedule/#schedule"/>
/// </summary>
public class Trigger
{
/// <summary>
/// 定期任务开始日期,必须为 24 小时制。
/// 类似:"2017-08-01 12:00:00"
/// </summary>
[JsonProperty("start")]
public string StartDate { get; set; }
/// <summary>
/// 定期任务终止日期,必须为 24 小时制。
/// 类似:"2017-12-30 12:00:00"
/// </summary>
[JsonProperty("end")]
public string EndDate { get; set; }
/// <summary>
/// 具体的触发时间。
/// 类似:"12:00:00"
/// </summary>
[JsonProperty("time")]
public string TriggerTime { get; set; }
/// <summary>
/// 定期任务执行的最小时间单位。
/// 必须为 "day" / "week" / "month" 中的一种。
/// </summary>
[JsonProperty("time_unit")]
public string TimeUnit { get; set; }
/// <summary>
/// 定期任务的执行周期(目前最大支持 100
/// 比如,当 TimeUnit 为 "day"Frequency 为 2 时,表示每两天触发一次推送。
/// </summary>
[JsonProperty("frequency")]
public int Frequency { get; set; }
/// <summary>
/// 当 TimeUnit 为 "week" 或 "month"时,具体的时间表。
/// - 如果 TimeUnit 为 "week": {"mon", "tue", "wed", "thu", "fri", "sat", "sun"};
/// - 如果 TimeUnit 为 "month": {"01", "02"...};
/// </summary>
[JsonProperty("point")]
public List<string> TimeList { get; set; }
private string GetJson()
{
return JsonConvert.SerializeObject(this, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
});
}
public override string ToString()
{
return GetJson();
}
}
}