urbanairship 3.2.3 → 3.2.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90725801ea0a0dcd8d3d9dee004e27490f1702af
4
- data.tar.gz: aa29329c6d1e0f8d842470eeae4841a9f5784879
3
+ metadata.gz: 4088c7ba66111c0c9711aecb5147d3b94983b475
4
+ data.tar.gz: d1b98a68f237ee6d2e29855e9ce8ed36f4538947
5
5
  SHA512:
6
- metadata.gz: 45a73240b851d941b6cec9632d3bd3161e1c2c850241c583d0eff2f0b3371fb512c58d795a30c309870ff4cd8c5039e0cafd90651d3f518f5be648ccbcbb972e
7
- data.tar.gz: 73a0470ec770e2d1b96f6d60b0b88c8c1520d7af3c102f206550c66dfd7c08cd378f291afdcfa9181d2696df0f8d50a85a50b499ace632112e23a9ccf3885f52
6
+ metadata.gz: 7159f0a5100b974628d1a0afebd5841250ced0a4f7ecc1d1cc2a53b77acd39601af7041bd0e05df48bb08fd82f186581a32537ec6f66914ffd50cb9211bd1891
7
+ data.tar.gz: 0576569d8278abe88be7f38edbdfbf21048634eae6550a4d1bbfe87ef173ab541028138bcbac9b31a9b7e79c75e86a237a80c64635a2b11661924d0474255028
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ --------------------
2
+ 3.2.4
3
+ --------------------
4
+ - Replace unirest dependency with rest-client
5
+
6
+
1
7
  --------------------
2
8
  3.2.3
3
9
  --------------------
data/README.rst CHANGED
@@ -5,30 +5,40 @@ About
5
5
  =====
6
6
 
7
7
  ``urbanairship`` is a Ruby library for using the `Urban Airship
8
- <http://urbanairship.com/>`_ web service API for push notifications and rich
9
- app pages.
8
+ <http://urbanairship.com/>`_ web service API for push notifications
9
+ and rich app pages.
10
+
10
11
 
11
12
  Requirements
12
13
  ============
13
14
 
14
- As of Version 3.0, a Ruby version >= 2.0 must be used.
15
+ We officially support the following Ruby versions::
16
+
17
+ 2.1.10
18
+ 2.2.5
19
+ 2.3.1
20
+
15
21
 
16
22
  Functionality
17
23
  =============
18
24
 
19
- Version 3.0 is a major upgrade and backwards incompatible with earlier versions.
25
+ Version 3.0 is a major upgrade and backwards incompatible with earlier
26
+ versions.
20
27
 
21
28
  To encourage the use of our SDK, which takes care of proper channel
22
29
  registration, support for device token registration has been removed.
23
- Support for v1 endpoints will also be removed and transitioned to their v3
24
- equivalents where possible.
30
+ Support for v1 endpoints will also be removed and transitioned to their
31
+ v3 equivalents where possible.
25
32
 
26
33
  A more detailed list of changes can be found in the CHANGELOG.
27
34
 
35
+
28
36
  Installation
29
37
  ============
30
38
 
31
- If you have the ``bundler`` gem (if not you can get it with ``$ gem install bundler``) add this line to your application's Gemfile::
39
+ If you have the ``bundler`` gem (if not you can get it with
40
+ ``$ gem install bundler``) add this line to your application's
41
+ Gemfile::
32
42
 
33
43
  >>> gem 'urbanairship'
34
44
 
@@ -40,18 +50,20 @@ OR install it yourself as::
40
50
 
41
51
  >>> gem install urbanairship
42
52
 
53
+
43
54
  Usage
44
55
  =====
45
56
 
46
57
  Once the gem has been installed you can start sending pushes!
47
58
  See the `full documentation
48
- <http://docs.urbanairship.com/reference/libraries/ruby>`_,
59
+ <http://docs.urbanairship.com/reference/libraries/ruby>`_,
49
60
  `api examples
50
61
  <http://docs.urbanairship.com/topic-guides/api-examples.html>`_, as well as the
51
62
  `Urban Airship API Documentation
52
63
  <http://docs.urbanairship.com/api/>`_ for more
53
64
  information.
54
65
 
