jpush 3.2.1 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +11 -0
  3. data/.travis.yml +7 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +56 -0
  7. data/Rakefile +10 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +8 -0
  10. data/docs/README.md +347 -0
  11. data/jpush.gemspec +35 -0
  12. data/lib/jpush.rb +6 -26
  13. data/lib/jpush/api.rb +42 -0
  14. data/lib/jpush/config.rb +20 -0
  15. data/lib/jpush/device.rb +182 -0
  16. data/lib/jpush/helper/argument.rb +77 -0
  17. data/lib/jpush/helper/argument_helper.rb +59 -0
  18. data/lib/jpush/http/client.rb +39 -0
  19. data/lib/jpush/http/response.rb +47 -0
  20. data/lib/jpush/push.rb +36 -0
  21. data/lib/jpush/push/audience.rb +46 -0
  22. data/lib/jpush/push/notification.rb +75 -0
  23. data/lib/jpush/push/push_payload.rb +100 -0
  24. data/lib/jpush/report.rb +62 -0
  25. data/lib/jpush/schedule.rb +51 -0
  26. data/lib/jpush/schedule/schedule_payload.rb +61 -0
  27. data/lib/jpush/schedule/trigger.rb +66 -0
  28. data/lib/jpush/utils/exceptions.rb +80 -0
  29. data/lib/jpush/utils/helper.rb +48 -0
  30. data/lib/jpush/utils/http.rb +77 -0
  31. data/lib/jpush/version.rb +3 -0
  32. metadata +73 -43
  33. data/lib/jpush/api_connection_exception.rb +0 -11
  34. data/lib/jpush/device_client.rb +0 -84
  35. data/lib/jpush/http_client.rb +0 -138
  36. data/lib/jpush/jpush_client.rb +0 -149
  37. data/lib/jpush/model/alias_uids_result.rb +0 -32
  38. data/lib/jpush/model/audience.rb +0 -67
  39. data/lib/jpush/model/exist_result.rb +0 -33
  40. data/lib/jpush/model/get_messages_result.rb +0 -30
  41. data/lib/jpush/model/message.rb +0 -37
  42. data/lib/jpush/model/messages_result.rb +0 -7
  43. data/lib/jpush/model/notification/android_notification.rb +0 -38
  44. data/lib/jpush/model/notification/ios_notification.rb +0 -64
  45. data/lib/jpush/model/notification/notification.rb +0 -35
  46. data/lib/jpush/model/notification/winphone_notification.rb +0 -37
  47. data/lib/jpush/model/options.rb +0 -64
  48. data/lib/jpush/model/platform.rb +0 -57
  49. data/lib/jpush/model/push_payload.rb +0 -76
  50. data/lib/jpush/model/push_result.rb +0 -32
  51. data/lib/jpush/model/receiveds_result.rb +0 -62
  52. data/lib/jpush/model/tag_alias.rb +0 -62
  53. data/lib/jpush/model/tag_alias_result.rb +0 -32
  54. data/lib/jpush/model/tag_list_result.rb +0 -32
  55. data/lib/jpush/model/tag_manager.rb +0 -44
  56. data/lib/jpush/model/user_result.rb +0 -40
  57. data/lib/jpush/push_client.rb +0 -45
  58. data/lib/jpush/report_client.rb +0 -50
  59. data/lib/jpush/response_wrapper.rb +0 -37
  60. data/lib/jpush/util/service_helper.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afc8cbc7711185ef95c4a147eee1be80a71cc18c
4
- data.tar.gz: 7c16e63e9a0b54c83ea290a38a36f2205d9903e4
3
+ metadata.gz: 0bae15213acb2d3c9dfd3d3babf1c99ace6034c8
4
+ data.tar.gz: bfdab4624e1cee4ae30433fd1c0f5da239fbf88c
5
5
  SHA512:
