urbanairship 3.2.4 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4088c7ba66111c0c9711aecb5147d3b94983b475
4
- data.tar.gz: d1b98a68f237ee6d2e29855e9ce8ed36f4538947
3
+ metadata.gz: 692d6774c618680475e856b748d6565f38278c2a
4
+ data.tar.gz: 44cbb4e3aa1adf9382a9616fc540b675591e71a1
5
5
  SHA512:
6
- metadata.gz: 7159f0a5100b974628d1a0afebd5841250ced0a4f7ecc1d1cc2a53b77acd39601af7041bd0e05df48bb08fd82f186581a32537ec6f66914ffd50cb9211bd1891
7
- data.tar.gz: 0576569d8278abe88be7f38edbdfbf21048634eae6550a4d1bbfe87ef173ab541028138bcbac9b31a9b7e79c75e86a237a80c64635a2b11661924d0474255028
6
+ metadata.gz: e354ef63c9665715631ec9647692c8148aea180dedb43159afdd041da68e5e1a206158fee15ac4ba589f1c0e90cbf389f3270e4b94ddd3710fb3f01bd276116c
7
+ data.tar.gz: 1d77961f636470f64cc8372d08b56adaeab8b4ffa5607e1825e007c5ad6c3700dc48a405a923510f8cc7c3455a9db2d15f340a38dd0e8f9e48095ae6b49324e4
@@ -0,0 +1,11 @@
1
+ # Contribution Agreement
2
+
3
+ ## What is the Contributor License Agreement, and what does it mean?
4
+
5
+ The Contributor License Agreement (CLA) below is to ensure that when someone contributes code to one of our open source libraries that we have a clear record of the license to use it. This is necessary so that we can ensure to all of our customers that they can make use of our libraries and tools without worry. You retain copyright of all of your code.
6
+
7
+ Please read through the agreement at the URL below.
8
+
9
+ If you have questions about this agreement or why we need it please contact us at https://support.urbanairship.com/.
10
+
11
+ [Contribution Agreement](https://docs.urbanairship.com/contribution-agreement/)
@@ -0,0 +1,33 @@
1
+ We only accept issues for bug reporting purposes.
2
+
3
+ **All feature requests, implementation concerns or general queries should be sent to our [support team](https://support.urbanairship.com/).**
4
+
5
+ Before completing the form below, please check the following:
6
+
7
+ - [ ] You are using the most recent version of the library.
8
+ - [ ] You are using a supported version of Ruby for that library version.
9
+ - [ ] This issue is reproducible.
10
+
11
+ ## Expected Behavior
12
+ <!--- Tell us what should happen -->
13
+
14
+ ## Current Behavior
15
+ <!--- Tell us what happens instead of the expected behavior -->
16
+
17
+ ## Possible Solution
18
+ <!--- Not required, but gives us a place to begin investigating -->
19
+
20
+ ## Steps to Reproduce
21
+ <!--- Provide a link to a live example, or an unambiguous set of steps to -->
22
+ <!--- reproduce this bug. Include your implementation code if possible and relevant -->
23
+ 1.
24
+ 2.
25
+ 3.
26
+ 4.
27
+
28
+ ## Detailed Description
29
+ <!--- Provide a detailed description. If possible full logs showing the behavior.-->
30
+
31
+ ## Possible Fix
32
+ <!--- Not required, but suggest your possible solution if possible. -->
33
+ <!-- If your fix is known to work, we accept pull requests with a completed contribution agreement. -->
@@ -0,0 +1,21 @@
1
+ ### What does this do and why?
2
+ Please include link to open issue if applicable.
3
+
4
+ ### Additional notes for reviewers
5
+ * If applicable
6
+
7
+ ### Testing
8
+ - [ ] I wrote tests covering these changes
9
+
10
+ * I've tested for Ruby versions:
11
+
12
+ - [ ] 2.2.5
13
+ - [ ] 2.3.1
14
+
15
+ ### Urban Airship Contribution Agreement
16
+ https://docs.urbanairship.com/contribution-agreement/
17
+
18
+ - [ ] I've filled out and signed UA's contribution agreement form.
19
+
20
+ ### Screenshots
21
+ * If applicable
@@ -0,0 +1,10 @@
1
+ # Support Requests
2
+
3
+ All requests for support including implementation support and feature requests are made to the Urban Airship support team.
4
+
5
+ You can contact them by visiting https://support.urbanairship.com/
6
+
7
+ # Documentation
8
+
9
+ Documentation for the library can be found here:
10
+ https://docs.urbanairship.com/reference/libraries/ruby/
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
 
13
13
  # App
14
14
  urbanairship.log
15
+ .DS_Store
data/.travis.yml CHANGED
@@ -1,6 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1
4
- - 2.2.1
5
- - 2.2.2
6
- script: bundle exec rspec
3
+ - 2.2.5
4
+ - 2.3.1
data/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
1
+ --------------------
2
+ 4.0.0
3
+ --------------------
4
+ - Added support for in-app messages
5
+ - Added support for iOS priority
6
+ - Added config class, allowing you to define log level and log location
7
+ - Added templates for Github pull requests and issues, contribution information
8
+ - Fixed ability to create a new scheduled push from an existing scheduled push URL
9
+ - Various docs and tests fixes
10
+ - Removed support for Blackberry and MPNS platforms
11
+ - Removed support for per-push reports
12
+
13
+
1
14
  --------------------
2
15
  3.2.4
3
16
  --------------------
data/README.rst CHANGED
@@ -14,23 +14,16 @@ Requirements
14
14
 
15
15
  We officially support the following Ruby versions::
16
16
 
17
- 2.1.10
18
17
  2.2.5
19
18
  2.3.1
20
19
 
20
+ Newer versions should work as well.
21
+
21
22
 
22
23
  Functionality
23
24
  =============
24
25
 
25
- Version 3.0 is a major upgrade and backwards incompatible with earlier
26
- versions.
27
-
28
- To encourage the use of our SDK, which takes care of proper channel
29
- registration, support for device token registration has been removed.
30
- Support for v1 endpoints will also be removed and transitioned to their
31
- v3 equivalents where possible.
32
-
33
- A more detailed list of changes can be found in the CHANGELOG.
26
+ Version 4.0 is a major upgrade, as some features have been removed that were present in earlier versions. A more detailed list of changes can be found in the CHANGELOG.
34
27
 
35
28
 
36
29
  Installation
@@ -51,6 +44,25 @@ OR install it yourself as::
51
44
  >>> gem install urbanairship
52
45
 
53
46
 
47
+ Configuration
48
+ =============
49
+
50
+ In your app initialization, you can do something like the following:
51
+
52
+ >>> require 'urbanairship'
53
+ >>> Urbanairship.configure do |config|
54
+ >>> config.log_path = '/path/to/your/logfile'
55
+ >>> config.log_level = Logger::WARN
56
+ >>> end
57
+
58
+
59
+ Available Configurations
60
+ ------------------------
61
+
62
+ - **log_path**: Allows to define the folder where the log file will be created (the default is nil).
63
+ - **log_level**: Allows to define the log level and only messages at that level or higher will be printed (the default is INFO).
64
+
65
+
54
66
  Usage
55
67
  =====
56
68
 
data/docs/devices.rst CHANGED
@@ -138,78 +138,3 @@ that have been iterated over by using the ``count`` method.
138
138
  puts(apid)
139
139
  end
140
140
  puts(apid_list.count)
141
-
142
-
143
- Blackberry PIN Register
144
- -----------------------
145
-
146
- Register a PIN with the application. This will mark the PIN as active in
147
- the system. You can also set up an alias and tags for the pin.
148
-
149
- .. code-block:: ruby
150
-
151
- require 'urbanairship'
152
-
153
- UA = Urbanairship
154
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
155
- device_pin = UA::DevicePin.new(client: airship)
156
- resp = device_pin.register(pin: '12345678', pin_alias: nil, tags: nil)
157
- puts(resp)
158
-
159
- .. note::
160
- ``pin_alias`` and ``tags`` are optional parameters for this command.
161
- If no ``pin_alias`` is provided, any existing alias will be removed from the device
162
- record. To empty the tag set, send an empty array of tags. If the tags
163
- array is missing from the request, the tags will not be modified.
164
-
165
-
166
- Blackberry PIN Lookup
167
- ---------------------
168
-
169
- Get information on a particular BlackBerry PIN:
170
-
171
- .. code-block:: ruby
172
-
173
- require 'urbanairship'
174
-
175
- UA = Urbanairship
176
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
177
- device_pin = UA::DevicePin.new(client: airship)
178
- resp = device_pin.lookup(pin: 'device_pin')
179
- puts(resp)
180
-
181
-
182
- Blackberry PIN Deactivate
183
- -------------------------
184
-
185
- Deactive a Blackberry pin for the application.
186
-
187
- .. code-block:: ruby
188
-
189
- require 'urbanairship'
190
-
191
- UA = Urbanairship
192
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
193
- device_pin = UA::DevicePin.new(client: airship)
194
- resp = device_pin.deactivate(pin: 'device_pin')
195
- puts(resp)
196
-
197
-
198
- Blackberry PIN List
199
- -------------------
200
-
201
- Get a list of all Blackberry PINs registered to the application. After you
202
- have iterated over the list, you can get the total count of PINs by using the
203
- ``count`` method.
204
-
205
- .. code-block:: ruby
206
-
207
- require 'urbanairship'
208
-
209
- UA = Urbanairship
210
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
211
- device_pin_list = UA::DevicePinList.new(client: airship)
212
- device_pin_list.each do |pin|
213
- puts(pin)
214
- end
215
- puts(device_pin_list.count)
data/docs/push.rst CHANGED
@@ -65,12 +65,6 @@ Select a single iOS device token:
65
65
 
66
66
  push.audience = UA.device_token(token)
67
67
 
68
- Select a single BlackBerry PIN:
69
-
70
- .. code-block:: ruby
71
-
72
- push.audience = UA.device_pin(pin)
73
-
74
68
  Select a single Android APID:
75
69
 
76
70
  .. code-block:: ruby
@@ -83,12 +77,6 @@ Select a single Windows 8 APID:
83
77
 
84
78
  push.audience = UA.wns(uuid)
85
79
 
86
- Select a single Windows Phone 8 APID:
87
-
88
- .. code-block:: ruby
89
-
90
- push.audience = UA.mpns(uuid)
91
-
92
80
  Select a single tag:
93
81
 
94
82
  .. code-block:: ruby
@@ -200,7 +188,7 @@ single piece of text:
200
188
  You can override the notification payload with one of the following platform
201
189
  keys::
202
190
 
203
- ios, amazon, android, blackberry, wns, mpns
191
+ ios, amazon, android, wns
204
192
 
205
193
  In the examples below, we override the general ``'Hello World!'`` alert with
206
194
  platform-specific alerts, and we set a number of other platform-specific options.
@@ -215,8 +203,8 @@ platform-specific alerts, and we set a number of other platform-specific options
215
203
  alert: 'Hello iOS!',
216
204
  badge: 123,
217
205
  sound: 'sound file',
218
- extra: { 'key' => 'value', 'key2' => 'value2' }
219
- expiry: '2012-01-01 12:45',
206
+ extra: { 'key' => 'value', 'key2' => 'value2' },
207
+ expiry: '2012-01-01 12:45:00',
220
208
  category: 'category_name',
221
209
  interactive: UA.interactive(
222
210
  type: 'ua_share',
@@ -224,6 +212,7 @@ platform-specific alerts, and we set a number of other platform-specific options
224
212
  share: { share: 'Sharing is caring!' }
225
213
  }
226
214
  ),
215
+ priority: 5,
227
216
  content_available: true
228
217
  )