66
+
55
67
  Broadcast to All Devices
56
68
  ------------------------
57
69
 
@@ -64,8 +76,9 @@ Broadcast to All Devices
64
76
  >>> p.device_types = UA.all
65
77
  >>> p.send_push
66
78
 
79
+
67
80
  Simple Tag Push
68
- -------------------------------------------------
81
+ ---------------
69
82
 
70
83
  >>> require 'urbanairship'
71
84
  >>> UA = Urbanairship
@@ -76,12 +89,14 @@ Simple Tag Push
76
89
  >>> p.device_types = UA.all
77
90
  >>> p.send_push
78
91
 
92
+
79
93
  Questions
80
94
  =========
81
95
 
82
96
  The best place to ask questions is our support site:
83
97
  http://support.urbanairship.com/
84
98
 
99
+
85
100
  Contributing
86
101
  ============
87
102
 
@@ -90,14 +105,18 @@ Contributing
90
105
  3. Commit your changes ``git commit -am 'Add some feature'``
91
106
  4. Push to the branch ``git push origin my-new-feature``
92
107
  5. Create a new Pull Request
93
- 6. Sign Urban Airship's `contribution agreement <http://docs.urbanairship.com/contribution-agreement.html>`_.
108
+ 6. Sign Urban Airship's `contribution agreement
109
+ <http://docs.urbanairship.com/contribution-agreement.html>`_.
110
+
111
+ **Note**: Changes will not be approved and merged without a signed
112
+ contribution agreement.
94
113
 
95
- **Note**: Changes will not be approved and merged without a signed contribution agreement
96
114
 
97
115
  Development
98
116
  ===========
99
117
 
100
- After checking out the repo, ensure you have ``bundler`` installed (``$ gem install bundler``) run::
118
+ After checking out the repo, ensure you have ``bundler`` installed
119
+ (``$ gem install bundler``) run::
101
120
 
102
121
  >>> $ bin/setup
103
122
 
@@ -112,5 +131,6 @@ OR you can build a local gem to play with::
112
131
  >>> $ gem build urbanairship.gemspec
113
132
  >>> $ gem install ./urbanairship-<VERSION>.gem
114
133
 
115
- Having a local build will give you better logging if you are running into issues, but be careful to make sure to use our released
116
- public gem in Production.
134
+ Having a local build will give you better logging if you are running
135
+ into issues, but be careful to make sure to use our released public
136
+ gem in Production.
@@ -195,75 +195,121 @@ single piece of text:
195
195
 
196
196
  .. code-block:: ruby
197
197
 
198
- push.notification = UA.notification(alert="Hello, world!")
198
+ push.notification = UA.notification(alert: "Hello, world!")
199
199
 
200
- You can override the payload with platform-specific values as well.
200
+ You can override the notification payload with one of the following platform
201
+ keys::
202
+
203
+ ios, amazon, android, blackberry, wns, mpns
204
+
205
+ In the examples below, we override the general ``'Hello World!'`` alert with
206
+ platform-specific alerts, and we set a number of other platform-specific options.
207
+
208
+ **Example iOS Override**
201
209
 
202
210
  .. code-block:: ruby
203
211
 