6
- metadata.gz: ef8fdb050300bb47b07d32d1de23497f2335e3d2aa21d4817cdb6207bdb0864acc4e2fdc08b52a8c50387c098fa2b518aca29393636691cfae52673892850997
7
- data.tar.gz: 44f804cf52523e6cdc09194923074e51058126212e8058b8f7f80f7b4a98575fe41d229a193a37f9c269135f29b4be36dbaf2862aa05becc2250de1942cc946e
6
+ metadata.gz: 7cc2de05de5a4e864039a3761be554396a91673948994ebd353fed6177e2096213d827e944f0ba93eaa0be96fd46f4defd610054a24301dee81e9f387cd20ea6
7
+ data.tar.gz: b5d30caaab0b375caa58ed2b26f1b23b63607158cbdb05340570f6656dce921b69f09ededbaff762884fcebe54e0c8730cbe50e97a48db8f72166d8fa7dff3f6
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /test/config.yml
11
+ *~
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ - 2.2.0
5
+ before_install: gem install bundler -v 1.11.2
6
+
7
+ before_script: cp test/config.yml.example test/config.yml
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jpush.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Helperhaps
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ [![](http://community.jpush.cn/uploads/default/original/1X/a1dbd54304178079e65cdc36810fdf528fdebe24.png)](http://community.jpush.cn/)
2
+
3
+ # JPush API Ruby Client
4
+
5
+ [![Build Status](https://travis-ci.org/jpush/jpush-api-ruby-client.svg?branch=master)](https://travis-ci.org/jpush/jpush-api-ruby-client)
6
+
7
+ 这是 JPush REST API 的 Ruby 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。
8
+ 对应的 REST API 文档: http://docs.jpush.io/server/server_overview/,
9
+ 支持 Ruby 版本 >= 2.2.0
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'jpush', git: 'https://github.com/jpush/jpush-api-ruby-client.git'
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ - [Getting Started](docs/README.md#getting-started)
22
+ - [Device API](docs/README.md#device-api)
23
+ - [Push API](docs/README.md#push-api)
24
+ - [Report API](docs/README.md#report-api)
25
+ - [Schedule API](docs/README.md#schedule-api)
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Testing
34
+
35
+ ```bash
36
+ # 复制测试的配置文件
37
+ $ cp test/config.yml.example test/config.yml
38
+
39
+ # 编辑 test/config.yml 文件,填入必须的变量值
40
+ # OR 设置相应的环境变量
41
+
42
+ # 运行全部测试用例
43
+ $ bundle exec rake
44
+
45
+ # 运行某一具体测试用例
46
+ $ bundle exec rake test TEST=test/jpush/xx_test.rb
47
+ ```
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jpush/jpush-api-ruby-client.
52
+
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jpush"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/docs/README.md ADDED
@@ -0,0 +1,347 @@
1
+ ## 目录
2
+
3
+ - [Getting Started](#getting-started)
4
+ - [Device API](#device-api)
5
+ - [查询设备](#查询设备-设备的别名与标签)
6
+ - [更新设备](#更新设备-设备的别名与标签)
7
+ - [获取用户在线状态(VIP专属接口)](#获取用户在线状态vip专属接口)
8
+ - [查询标签列表](#查询标签列表)
9
+ - [判断设备与标签的绑定](#判断设备与标签的绑定)
10
+ - [更新标签](#更新标签-与设备的绑定的关系)
11
+ - [删除标签](#删除标签-与设备的绑定关系)
12
+ - [查询别名](#查询别名-与设备的绑定关系)
13
+ - [删除别名](#删除别名-与设备的绑定关系)
14
+ - [Push API](#push-api)
15
+ - [构建复杂的 Audience 对象](#构建复杂的-audience-对象)
16
+ - [构建复杂的 Notification 对象](#构建复杂的-notification-对象)
17
+ - [构建复杂 PushPayload 对象](#构建复杂-pushpayload-对象)
18
+ - [推送消息](#推送消息)
19
+ - [Report API](#report-api)
20
+ - [送达统计](#送达统计)
21
+ - [消息统计(VIP专属接口)](#消息统计vip专属接口)
22
+ - [用户统计(VIP专属接口)](#用户统计vip专属接口)
23
+ - [Schedule API](#schedule-api)
24
+ - [构建 Trigger 对象](#构建-trigger-对象)
25
+ - [构建 SchedulePayload 对象](#构建-schedulepayload-对象)
26
+ - [创建定时任务](#创建定时任务)
27
+ - [获取有效的定时任务列表](#获取有效的定时任务列表)
28
+ - [获取定时任务详情](#获取定时任务详情)
29
+ - [更新定时任务](#更新定时任务)
30
+ - [删除定时任务](#删除定时任务)
31
+
32
+ #### Getting Started
33
+
34
+ [Where to get app_key or master_secret?](https://www.jpush.cn/common/apps/new)
35
+
36
+ ```ruby
37
+ app_key = 'xxx'
38
+ master_secret = 'xxx'
39
+ jpush = JPush::Client.new(app_key, master_secret)
40
+ ```
41
+
42
+ #### Device API
43
+
44
+ ```ruby
45
+ devices = jpush.devices
46
+ tags = jpush.tags
47
+ aliases = jpush.aliases
48
+ ```
49
+
50
+ ###### 查询设备 (设备的别名与标签)
51
+
52
+ ```ruby
53
+ # 获取当前设备的所有属性,包含标签 tags, 别名 alias, 手机号码 mobile
54
+ devices.show(registration_id)
55
+ ```
56
+
57
+ ###### 更新设备 (设备的别名与标签)
58
+
59
+ ```ruby
60
+ # 为设备添加/移除标签
61
+ # 参数 tags 为一个表示有效的 tag 字符串或者一个最多包含100个有效的 tag 字符串的数组
62
+ devices.add_tags(registration_id, tags)
63
+ devices.remove_tags(registration_id, tags)
64
+
65
+ # 清除设备所有标签
66
+ devices.clear_tags(registration_id)
67
+
68
+ # 更新设备的别名
69
+ devices.update_alias(registration_id, alis)
70
+
71
+ # 删除设备的别名
72
+ devices.delete_alias(registration_id)
73
+
74
+ # 更新设备的手机号码
75
+ devices.update_mobile(registration_id)
76
+ ```
77
+
78
+ ###### 获取用户在线状态(VIP专属接口)
79
+
80
+ ```ruby
81
+ # 参数 registration_ids 为一个表示有效的 registration_id 字符串或者一个最多包含1000个有效的 registration_id 字符串的数组
82
+ device.status(registration_ids)
83
+ ```
84
+
85
+ ###### 查询标签列表
86
+
87
+ ```ruby
88
+ # 获取应用的所有标签列表
89
+ tags.list
90
+ ```
91
+
92
+ ###### 判断设备与标签的绑定
93
+
94
+ ```ruby
95
+ # 查询某个设备是否在标签下
96
+ tags.has_device?(tag_value, registration_id)
97
+ ```
98
+
99
+ ###### 更新标签 (与设备的绑定的关系)
100
+
101
+ ```ruby
102
+ # 为一个标签添加/移除设备
103
+ # 参数 registration_ids 为一个表示有效的 registration_id 字符串或者一个最多包含1000个有效的 registration_id 字符串的数组
104
+ tags.add_devices(tag_value, registration_ids)
105
+ tags.remove_devices(tag_value, registration_ids)
106
+ ```
107
+
108
+ ###### 删除标签 (与设备的绑定关系)
109
+
110
+ ```ruby
111
+ # 删除一个标签,以及标签与设备之间的关联关系, platform 默认为所有平台
112
+ tags.delete(tag_value, platform = nil)
113
+ ```
114
+
115
+ ###### 查询别名 (与设备的绑定关系)
116
+
117
+ ```ruby
118
+ # 获取指定别名下的设备,最多输出10个, platform 默认为所有平台
119
+ aliases.show(alias_value, platform = nil)
120
+ ```
121
+
122
+ ###### 删除别名 (与设备的绑定关系)
123
+
124
+ ```ruby
125
+ # 删除一个别名,以及该别名与设备的绑定关系, platform 默认为所有平台
126
+ aliases.delete(alias_value, platform = nil)
127
+ ```
128
+
129
+ #### Push API
130
+
131
+ ```ruby
132
+ pusher = jpush.pusher
133
+
134
+ # simplest push Hello to all
135
+ push_payload = JPush::Push::PushPayload.new(
136
+ platform: 'all',
137
+ audience: 'all',
138
+ notification: 'hello jpush',
139
+ message: 'hello world'
140
+ ).build
141
+ pusher.push(push_payload)
142
+ ```
143
+
144
+ ###### 构建复杂的 Audience 对象
145
+
146
+ 推送设备对象,表示一条推送可以被推送到哪些设备列表。
147
+ 如果要发广播(全部设备),不需要构建 Audience 对象,在新建 PushPayload 对象的时候,给 'audience' 直接传递 'all'即可。
148
+ 广播外的设备选择方式,有4种类型: tag, tag_and, alias, registration_id
149
+ 4 种类型至少需要有其一, 这几种类型并存时多项的隐含关系是 AND,即取交集。
150
+
151
+ ```ruby
152
+ # 参数 tag 和 tag_and 为一个有效的 tag 字符串或者一个最多包含20个有效的 tag 字符串的数组
153
+ # 参数 alias 为一个表示有效的 alias 字符串或者一个最多包含1000个有效的 alias 字符串的数组
154
+ # 参数registration_ids 为一个表示有效的 registration_id 字符串或者一个最多包含1000个有效的 registration_id 字符串的数组
155
+ audience = JPush::Push::Audience.new
156
+ audience.set_tag(tag)
157
+ audience.set_tag_and(tag_and)
158
+ audience.set_alias(alis)
159
+ audience.set_registration_id(registration_ids)
160
+ audience.build
161
+
162
+ # OR
163
+ audience = JPush::Push::Audience.new.
164
+ set_tag(tag).
165
+ set_tag_and(tag_and).
166
+ set_alias(alis).
167
+ set_registration_id(registration_ids).
168
+ build
169
+ ```
170
+
171
+ ###### 构建复杂的 Notification 对象
172
+
173
+ 若通知的内容在各个平台上,都只有 'alert' 这一个最基本的属性,
174
+ 则不需要构建 Notifacation 对象,在新建 PushPayload 对象的时候,给 'notication' 直接传递 alert 字符串即可。
175
+
176
+ ```ruby
177
+ notification = JPush::Push::Notification.new
178
+
179
+ notification.set_alert(alert)
180
+ notification.set_not_alert # 不展示到通知栏
181
+
182
+ # 参数 extra 为一个 Hash 对象,表示自定义扩展字段以供业务使用
183
+ notification.set_android(alert: , title: nil, builder_id: nil, extras: nil)
184
+ # 参数 available 表示推送唤醒,仅能接受 true 或者 nil
185
+ notification.set_ios(alert: , sound: nil, badge: nil, available: nil, category: nil, extras: nil)
186
+
187
+ notification.build
188
+
189
+ # OR
190
+ notification = JPush::Push::Notification.new.
191
+ set_alert(alert).
192
+ set_android(alert: , title: nil, builder_id: nil, extras: nil).
193
+ set_ios(alert: , sound: nil, badge: nil, available: nil, category: nil, extras: nil).
194
+ build
195
+ ```
196
+
197
+ ###### 构建复杂 PushPayload 对象
198
+
199
+ 一个推送对象,表示一条推送相关的所有信息,通知内容体。是被推送到客户端的内容。
200
+ notification 和 message 二者必须有其一,可以二者并存。
201
+
202
+ ```ruby
203
+ # audience 和 notification 对象可按照上面的例子实例化
204
+ audience = JPush::Push::Andience.new
205
+ notification = JPush::Push::Notification.new
206
+
207
+ # 初始化 PushPayload 对象
208
+ # 参数 platform 表示推送的平台,其可接受的参数为 'all'(表示推送到所有平台), 'android' 或 'ios'
209
+ # 参数 audience 表示推送的设备,其可接受的参数为 'all' (表示发广播(推送到全部设备)) 或者一个 Audience 对象
210
+ # 参数 notification 接受一个字符串(表示为仅设置最基本的属性 'alert') 或者一个 Notifcation 对象
211
+ # 参数 message 仅接受一个字符串来快速设置消息内容本身
212
+ push_payload = JPush::Push::PushPayload.new(
213
+ platform: , audience: , notification: , message:
214
+ )
215
+
216
+ # 添加应用内消息
217
+ # 参数 extra 为一个 Hash 对象,表示自定义扩展字段以供业务使用
218
+ push_payload.set_message(msg_content, title: nil,content_type: nil, extras: nil)
219
+
220
+ # 添加短信业务
221
+ # 参数 content 表示短信内容,不能超过480个字符
222
+ # 参数 delay_time 表示短信发送的延迟时间,单位为秒,不能超过24小时。
223
+ # 该参数仅对android平台有效。默认为 0,表示立即发送短信
224
+ push_payload.set_sms_message(content, delay_time = 0)
225
+
226
+ push_payload.build
227
+
228
+ # OR
229
+ push_payload = JPush::Push::PushPayload.new(
230
+ platform: , audience: , notification: ).
231
+ set_message(msg_content, title: nil,content_type: nil, extras: nil).
232
+ set_sms_message(content, delay_time).
233
+ build
234
+ ```
235
+
236
+ ###### 推送消息
237
+
238
+ ```ruby
239
+ # 仅接受一个 PushPayload对象参数
240
+ pusher.push(push_payload)
241
+ ```
242
+
243
+ #### Report API
244
+
245
+ ```ruby
246
+ reporter = jpush.reporter
247
+ ```
248
+
249
+ ###### 送达统计
250
+
251
+ ```ruby
252
+ # 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
253
+ reporter.received(msg_ids)
254
+ ```
255
+
256
+ ###### 消息统计(VIP专属接口)
257
+
258
+ ```ruby
259
+ # 与送达统计 API 不同的是,该 API 提供更多的的统计数据
260
+ # 参数 msg_ids 为一个表示有效的 msg_id 字符串或者一个最多包含100个有效的 msg_id 字符串的数组
261
+ reporter.messages(msg_ids)
262
+ ```
263
+
264
+ ###### 用户统计(VIP专属接口)
265
+
266
+ ```ruby
267
+ # 提供近2个月内某时间段的用户相关统计数据:新增用户、在线用户、活跃用户
268
+ # 参数 time_unit 表示时间单位,支持:HOUR(小时)、DAY(天)、MONTH(月) (不区分大小写)
269
+ # 参数 start 接受一个 Time 类的实例,表示统计的起始时间,会根据参数 time_unit 自动的转换成需要的格式
270
+ # 参数 duration 表示统计持续的时长,根据参数 time_unit 的不同有不同的取值范围,
271
+ # 若 time_unit 为 'MONTH' 其范围为1至2,若 time_unit 为 'DAY' 其范围为1至60,
272
+ # 若 time_unit 为 'HOUR',其范围为1至24,并且只支持输出当天的统计结果,
273
+ # 若 duration 超过限定的最大取值,则取最大值。
274
+ reporter.users(time_unit, start, duration)
275
+ ```
276
+
277
+ #### Schedule API
278
+
279
+ ```ruby
280
+ schedules = jpush.schedules
281
+ ```
282
+
283
+ ###### 构建 Trigger 对象
284
+
285
+ 表示schedule任务的触发条件,当前只支持定时任务(single)或定期任务(periodical)
286
+
287
+ ```ruby
288
+ # 定时任务(single)
289
+ # 参数 time 接受一个 Time 对象
290
+ single = JPush::Schedule::Trigger.new.set_single(time)
291
+
292
+ # 定期任务(periodical)
293
+ # 参数 start_time 和 end_time 表示定期任务有效起始时间与过期时间,都接受一个 Time 对象
294
+ # 参数 time 表示触发定期任务的定期执行时间, 其接受一个表示24小时制时间(时分秒)的字符串,例如:'12:07'
295
+ # 参数 time_unit 表示定期任务的执行的最小时间单位 可选 'day','week' 或 'month'
296
+ # 参数 frequency 与time_unit的乘积共同表示的定期任务的执行周期
297
+ # 参数 point 接受一个数组,此项与time_unit相对应:
298
+ # 当time_unit为day时point此项无效
299
+ # 当time_unit为week时,point为数组 ['MON','TUE','WED','THU','FRI','SAT','SUN'] 的子数组,表示星期几进行触发
300
+ # 当time_unit为month时,point为当前进行月对应的日期, 为数组['01', '02' , .., '31'] 的子数组
301
+ periodical = JPush::Schedule::Trigger.new.set_periodical(start_time, end_time, time, time_unit, frequency, point)
302
+ ```
303
+
304
+ ###### 构建 SchedulePayload 对象
305
+
306
+ ```ruby
307
+ # 参数 triggle 接受一个 Trigger 对象,或者一个 Time 对象快速设置 single 定时任务
308
+ # 参数 push 仅接受一个有效的 PushPayload 对象
309
+ JPush::Schedule::SchedulePayload.new(name, trigger, push)
310
+ ```
311
+
312
+ ###### 创建定时任务
313
+
314
+ ```ruby
315
+ # 参数 schedule_payload 仅接受一个有效的 SchedulePayload 对象
316
+ schedules.create(schedule_payload)
317
+ ```
318
+
319
+ ###### 获取有效的定时任务列表
320
+
321
+ ```ruby
322
+ # 返回当前请求页的详细的 schedule-task 列表,如未指定page则page为1
323
+ schedules.tasks(page)
324
+ ```
325
+
326
+ ###### 获取定时任务详情
327
+
328
+ ```ruby
329
+ schedules.show(schedule_id)
330
+ ```
331
+
332
+ ###### 更新定时任务
333
+
334
+ ```ruby
335
+ # 更新操作必须为 'name','enabled','trigger' 或 'push' 四项中的一项或多项
336
+ # 参数 triggle 接受一个 Trigger 对象,或者一个 Time 对象快速设置 single 定时任务
337
+ # 参数 push 仅接受一个有效的 PushPayload 对象
338
+ schedules.update(schedule_id, name: nil, enabled: nil, trigger: nil, push: nil)
339
+ # 例如只更新 name
340
+ schedules.update(schedule_id, name: 'jpush')
341
+ ```
342
+
343
+ ###### 删除定时任务
344
+
345
+ ```ruby
346
+ schedules.delete(schedule_id)
347
+ ```