229
218
  )
@@ -237,7 +226,7 @@ platform-specific alerts, and we set a number of other platform-specific options
237
226
  amazon: UA.amazon(
238
227
  alert: 'Hello Amazon!',
239
228
  consolidation_key: 'key',
240
- expires_after: '2012-01-01 12:45',
229
+ expires_after: '2012-01-01 12:45:00',
241
230
  extra: { 'key' => 'value', 'key2' => 'value2' },
242
231
  title: 'title',
243
232
  summary: 'summary',
@@ -271,19 +260,6 @@ platform-specific alerts, and we set a number of other platform-specific options
271
260
  )
272
261
  )
273
262
 
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
- )
285
- )
286
-
287
263
  **Example WNS Override**
288
264
 
289
265
  .. code-block:: ruby
@@ -298,26 +274,11 @@ platform-specific alerts, and we set a number of other platform-specific options
298
274
  )
299
275
  )
300
276
 
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
- )
313
- )
314
277
 
315
278
  .. note::
316
279
  The input for wns_payload must include exactly one of
317
280
  alert, toast, tile, or badge.
318
281
 
319
- The input for mpns_payload must include exactly one of
320
- alert, toast, or tile.
321
282
 
322
283
  Actions
323
284
  -------
@@ -337,7 +298,7 @@ http://docs.urbanairship.com/api/ua.html#actions, example:
337
298
  share: 'Check out Urban Airship!',