204
- push.notification = UA.ios(
205
- alert: 'hello world',
206
- badge: 123,
207
- sound: 'sound file',
208
- extra: { 'key' => 'value', 'key2' => 'value2' }
209
- expiry: '2012-01-01 12:45',
210
- category: 'category_name',
211
- interactive: UA.interactive(
212
- type: 'ua_share',
213
- button_actions: {
214
- share: { share: 'Sharing is caring!' }
215
- }
216
- ),
217
- content_available: true
212
+ push.notification = UA.notification(
213
+ alert: 'Hello World!',
214
+ ios: UA.ios(
215
+ alert: 'Hello iOS!',
216
+ badge: 123,
217
+ sound: 'sound file',
218
+ extra: { 'key' => 'value', 'key2' => 'value2' }
219
+ expiry: '2012-01-01 12:45',
220
+ category: 'category_name',
221
+ interactive: UA.interactive(
222
+ type: 'ua_share',
223
+ button_actions: {
224
+ share: { share: 'Sharing is caring!' }
225
+ }
226
+ ),
227
+ content_available: true
228
+ )
218
229
  )
219
230
 
220
- push.notification = UA.amazon(
221
- alert: 'hello world',
222
- consolidation_key: 'key',
223
- expires_after: '2012-01-01 12:45',
224
- extra: { 'key' => 'value', 'key2' => 'value2' },
225
- title: 'title',
226
- summary: 'summary',
227
- interactive: UA.interactive(
228
- type: 'ua_share',
229
- button_actions: {
230
- share: { share: 'Sharing is caring!' }
231
- }
231
+ **Example Amazon Override**
232
+
233
+ .. code-block:: ruby
234
+
235
+ push.notification = UA.notification(
236
+ alert: 'Hello World!',
237
+ amazon: UA.amazon(
238
+ alert: 'Hello Amazon!',
239
+ consolidation_key: 'key',
240
+ expires_after: '2012-01-01 12:45',
241
+ extra: { 'key' => 'value', 'key2' => 'value2' },
242
+ title: 'title',
243
+ summary: 'summary',
244
+ interactive: UA.interactive(
245
+ type: 'ua_share',
246
+ button_actions: {
247
+ share: { share: 'Sharing is caring!' }
248
+ }
249
+ )
232
250
  )
233
251
  )
234
252
 
235
- push.notification = UA.android(
236
- alert: 'hello world',
237
- collapse_key: 'key',
238
- time_to_live: 123,
239
- extra: { 'key' => 'value', 'key2' => 'value2' },
240
- delay_while_idle: false,
241
- interactive: UA.interactive(
242
- type: 'ua_share',
243
- button_actions: {
244
- share: { share: 'Sharing is caring!' }
245
- }
253
+ **Example Android Override**
254
+
255
+ .. code-block:: ruby
256
+
257
+ push.notification = UA.notification(
258
+ alert: 'Hello World!',
259
+ android: UA.android(
260
+ alert: 'Hello Android!',
261
+ collapse_key: 'key',
262
+ time_to_live: 123,
263
+ extra: { 'key' => 'value', 'key2' => 'value2' },
264
+ delay_while_idle: false,
265
+ interactive: UA.interactive(
266
+ type: 'ua_share',
267
+ button_actions: {
268
+ share: { share: 'Sharing is caring!' }
269
+ }
270
+ )
246
271
  )
247
272
  )
248
273
 
249
- push.notification = UA.blackberry(
250
- alert: 'hello world',
251
- body: 'body',
252
- content_type: 'text/plain'
274
+ **Example BlackBerry Override**
275
+
276
+ .. code-block:: ruby
277
+
278
+ push.notification = UA.notification(
279
+ alert: 'Hello World!',
280
+ blackberry: UA.blackberry(
281
+ alert: 'Hello BlackBerry!',
282
+ body: 'body',
283
+ content_type: 'text/plain'
284
+ )
253
285
  )
254
286
 
255
- push.notification = UA.wns_payload(
256
- alert: 'hello world',
257
- tile: nil,
258
- toast: nil,
259
- badge: nil
287
+ **Example WNS Override**
288
+
289
+ .. code-block:: ruby
290
+
291
+ push.notification = UA.notification(
292
+ alert: 'Hello World!',
293
+ wns: UA.wns_payload(
294
+ alert: 'Hello WNS!',
295
+ tile: nil,
296
+ toast: nil,
297
+ badge: nil
298
+ )
260
299
  )
261
300
 
262
- push.notification = UA.mpns_payload(
263
- alert: 'hello world',
264
- tile: nil,
265
- toast: nil,
266
- badge: nil
301
+ **Example MPNS Override**
302
+
303
+ .. code-block:: ruby
304
+
305
+ push.notification = UA.notification(
306
+ alert: 'Hello World!',
307
+ mpns: UA.mpns_payload(
308
+ alert: 'Hello MPNS!',
309
+ tile: nil,
310
+ toast: nil,
311
+ badge: nil
312
+ )
267
313
  )
268
314
 
269
315
  .. note::
@@ -311,8 +357,8 @@ Example:
311
357
  .. code-block:: ruby
312
358
 
313
359
  push.notification = UA.notification(
314
- alert="Hello, world!",
315
- interactive=UA.interactive(
360
+ alert: "Hello, world!",
361
+ interactive: UA.interactive(
316
362
  type: "ua_share",
317
363
  button_actions: {
318
364
  share: {share: "Sharing is caring!"}
@@ -324,12 +370,12 @@ Button actions can also be mapped to *actions* objects as shown below:
324
370
 
325
371
  .. code-block:: ruby
326
372
 
327
- shared = ua.actions(share="Sharing is caring!")
373
+ shared = ua.actions(share: "Sharing is caring!")
328
374
  push.notification = ua.notification(
329
- alert="Hello, world!",
330
- interactive=ua.interactive(
331
- type = "ua_share",
332
- button_actions = {
375
+ alert: "Hello, world!",
376
+ interactive: ua.interactive(
377
+ type: "ua_share",
378
+ button_actions: {
333
379
  "share" : shared
334
380
  }
335
381
  )
@@ -1,4 +1,5 @@
1
- require 'unirest'
1
+ require 'json'
2
+ require 'rest-client'
2
3
  require 'urbanairship'
3
4
 
4
5
 
@@ -8,9 +9,6 @@ module Urbanairship
8
9
  include Urbanairship::Common
9
10
  include Urbanairship::Loggable
10
11
 
11
- # set default client timeout to 5 seconds
12
- Unirest.timeout(5)
13
-
14
12
  # Initialize the Client
15
13
  #
16
14
  # @param [Object] key Application Key
@@ -58,21 +56,20 @@ module Urbanairship
58
56
 
59
57
  logger.debug(debug)
60
58
 
61
- response = Unirest.method(req_type).call(
62
- url,
59
+ response = RestClient::Request.execute(
60
+ method: method,
61
+ url: url,
63
62
  headers: headers,
64
- auth:{
65
- :user=>@key,
66
- :password=>@secret
67
- },
68
- parameters: body
63
+ user: @key,
64
+ password: @secret,
65
+ payload: body,
66
+ timeout: 5
69
67
  )
70
68
 
71
69
  logger.debug("Received #{response.code} response. Headers:\n\t#{response.headers}\nBody:\n\t#{response.body}")
72
-
73
70
  Response.check_code(response.code, response)
74
71
 
75
- {'body'=>response.body, 'code'=>response.code, 'headers'=>response.headers}
72
+ self.class.build_response(response)
76
73
  end
77
74
 
78
75
  # Create a Push Object
@@ -88,5 +85,26 @@ module Urbanairship
88
85
  def create_scheduled_push
89
86
  Push::ScheduledPush.new(self)
90
87
  end
88
+
89
+ # Build a hash from the response object
90
+ #
91
+ # @return [Hash] The response body.
92
+ def self.build_response(response)
93
+ response_hash = {'code'=>response.code.to_s, 'headers'=>response.headers}
94
+
95
+ begin
96
+ body = JSON.parse(response.body)
97
+ rescue JSON::ParserError
98
+ if response.body.nil? || response.body.empty?
99
+ body = {}
100
+ else
101
+ body = response.body
102
+ response_hash['error'] = 'could not parse response JSON'
103
+ end
104
+ end
105
+
106
+ response_hash['body'] = body
107
+ response_hash
108
+ end
91
109
  end
92
110
  end
@@ -1,3 +1,3 @@
1
1
  module Urbanairship
2
- VERSION = '3.2.3'
2
+ VERSION = '3.2.4'
3
3
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ['lib']
29
29
 
30
- spec.add_runtime_dependency 'unirest', '~> 1.1', '>= 1.1.2'
30
+ spec.add_runtime_dependency 'rest-client', '>= 1.4', '< 4.0'
31
31
 
32
32
  spec.add_development_dependency 'bundler', '~> 1'
33
33
  spec.add_development_dependency 'guard-rspec'
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanairship
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urban Airship
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-16 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: unirest
14
+ name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.1'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 1.1.2
19
+ version: '1.4'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '1.1'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
- version: 1.1.2
29
+ version: '1.4'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  requirements: []
190
190
  rubyforge_project:
191
- rubygems_version: 2.4.5.1
191
+ rubygems_version: 2.5.1
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: Ruby Gem for using the Urban Airship API