jpush 3.1.1 → 3.2.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jpush.rb +10 -0
  3. data/lib/jpush/api_connection_exception.rb +11 -0
  4. data/lib/jpush/device_client.rb +84 -0
  5. data/lib/jpush/http_client.rb +32 -18
  6. data/lib/jpush/jpush_client.rb +81 -7
  7. data/lib/jpush/model/alias_uids_result.rb +32 -0
  8. data/lib/jpush/model/exist_result.rb +33 -0
  9. data/lib/jpush/model/get_messages_result.rb +30 -0
  10. data/lib/jpush/model/notification/ios_notification.rb +6 -2
  11. data/lib/jpush/model/options.rb +15 -4
  12. data/lib/jpush/model/push_payload.rb +6 -0
  13. data/lib/jpush/model/push_result.rb +4 -4
  14. data/lib/jpush/model/receiveds_result.rb +3 -3
  15. data/lib/jpush/model/tag_alias.rb +62 -0
  16. data/lib/jpush/model/tag_alias_result.rb +32 -0
  17. data/lib/jpush/model/tag_list_result.rb +32 -0
  18. data/lib/jpush/model/tag_manager.rb +44 -0
  19. data/lib/jpush/model/user_result.rb +40 -0
  20. data/lib/jpush/push_client.rb +18 -4
  21. data/lib/jpush/report_client.rb +11 -6
  22. data/lib/jpush/response_wrapper.rb +2 -1
  23. data/lib/jpush/util/service_helper.rb +3 -2
  24. metadata +13 -26
  25. data/.gitignore +0 -18
  26. data/.project +0 -18
  27. data/Gemfile +0 -4
  28. data/LICENSE.txt +0 -339
  29. data/README.md +0 -75
  30. data/Rakefile +0 -1
  31. data/example/push_example.rb +0 -101
  32. data/example/report_example.rb +0 -18
  33. data/jpush.gemspec +0 -24
  34. data/test/alert_override_tests.rb +0 -62
  35. data/test/audience_tests.rb +0 -169
  36. data/test/base_remote_tests.rb +0 -27
  37. data/test/message_tests.rb +0 -49
  38. data/test/notification_tests.rb +0 -52
  39. data/test/push_payload_test.rb +0 -58
  40. data/test/report_function_tests.rb +0 -40
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,101 +0,0 @@
1
- require 'jpush'
2
-
3
- master_secret = '2b38ce69b1de2a7fa95706ea'
4
- app_key = 'dd1066407b044738b6479275'
5
- client = JPush::JPushClient.new(app_key, master_secret)
6
-
7
- logger = Logger.new(STDOUT)
8
- #send broadcast
9
- payload1 = JPush::PushPayload.build(
10
- platform: JPush::Platform.all,
11
- audience: JPush::Audience.all,
12
- notification: JPush::Notification.build(
13
- alert: 'alert meassage')
14
- )
15
- result = client.sendPush(payload1)
16
- logger.debug("Got result " + result.toJSON)
17
-
18
- #send winphone
19
- payload1 = JPush::PushPayload.build(
20
- platform: JPush::Platform.all,
21
- audience: JPush::Audience.all,
22
- notification: JPush::Notification.build(
23
- alert: 'alert meassage',
24
- winphone: JPush::WinphoneNotification.build(
25
- alert: "winphone notification alert test",
26
- title: "winphone notification title test",
27
- _open_page: "/friends.xaml",
28
- extras: {"key1" => "value1", "key2" => "value2"})))
29
- result = client.sendPush(payload1)
30
- logger.debug("Got result " + result.toJSON)
31
-
32
- #send android WithExtrasMessage
33
- payload1 = JPush::PushPayload.build(
34
- platform: JPush::Platform.all,
35
- audience: JPush::Audience.all,
36
- notification: JPush::Notification.build(
37
- alert: 'alert meassage',
38
- android: JPush::AndroidNotification.build(
39
- alert: "android notification alert test",
40
- title: "android notification title test",
41
- builder_id: 1,
42
- extras: {"key1" => "value1", "key2" => "value2"})),
43
- message: JPush::Message.build(
44
- msg_content: "message content test",
45
- title: "message title test",
46
- content_type: "message content type test",
47
- extras: {"key1" => "value1", "key2" => "value2"})
48
- )
49
- result = client.sendPush(payload1)
50
- logger.debug("Got result " + result.toJSON)
51
-
52
- #send ios WithExtrasMessageANDoptions
53
- payload1 = JPush::PushPayload.build(
54
- platform: JPush::Platform.all,
55
- audience: JPush::Audience.all,#audience: JPush::Audience.build{ _alias : "your alias"}
56
- notification: JPush::Notification.build(
57
- alert: 'alert meassage',
58
- ios: JPush::IOSNotification.build(
59
- alert: "ios notification alert test",
60
- title: "ios notification title test",
61
- badge: 1,
62
- sound: "happy",
63
- extras: {"key1" => "value1", "key2" => "value2"})),
64
- message: JPush::Message.build(
65
- msg_content: "message content test",
66
- title: "message title test",
67
- content_type: "message content type test",
68
- extras: {"key1" => "value1", "key2" => "value2"}),
69
- options:JPush::Options.build(
70
- sendno: 1,
71
- apns_production: true))
72
- result = client.sendPush(payload1)
73
- logger.debug("Got result " + result.toJSON)
74
-
75
- #sendByTag
76
- payload = JPush::PushPayload.build(
77
- platform: JPush::Platform.all,
78
- notification: JPush::Notification.build(
79
- alert: 'alert'),
80
- audience: JPush::Audience.build(
81
- tag: ["tag1"]))
82
- res = client.sendPush(payload)
83
- logger.debug("Got result " + res.toJSON)
84
- #sendByTagAnd
85
- payload = JPush::PushPayload.build(
86
- platform: JPush::Platform.all,
87
- notification: JPush::Notification.build(
88
- alert: 'alert'),
89
- audience: JPush::Audience.build(
90
- tag_and: ["tag1"]))
91
- res = client.sendPush(payload)
92
- logger.debug("Got result " + res.toJSON)
93
- #sendByAlias
94
- payload = JPush::PushPayload.build(
95
- platform: JPush::Platform.all,
96
- notification: JPush::Notification.build(
97
- alert: 'alert'),
98
- audience: JPush::Audience.build(
99
- _alias: ["alias1"]))
100
- res = client.sendPush(payload)
101
- logger.debug("Got result " + res.toJSON)
@@ -1,18 +0,0 @@
1
- require 'jpush'
2
-
3
- master_secret = '2b38ce69b1de2a7fa95706ea'
4
- app_key = 'dd1066407b044738b6479275'
5
- client = JPush::JPushClient.new(app_key, master_secret)
6
- logger = Logger.new(STDOUT)
7
-
8
- #getReceiveds
9
- result = client.getReportReceiveds('1942377665')
10
- logger.debug("Got result - " + result.toJSON)
11
-
12
- #getMessages
13
- #result = client.getReportMessages('1942377665')
14
- #logger.debug("Got result - " + result)
15
-
16
- #getUsers
17
- #result = client.getReportUsers('DAY',"2014-06-10",'3')
18
- #logger.debug("Got result - " + result)
@@ -1,24 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "jpush"
7
- spec.version = "3.1.1"
8
- spec.authors = ['JPush Offical']
9
- spec.email = ['support@jpush.cn']
10
- spec.description = "JPush's officially supported Ruby client library for accessing JPush APIs. http://jpush.cn"
11
- spec.summary = "JPush's officially supported Ruby client library for accessing JPush APIs."
12
- spec.homepage = "https://github.com/jpush/jpush-api-ruby-client"
13
- spec.license = "GNU"
14
-
15
- spec.files = `git ls-files`.split($/)
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_development_dependency "rspec", "~> 2.6"
21
- #spec.add_runtime_dependency "rest-client","~> 1.6.7"
22
- #spec.add_runtime_dependency "json", "~> 1.7.7"
23
-
24
- end
@@ -1,62 +0,0 @@
1
- require 'jpush'
2
- require './base_remote_tests.rb';
3
- require 'test/unit'
4
-
5
- class AlertOverrideTests < Test::Unit::TestCase
6
- def setup
7
- @client = JPush::JPushClient.new(AppKey, MasterSecret)
8
- end
9
-
10
- def testsendAlert_all
11
- @payload = JPush::PushPayload.build(
12
- audience: JPush::Audience.all,
13
- platform: JPush::Platform.all,
14
- notification: JPush::Notification.build(
15
- alert: 'alert',
16
- ios: JPush::IOSNotification.build(
17
- alert: 'ios alert'),
18
- android: JPush::AndroidNotification.build(
19
- alert: 'android alert'),
20
- winphone: JPush::WinphoneNotification.build(
21
- alert: 'winphone alert')))
22
- res = @client.sendPush(@payload)
23
- assert(res.isok, message = "response error")
24
- end
25
-
26
- def testsendAlert_android
27
- @payload = JPush::PushPayload.build(
28
- audience: JPush::Audience.all,
29
- platform: JPush::Platform.all,
30
- notification: JPush::Notification.build(
31
- alert: 'alert',
32
- android: JPush::AndroidNotification.build(
33
- alert: 'android alert')))
34
- res = @client.sendPush(@payload)
35
- assert(res.isok, message = "response error")
36
- end
37
-
38
- def testsendAlert_ios
39
- @payload = JPush::PushPayload.build(
40
- audience: JPush::Audience.all,
41
- platform: JPush::Platform.all,
42
- notification: JPush::Notification.build(
43
- alert: 'alert',
44
- ios: JPush::IOSNotification.build(
45
- alert: 'ios alert')))
46
- res = @client.sendPush(@payload)
47
- assert(res.isok, message = "response error")
48
- end
49
-
50
- def testsendAlert_wp
51
- @payload = JPush::PushPayload.build(
52
- audience: JPush::Audience.all,
53
- platform: JPush::Platform.all,
54
- notification: JPush::Notification.build(
55
- alert: 'alert',
56
- winphone: JPush::WinphoneNotification.build(
57
- alert: 'winphone alert')))
58
- res = @client.sendPush(@payload)
59
- assert(res.isok, message = "response error")
60
- end
61
-
62
- end
@@ -1,169 +0,0 @@
1
- require 'jpush'
2
-
3
- require './base_remote_tests.rb'
4
-
5
- require 'test/unit'
6
- class AudienceTests < Test::Unit::TestCase
7
- def setup
8
- @client = JPush::JPushClient.new(AppKey, MasterSecret)
9
- end
10
-
11
- def testsendByTag
12
- @payload = JPush::PushPayload.build(
13
- platform: JPush::Platform.all,
14
- notification: JPush::Notification.build(
15
- alert: 'alert'),
16
- audience: JPush::Audience.build(
17
- tag: TAG1))
18
- res = @client.sendPush(@payload)
19
- assert(res.isok, message = "")
20
- end
21
-
22
- def testsendByTagAnd
23
- @payload = JPush::PushPayload.build(
24
- platform: JPush::Platform.all,
25
- notification: JPush::Notification.build(
26
- alert: 'alert'),
27
- audience: JPush::Audience.build(
28
- tag_and: TAG1))
29
- res = @client.sendPush(@payload)
30
- assert(res.isok, message = "")
31
- end
32
-
33
- def testsendByAlias
34
- @payload = JPush::PushPayload.build(
35
- platform: JPush::Platform.all,
36
- notification: JPush::Notification.build(
37
- alert: 'alert'),
38
- audience: JPush::Audience.build(
39
- _alias: ALIAS1))
40
- res = @client.sendPush(@payload)
41
- assert_not_nil(res.isok, message = "")
42
- end
43
-
44
- def testsendByRegistrationID
45
- @payload = JPush::PushPayload.build(
46
- platform: JPush::Platform.all,
47
- notification: JPush::Notification.build(
48
- alert: 'alert'),
49
- audience: JPush::Audience.build(
50
- registration_id: REGISTRATION_ID1))
51
- res = @client.sendPush(@payload)
52
- assert(res.isok, message = "")
53
- end
54
-
55
- def testsendByTagMore
56
- @payload = JPush::PushPayload.build(
57
- platform: JPush::Platform.all,
58
- notification: JPush::Notification.build(
59
- alert: 'alert'),
60
- audience: JPush::Audience.build(
61
- tag: TAG2))
62
- res = @client.sendPush(@payload)
63
- assert(res.isok, message = "")
64
- end
65
-
66
- def testsendByTagAndMore
67
- @payload = JPush::PushPayload.build(
68
- platform: JPush::Platform.all,
69
- notification: JPush::Notification.build(
70
- alert: 'alert'),
71
- audience: JPush::Audience.build(
72
- tag_and: TagAndMore))
73
- res = @client.sendPush(@payload)
74
- assert(res.isok, message = "")
75
- end
76
-
77
- def testsendByTagAndMore_fail
78
- @payload = JPush::PushPayload.build(
79
- platform: JPush::Platform.all,
80
- notification: JPush::Notification.build(
81
- alert: 'alert'),
82
- audience: JPush::Audience.build(
83
- tag_and: TAG2))
84
- res = @client.sendPush(@payload)
85
- assert(res.isok, message = "")
86
- end
87
-
88
- def testsendByAliasMore
89
- @payload = JPush::PushPayload.build(
90
- platform: JPush::Platform.all,
91
- notification: JPush::Notification.build(
92
- alert: 'alert'),
93
- audience: JPush::Audience.build(
94
- _alias: ALIAS2))
95
- res = @client.sendPush(@payload)
96
- assert(res.isok, message = "")
97
- end
98
-
99
- def testsendByRegistrationIDMore
100
- @payload = JPush::PushPayload.build(
101
- platform: JPush::Platform.all,
102
- notification: JPush::Notification.build(
103
- alert: 'alert'),
104
- audience: JPush::Audience.build(
105
- registration_id: REGISTRATION_ID2))
106
- res = @client.sendPush(@payload)
107
- assert(res.isok, message = "")
108
- end
109
-
110
- def testsendByTagAlias
111
- @payload = JPush::PushPayload.build(
112
- platform: JPush::Platform.all,
113
- notification: JPush::Notification.build(
114
- alert: 'alert'),
115
- audience: JPush::Audience.build(
116
- tag: TAG_ALL,
117
- _alias: ALIAS1))
118
- res = @client.sendPush(@payload)
119
- assert(res.isok, message = "")
120
- end
121
-
122
- def testsendByTagRegistrationID
123
- @payload = JPush::PushPayload.build(
124
- platform: JPush::Platform.all,
125
- notification: JPush::Notification.build(
126
- alert: 'alert'),
127
- audience: JPush::Audience.build(
128
- registration_id: REGISTRATION_ID1,
129
- tag: TAG_ALL))
130
- res = @client.sendPush(@payload)
131
- assert(res.isok, message = "")
132
- end
133
-
134
- def testsendByTagRegistrationID_0
135
- @payload = JPush::PushPayload.build(
136
- platform: JPush::Platform.all,
137
- notification: JPush::Notification.build(
138
- alert: 'alert'),
139
- audience: JPush::Audience.build(
140
- registration_id: REGISTRATION_ID1,
141
- tag: TAG_NO))
142
- res = @client.sendPush(@payload)
143
- assert(res.isok, message = "")
144
- end
145
-
146
- def testsendByTagAlias_0
147
- @payload = JPush::PushPayload.build(
148
- platform: JPush::Platform.all,
149
- notification: JPush::Notification.build(
150
- alert: 'alert'),
151
- audience: JPush::Audience.build(
152
- tag: TAG3,
153
- _alias: ALIAS1))
154
- res = @client.sendPush(@payload)
155
- assert(res.isok, message = "")
156
- end
157
-
158
- def testsendByTagAlias_0_2
159
- @payload = JPush::PushPayload.build(
160
- platform: JPush::Platform.all,
161
- notification: JPush::Notification.build(
162
- alert: 'alert'),
163
- audience: JPush::Audience.build(
164
- tag: TAG_ALL,
165
- _alias: ALIAS_NO))
166
- res = @client.sendPush(@payload)
167
- assert(res.isok, message = "")
168
- end
169
- end
@@ -1,27 +0,0 @@
1
-
2
- AppKey ="dd1066407b044738b6479275"
3
- MasterSecret = "2b38ce69b1de2a7fa95706ea"
4
-
5
- CONTENT_TYPE_JSON = "application/json"
6
-
7
- SUCCEED_RESULT_CODE = 0
8
- LACK_OF_PARAMS = 1002
9
- INVALID_PARAMS = 1003
10
- AUTHENTICATION_FAIL = 1004
11
- TOO_BIG = 1005
12
- APPKEY_NOT_EXIST = 1008
13
- NO_TARGET = 1011
14
-
15
- ALERT = "JPush Test - alert"
16
- MSG_CONTENT = "JPush Test - msgContent"
17
- TagAndMore = ["tag1", "tag_all"]
18
- TAG1 = ["tag1"]
19
- TAG2 = ["tag1", "tag2"]
20
- TAG3 = ["tag2"]
21
- TAG_ALL = ["tag_all"]
22
- TAG_NO = ["tag_no"]
23
- ALIAS1 = ["alias1"]
24
- ALIAS2 = ["alias1", "alias2"]
25
- ALIAS_NO = ["alias_no"]
26
- REGISTRATION_ID1 = ["0900e8d85ef"]
27
- REGISTRATION_ID2 = ["0900e8d85ef", "0a04ad7d8b4"]
@@ -1,49 +0,0 @@
1
- require 'jpush'
2
-
3
- require './base_remote_tests.rb'
4
-
5
- require 'test/unit'
6
-
7
- class MessageTests < Test::Unit::TestCase
8
- def setup
9
- @client = JPush::JPushClient.new(AppKey, MasterSecret)
10
- end
11
-
12
- def testsendMessageContentOnly
13
- @payload = JPush::PushPayload.build(
14
- audience: JPush::Audience.all,
15
- platform: JPush::Platform.all,
16
- message: JPush::Message.build(
17
- msg_content: MSG_CONTENT))
18
- res = @client.sendPush(@payload)
19
- assert(res.isok, message = "")
20
- end
21
-
22
- def testsendMessageContentAndTitle
23
- @payload = JPush::PushPayload.build(
24
- audience: JPush::Audience.all,
25
- platform: JPush::Platform.all,
26
- message: JPush::Message.build(
27
- msg_content: MSG_CONTENT,
28
- content_type: "content type",
29
- title: "message title"))
30
- res = @client.sendPush(@payload)
31
- assert(res.isok, message = "")
32
- end
33
-
34
- def testsendMessageContentAndExtras
35
- array = {}
36
- array['key1'] = 'value1'
37
- array['key2'] = 'value2'
38
- array['key3'] = 'value3'
39
- @payload = JPush::PushPayload.build(
40
- audience: JPush::Audience.all,
41
- platform: JPush::Platform.all,
42
- message: JPush::Message.build(
43
- msg_content: MSG_CONTENT,
44
- extras: array))
45
- res = @client.sendPush(@payload)
46
- assert(res.isok, message = "")
47
- end
48
-
49
- end