338
299
  open_: {
339
300
  type: 'url',
340
- content: 'http://www.urbanairship.com'
301
+ content: 'http://www.example.com'
341
302
  },
342
303
  app_defined: {
343
304
  some_app_defined_action: 'some_values'
@@ -390,7 +351,7 @@ types you wish to target with a list of strings:
390
351
 
391
352
  .. code-block:: ruby
392
353
 
393
- push.device_types = UA.device_types(['ios', 'blackberry'])
354
+ push.device_types = UA.device_types(['ios', 'android'])
394
355
 
395
356
  or with the ``all`` shortcut.
396
357
 
@@ -465,7 +426,7 @@ notification, you can update or cancel it before it's sent.
465
426
 
466
427
  .. code-block:: ruby
467
428
 
468
- schedule = UA.ScheduledPush.from_url(airship, url)
429
+ schedule = UA::ScheduledPush.from_url(client: airship, url: 'http://www.example.com')
469
430
  # change scheduled time to tomorrow
470
431
  schedule.schedule = UA.scheduled_time(Time.now.utc + (60 * 60 * 24))
471
432
  schedule.update
data/docs/reports.rst CHANGED
@@ -63,82 +63,6 @@ For more information, see `the API documentation on push reports
63
63
 
64
64
  precision needs to be a member of ['HOURLY', 'DAILY', 'MONTHLY']
65
65
 
66
- .. Hiding the perpush endpoints for now per GAG-705 (until rate limiting is in place)
67
-
68
- Per Push Reporting
69
- ==================
70
-
71
- Retrieve data specific to the performance of an individual push.
72
- For more information, see `the API documentationa on per push
73
- reporting
74
- <http://docs.urbanairship.com/api/ua.html#per-push-reporting>`_
75
-
76
- ---------------
77
- Per Push Detail
78
- ---------------
79
-
80
-
81
- Single Request
82
- --------------
83
-
84
- Get the analytics detail for a specific Push ID. For more information, see `the
85
- API documentation on single requests
86
- <http://docs.urbanairship.com/api/ua.html#single-request>`_
87
-
88
- .. code-block:: ruby
89
-
90
- require 'urbanairship'
91
- UA = Urbanairship
92
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
93
- d = UA::PerPushDetail.new(client: airship)
94
- details = d.get_single(push_id:'push_id')
95
-
96
-
97
- Batch Request
98
- -------------
99
-
100
- Get the analytics details for an array of Push IDs. For more information,
101
- see `the API documentation on batch requests <http://docs.urbanairship.com/api/ua.html#batch-request>`_
102
-
103
- .. code-block:: ruby
104
-
105
- require 'urbanairship'
106
- UA = Urbanairship
107
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
108
- d = UA::PerPushDetail.new(client: airship)
109
- details = d.get_batch(push_ids: ['push_id', 'push_id2', 'push_id3'])
110
-
111
- .. note::
112
-
113
- There is a maximum of 100 Push IDs per request
114
-
115
- ---------------
116
- Per Push Series
117
- ---------------
118
-
119
- Get the default time series data. For more information,
120
- see `the API documentation on per push series
121
- <http://docs.urbanairship.com/api/ua.html#per-push-series>`_
122
-
123
- .. code-block:: ruby
124
-
125
- require 'urbanairship'
126
- UA = Urbanairship
127
- airship = UA::Client.new(key:'application_key', secret:'master_secret')
128
- s = UA::PerPushSeries.new(client: airship)
129
- series = s.get(
130
- push_id: 'push_id',
131
- precision: 'HOURLY',
132
- start_date: '2015-06-01',
133
- end_date: '2015-08-01'
134
- )
135
-
136
- .. note::
137
-
138
- precision, start_date, and end_date are optional parameters. However, if specifying
139
- a date range, precision, start_date and end_date must all be specified. Precision
140
- can be specified without start_date and end_date but must be a member of
141
- ['HOURLY', 'DAILY', 'MONTHLY'].
142
66
 
143
67
  Response Report
144
68
  ===============
data/example/pusher.rb ADDED
@@ -0,0 +1,21 @@
1
+ class Pusher
2
+
3
+ require 'urbanairship'
4
+ UA = Urbanairship
5
+
6
+ def send_message
7
+ airship = UA::Client.new(key:'app_key', secret:'master_secret')
8
+ p = airship.create_push
9
+ p.audience = UA.all
10
+ p.notification = UA.notification(alert: 'Hello')
11
+ p.device_types = UA.all
12
+ p.in_app = UA.in_app(
13
+ alert: 'This is a test message!',
14
+ display_type: 'banner'
15
+ )
16
+ p.send_push
17
+ end
18
+
19
+ end
20
+
21
+ Pusher.new.send_message
data/lib/urbanairship.rb CHANGED
@@ -6,13 +6,13 @@ require 'urbanairship/devices/segment'
6
6
  require 'urbanairship/devices/channel_uninstall'
7
7
  require 'urbanairship/client'
8
8
  require 'urbanairship/common'
9
+ require 'urbanairship/configuration'
9
10
  require 'urbanairship/loggable'
10
11
  require 'urbanairship/util'
11
12
  require 'urbanairship/version'
12
13
  require 'urbanairship/devices/devicelist'
13
14
  require 'urbanairship/devices/channel_tags'
14
15
  require 'urbanairship/devices/named_user'
15
- require 'urbanairship/reports/per_push'
16
16
  require 'urbanairship/reports/response_statistics'
17
17
  require 'urbanairship/devices/static_lists'
18
18
  require 'urbanairship/push/location'
@@ -25,4 +25,16 @@ module Urbanairship
25
25
  include Urbanairship::Devices
26
26
  include Urbanairship::Reports
27
27
  include Urbanairship::Push
28
+
29
+ class << self
30
+ attr_accessor :configuration
31
+
32
+ def configuration
33
+ @configuration ||= Configuration.new
34
+ end
35
+
36
+ def configure
37
+ yield(configuration)
38
+ end
39
+ end
28
40
  end
@@ -9,7 +9,6 @@ module Urbanairship
9
9
  CHANNEL_URL = BASE_URL + '/channels/'
10
10
  DEVICE_TOKEN_URL = BASE_URL + '/device_tokens/'
11
11
  APID_URL = BASE_URL + '/apids/'
12
- DEVICE_PIN_URL = BASE_URL + '/device_pins/'
13
12
  PUSH_URL = BASE_URL + '/push/'
14
13
  DT_FEEDBACK_URL = BASE_URL + '/device_tokens/feedback/'
15
14
  APID_FEEDBACK_URL = BASE_URL + '/apids/feedback/'
@@ -0,0 +1,10 @@
1
+ module Urbanairship
2
+ class Configuration
3
+ attr_accessor :log_path, :log_level
4
+
5
+ def initialize
6
+ @log_path = nil
7
+ @log_level = Logger::INFO
8
+ end
9
+ end
10
+ end
@@ -125,58 +125,5 @@ module Urbanairship
125
125
  @data_attribute = 'apids'
126
126
  end
127
127
  end
128
-
129
- class DevicePin
130
- include Urbanairship::Common
131
- include Urbanairship::Loggable
132
-
133
- def initialize(client: required('client'))
134
- @client = client
135
- end
136
-
137
- def lookup(pin: required('pin'))
138
- fail ArgumentError, 'Device pin must be an 8 digit hex string' if pin[/\H/] or pin.length != 8
139
- resp = @client.send_request(
140
- method: 'GET',
141
- url: DEVICE_PIN_URL + pin
142
- )
143
- logger.info("Retrieved info on device pin #{pin}")
144
- resp
145
- end
146
-
147
- def register(pin: required('pin'), pin_alias: nil, tags: nil)
148
- fail ArgumentError, 'Device pin must be an 8 digit hex string' if pin[/\H/] or pin.length != 8
149
- payload = {}
150
- payload['alias'] = pin_alias unless pin_alias.nil?
151
- payload['tags'] = tags unless tags.nil?
152
-
153
- resp = @client.send_request(
154
- method: 'PUT',
155
- url: DEVICE_PIN_URL + pin,
156
- body: JSON.dump(payload),
157
- content_type: 'application/json'
158
- )
159
- logger.info("Registered device pin #{pin}")
160
- resp
161
- end
162
-
163
- def deactivate(pin: required('pin'))
164
- fail ArgumentError, 'Device pin must be an 8 digit hex string' if pin[/\H/] or pin.length != 8
165
- resp = @client.send_request(
166
- method: 'DELETE',
167
- url: DEVICE_PIN_URL + pin
168
- )
169
- logger.info("Deactivated device pin #{pin}")
170
- resp
171
- end
172
- end
173
-
174
- class DevicePinList < Urbanairship::Common::PageIterator
175
- def initialize(client: required('client'))
176
- super(client: client)
177
- @next_page = DEVICE_PIN_URL
178
- @data_attribute = 'device_pins'
179
- end
180
- end
181
128
  end
182
129
  end
@@ -13,9 +13,11 @@ module Urbanairship
13
13
  end
14
14
 
15
15
  def self.create_logger
16
- logger = Logger.new('urbanairship.log')
16
+ log_uri = [Urbanairship.configuration.log_path, 'urbanairship.log'].compact
17
+ logger = Logger.new(File.join(*log_uri))
17
18
  logger.datetime_format = '%Y-%m-%d %H:%M:%S'
18
19
  logger.progname = 'Urbanairship'
20
+ logger.level = Urbanairship.configuration.log_level
19
21
  logger
20
22
  end
21
23
  end
@@ -8,7 +8,6 @@ module Urbanairship
8
8
  include Urbanairship::Common
9
9
  UUID_PATTERN = /^\h{8}-\h{4}-\h{4}-\h{4}-\h{12}$/
10
10
  DEVICE_TOKEN_PATTERN = /^\h{64}$/
11
- DEVICE_PIN_PATTERN = /^\h{8}$/
12
11
  DATE_TERMS = %i(minutes hours days weeks months years)
13
12
 
14
13
 
@@ -18,7 +17,7 @@ module Urbanairship
18
17
  # @example
19
18
  # ios_channel(<channel>) # ==>
20
19
  # {:ios_channel=>"<channel>"}
21
- %w(ios_channel android_channel amazon_channel apid wns mpns).each do |name|
20
+ %w(ios_channel android_channel amazon_channel apid wns).each do |name|
22
21
  define_method(name) do |uuid|
23
22
  { name.to_sym => cleanup(uuid) }
24
23
  end
@@ -30,12 +29,6 @@ module Urbanairship
30
29
  { device_token: token.upcase.strip }
31
30
  end
32
31
 
33
- # Select a single BlackBerry PIN
34
- def device_pin(pin)
35
- Util.validate(pin, 'pin', DEVICE_PIN_PATTERN)
36
- { device_pin: pin.downcase.strip }
37
- end
38
-
39
32
  # Select a single tag
40
33
  def tag(tag, group: nil)
41
34
  tag_params = { tag: tag }
@@ -7,17 +7,14 @@ module Urbanairship
7
7
 
8
8
  # Notification Object for a Push Payload
9
9
  def notification(alert: nil, ios: nil, android: nil, amazon: nil,
10
- blackberry: nil, wns: nil, mpns: nil, actions: nil,
11
- interactive: nil)
10
+ wns: nil, actions: nil, interactive: nil)
12
11
  payload = compact_helper({
13
12
  alert: alert,
14
13
  actions: actions,
15
14
  ios: ios,
16
15
  android: android,
17
16
  amazon: amazon,
18
- blackberry: blackberry,
19
17
  wns: wns,
20
- mpns: mpns,
21
18
  interactive: interactive
22
19
  })
