蛋蛋星球-制度模式
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 regels
4.1 KiB

  1. package jpush
  2. import "encoding/json"
  3. type Platform string
  4. const (
  5. All Platform = "all"
  6. PlatformAndroid Platform = "android"
  7. PlatformIOS Platform = "ios"
  8. PlatformWinPhone Platform = "winphone"
  9. )
  10. type PushAudience struct {
  11. Tag []string `json:"tag,omitempty"`
  12. TagAnd []string `json:"tag_and,omitempty"`
  13. TagNot []string `json:"tag_not,omitempty"`
  14. Alias []string `json:"alias,omitempty"`
  15. RegistrationId []string `json:"registration_id,omitempty"`
  16. Segment []string `json:"segment,omitempty"`
  17. ABTest []string `json:"abtest,omitempty"`
  18. }
  19. type PushNotification struct {
  20. Alert string `json:"alert,omitempty"`
  21. Android *NotificationAndroid `json:"android,omitempty"`
  22. Hmos *NotificationHmos `json:"hmos,omitempty"`
  23. IOS *NotificationIOS `json:"ios,omitempty"`
  24. WinPhone *NotificationWinPhone `json:"winphone,omitempty"`
  25. }
  26. type NotificationAndroid struct {
  27. Alert string `json:"alert"`
  28. Title string `json:"title,omitempty"`
  29. BuilderId int `json:"builder_id,int,omitempty"`
  30. Priority int `json:"priority,omitempty"`
  31. Category string `json:"category,omitempty"`
  32. Style int `json:"style,int,omitempty"`
  33. AlertType int `json:"alert_type,int,omitempty"`
  34. BigText string `json:"big_text,omitempty"`
  35. Inbox map[string]interface{} `json:"inbox,omitempty"`
  36. BigPicPath string `json:"big_pic_path,omitempty"`
  37. Extras map[string]interface{} `json:"extras,omitempty"`
  38. }
  39. type NotificationHmos struct {
  40. Alert string `json:"alert"`
  41. Title string `json:"title"`
  42. }
  43. type NotificationIOS struct {
  44. Alert interface{} `json:"alert"`
  45. Sound string `json:"sound,omitempty"`
  46. Badge int `json:"badge,int,omitempty"`
  47. ContentAvailable bool `json:"content-available,omitempty"`
  48. MutableContent bool `json:"mutable-content,omitempty"`
  49. Category string `json:"category,omitempty"`
  50. Extras map[string]interface{} `json:"extras,omitempty"`
  51. }
  52. type NotificationWinPhone struct {
  53. Alert string `json:"alert"`
  54. Title string `json:"title,omitempty"`
  55. OpenPage string `json:"_open_page,omitempty"`
  56. Extras map[string]interface{} `json:"extras,omitempty"`
  57. }
  58. type PushMessage struct {
  59. MsgContent string `json:"msg_content"`
  60. Title string `json:"title,omitempty"`
  61. ContentType string `json:"content_type,omitempty"`
  62. Extras map[string]interface{} `json:"extras,omitempty"`
  63. }
  64. type SmsMessage struct {
  65. Content string `json:"content"`
  66. DelayTime int `json:"delay_time,int,omitempty"`
  67. }
  68. type PushOptions struct {
  69. SendNo int `json:"sendno,int,omitempty"`
  70. TimeToLive int `json:"time_to_live,int,omitempty"`
  71. OverrideMsgId int64 `json:"override_msg_id,int64,omitempty"`
  72. ApnsProduction bool `json:"apns_production"`
  73. ApnsCollapseId string `json:"apns_collapse_id,omitempty"`
  74. BigPushDuration int `json:"big_push_duration,int,omitempty"`
  75. }
  76. type PushRequest struct {
  77. Cid string `json:"cid,omitempty"`
  78. Platform string `json:"platform"`
  79. Audience interface{} `json:"audience,omitempty"`
  80. Notification *PushNotification `json:"notification,omitempty"`
  81. Message *PushMessage `json:"message,omitempty"`
  82. SmsMessage *SmsMessage `json:"sms_message,omitempty"`
  83. Options *PushOptions `json:"options,omitempty"`
  84. }
  85. type Response struct {
  86. data []byte
  87. }
  88. func (res *Response) Array() ([]interface{}, error) {
  89. list := make([]interface{}, 0)
  90. err := json.Unmarshal(res.data, &list)
  91. return list, err
  92. }
  93. func (res *Response) Map() (map[string]interface{}, error) {
  94. result := make(map[string]interface{})
  95. err := json.Unmarshal(res.data, &result)
  96. return result, err
  97. }
  98. func (res *Response) Bytes() []byte {
  99. return res.data
  100. }