23
20
  fail ArgumentError, 'Notification body is empty' if payload.empty?
@@ -26,7 +23,7 @@ module Urbanairship
26
23
 
27
24
  # iOS specific portion of Push Notification Object
28
25
  def ios(alert: nil, badge: nil, sound: nil, extra: nil, expiry: nil,
29
- category: nil, interactive: nil, content_available: nil)
26
+ category: nil, interactive: nil, content_available: nil, priority: nil)
30
27
  compact_helper({
31
28
  alert: alert,
32
29
  badge: badge,
@@ -35,7 +32,8 @@ module Urbanairship
35
32
  expiry: expiry,
36
33
  category: category,
37
34
  interactive: interactive,
38
- 'content-available' => content_available
35
+ 'content-available' => content_available,
36
+ priority: priority
39
37
  })
40
38
  end
41
39
 
@@ -66,11 +64,6 @@ module Urbanairship
66
64
  })
67
65
  end
68
66
 
69
- # BlackBerry specific portion of Push Notification Object
70
- def blackberry(alert: nil, body: nil, content_type: 'text/plain')
71
- { body: alert || body, content_type: content_type }
72
- end
73
-
74
67
  # WNS specific portion of Push Notification Object
75
68
  def wns_payload(alert: nil, toast: nil, tile: nil, badge: nil)
76
69
  payload = compact_helper({
@@ -83,17 +76,6 @@ module Urbanairship
83
76
  payload
84
77
  end
85
78
 
86
- # MPNS specific portion of Push Notification Object
87
- def mpns_payload(alert: nil, toast: nil, tile: nil)
88
- payload = compact_helper({
89
- alert: alert,
90
- toast: toast,
91
- tile: tile
92
- })
93
- fail ArgumentError, 'Must specify one message type' if payload.size != 1
94
- payload
95
- end
96
-
97
79
  # Rich Message specific portion of Push Notification Object
98
80
  def message(title: required('title'), body: required('body'), content_type: nil, content_encoding: nil,
99
81
  extra: nil, expiry: nil, icons: nil, options: nil)
@@ -109,6 +91,20 @@ module Urbanairship
109
91
  })
110
92
  end
111
93
 
94
+ # In-app message specific portion of Push Notification Object
95
+ def in_app(alert: nil, display_type: nil, display: nil, expiry: nil,
96
+ actions: nil, interactive: nil, extra: nil)
97
+ compact_helper({
98
+ alert: alert,
99
+ display_type: display_type,
100
+ display: display,
101
+ expiry: expiry,
102
+ actions: actions,
103
+ interactive: interactive,
104
+ extra: extra
105
+ })
106
+ end
107
+
112
108
  # Interactive Notification portion of Push Notification Object
113
109
  def interactive(type: required('type'), button_actions: nil)
114
110
  fail ArgumentError, 'type must not be nil' if type.nil?
@@ -9,7 +9,7 @@ module Urbanairship
9
9
  # A Push Notification.
10
10
  class Push
11
11
  attr_writer :client, :audience, :notification, :options,
12
- :device_types, :message
12
+ :device_types, :message, :in_app
13
13
  attr_reader :device_types, :audience
14
14
  include Urbanairship::Common
15
15
  include Urbanairship::Loggable
@@ -27,7 +27,8 @@ module Urbanairship
27
27
  notification: @notification,
28
28
  options: @options,
29
29
  device_types: @device_types,
30
- message: @message
30
+ message: @message,
31
+ in_app: @in_app
31
32
  })
32
33
  end
33
34
 
@@ -91,29 +92,29 @@ module Urbanairship
91
92
  pr
92
93
  end
93
94
 
94
- # Build a Scheduled Push Notification object its existing Scheduled Push URL
95
+ # Build a Scheduled Push Notification object from its existing Scheduled Push URL
95
96
  #
96
97
  # @param [Object] client The Client
97
98
  # @param [Object] url The existing Scheduled Push URL
98
99
  # @return [Object] Scheduled Push Object
99
100
  def self.from_url(client: required('client'), url: required('url'))
100
101
  scheduled_push = ScheduledPush.new(client)
101
- response_body = client.send_request(
102
+ response_payload = client.send_request(
102
103
  method: 'GET',
103
104
  body: nil,
104
105
  url: url
105
106
  )
106
- payload = JSON.load(response_body)
107
+ payload = JSON.load(response_payload.to_json)
107
108
 
108
109
  p = Push.new(client)
109
- p.audience = payload['push']['audience']
110
- p.notification = payload['push']['notification']
111
- p.device_types = payload['push']['device_types']
112
- p.message = payload['push']['message']
113
- p.options = payload['push']['options']
114
-
115
- scheduled_push.name = payload['name']
116
- scheduled_push.schedule = payload['schedule']
110
+ p.audience = payload['body']['push']['audience']
111
+ p.notification = payload['body']['push']['notification']
112
+ p.device_types = payload['body']['push']['device_types']
113
+ p.message = payload['body']['push']['message']
114
+ p.options = payload['body']['push']['options']
115
+
116
+ scheduled_push.name = payload['body']['name']
117
+ scheduled_push.schedule = payload['body']['schedule']
117
118
  scheduled_push.push = p
118
119
  scheduled_push.url = url
119
120
  scheduled_push
@@ -1,3 +1,3 @@
1
1
  module Urbanairship
2
- VERSION = '3.2.4'
2
+ VERSION = '4.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanairship
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 4.0.0
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-10-24 00:00:00.000000000 Z
11
+ date: 2017-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -122,6 +122,10 @@ executables: []
122
122
  extensions: []
123
123
  extra_rdoc_files: []
124
124
  files:
125
+ - ".github/CONTRIBUTING.md"
126
+ - ".github/ISSUE_TEMPLATE.md"
127
+ - ".github/PULL_REQUEST_TEMPLATE.md"
128
+ - ".github/SUPPORT.md"
125
129
  - ".gitignore"
126
130
  - ".rspec"
127
131
  - ".travis.yml"
@@ -147,9 +151,11 @@ files:
147
151
  - docs/segment.rst
148
152
  - docs/static_lists.rst
149
153
  - docs/tags.rst
154
+ - example/pusher.rb
150
155
  - lib/urbanairship.rb
151
156
  - lib/urbanairship/client.rb
152
157
  - lib/urbanairship/common.rb
158
+ - lib/urbanairship/configuration.rb
153
159
  - lib/urbanairship/devices/channel_tags.rb
154
160
  - lib/urbanairship/devices/channel_uninstall.rb
155
161
  - lib/urbanairship/devices/devicelist.rb
@@ -162,7 +168,6 @@ files:
162
168
  - lib/urbanairship/push/payload.rb
163
169
  - lib/urbanairship/push/push.rb
164
170
  - lib/urbanairship/push/schedule.rb
165
- - lib/urbanairship/reports/per_push.rb
166
171
  - lib/urbanairship/reports/response_statistics.rb
167
172
  - lib/urbanairship/util.rb
168
173
  - lib/urbanairship/version.rb
@@ -188,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
193
  version: '0'
189
194
  requirements: []
190
195
  rubyforge_project:
191
- rubygems_version: 2.5.1
196
+ rubygems_version: 2.5.2.1
192
197
  signing_key:
193
198
  specification_version: 4
194
199
  summary: Ruby Gem for using the Urban Airship API
@@ -1,97 +0,0 @@
1
- require 'urbanairship'
2
- require 'time'
3
-
4
-
5
- module Urbanairship
6
- module Reports
7
- class PerPushDetail
8
- include Urbanairship::Common
9
- include Urbanairship::Loggable
10
-
11
- def initialize(client: required('client'))
12
- @client = client
13
- end
14
-
15
- def get_single(push_id: required('push_id'))
16
- fail ArgumentError,
17
- 'push_id cannot be empty' if push_id.nil?
18
- url = REPORTS_URL + 'perpush/detail/' + push_id
19
- response = @client.send_request(
20
- method: 'GET',
21
- url: url
22
- )
23
- logger.info("Requested per-push details for #{push_id}")
24
- response
25
- end
26
-
27
- def get_batch(push_ids: required('push_ids'))
28
- fail ArgumentError,
29
- 'push_ids must be an array' unless push_ids.kind_of?(Array)
30
- fail ArgumentError,
31
- 'push_ids cannot be empty' if push_ids.empty?
32
- fail ArgumentError,
33
- 'push_ids cannot contain more than 100 IDs' if push_ids.count > 100
34
-
35
- response = @client.send_request(
36
- method: 'POST',
37
- body: JSON.dump('push_ids' => push_ids),
38
- url: REPORTS_URL + 'perpush/detail/',
39
- content_type: 'application/json'
40
- )
41
- logger.info("Requested info for push ids: #{push_ids}")
42
- response
43
- end
44
- end
45
-
46
- class PerPushSeries
47
- include Urbanairship::Common
48
- include Urbanairship::Loggable
49
-
50
- def initialize(client: required)
51
- @client = client
52
- end
53
-
54
- def get(push_id: required('push_id'), precision:nil, start_date:nil, end_date:nil)
55
- fail ArgumentError,
56
- 'push_id cannot be empty' if push_id.nil?
57
- url = REPORTS_URL + 'perpush/series/' + push_id
58
-
59
- if precision
60
- precision_array = %w(HOURLY DAILY MONTHLY)
61
- fail ArgumentError,
62
- "Precision must be 'HOURLY', 'DAILY', or 'MONTHLY'" unless precision_array.include?(precision)
63
- url += '?precision=' + precision
64
- end
65
-
66
- if start_date
67
- fail ArgumentError,
68
- 'Precision must be included with start date' if precision.nil?
69
- start_parsed = nil
70
- end_parsed = nil
71
-
72
- begin
73
- start_parsed = Time.parse(start_date)
74
- end_parsed = Time.parse(end_date) unless end_date.nil?
75
- rescue ArgumentError
76
- fail ArgumentError,
77
- 'start_date and end_date must be valid date strings'
78
- end
79
-
80
- fail ArgumentError,
81
- 'End date must be after start date' if !end_date.nil? and end_parsed <= start_parsed
82
- url += '&start=' + start_parsed.iso8601
83
- url += '&end=' + end_parsed.iso8601 unless end_parsed.nil?
84
- end
85
-
86
- response = @client.send_request(
87
- method: 'GET',
88
- url: url
89
- )
90
- logger.info("Send per push series request for push_id #{push_id} and url #{url}")
91
- response
92
- end
93
- end
94
- end
95
- end
96
-
97
-