urbanairship 3.1.1 → 3.2.0
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 +4 -4
- data/CHANGELOG +11 -0
- data/docs/devices.rst +166 -5
- data/docs/index.rst +2 -0
- data/docs/location.rst +127 -0
- data/docs/push.rst +31 -0
- data/docs/reports.rst +68 -66
- data/docs/static_lists.rst +137 -0
- data/lib/urbanairship.rb +3 -0
- data/lib/urbanairship/client.rb +10 -5
- data/lib/urbanairship/common.rb +10 -0
- data/lib/urbanairship/devices/devicelist.rb +121 -0
- data/lib/urbanairship/devices/static_lists.rb +101 -0
- data/lib/urbanairship/push/location.rb +103 -0
- data/lib/urbanairship/push/push.rb +22 -3
- data/lib/urbanairship/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 976658dd2efc281297b56b178d85d548a2c7122e
|
|
4
|
+
data.tar.gz: 8389f2788b640c2cafd9ba036701a69fc8c90740
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1db5563ad0b87e7f5ca1ef2b8485622f401b6630180627385157f7e5ad8d1b6b569c727c0a7761995215a004b6bada2681ab83efb183959b25a5e07223ec2564
|
|
7
|
+
data.tar.gz: 13ff6a7e2d6cb7405c63764732f79e3037418195cc45026639606f97472544d70628cb9cb8343c0b6c11ee8851c8a7eef873963162a2b596e51990ade15fc721
|
data/CHANGELOG
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
--------------------
|
|
2
|
+
3.2.0
|
|
3
|
+
--------------------
|
|
4
|
+
- Added support for static lists
|
|
5
|
+
- Added support for device tokens, apids, and blackberry pins
|
|
6
|
+
- Added support for locations
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
--------------------
|
|
1
11
|
3.1.1
|
|
2
12
|
--------------------
|
|
3
13
|
- Changed UA to Urbanairship in client.rb to fix aliasing issue
|
|
4
14
|
|
|
5
15
|
|
|
6
16
|
|
|
17
|
+
--------------------
|
|
7
18
|
3.1.0
|
|
8
19
|
--------------------
|
|
9
20
|
- Added documentation files
|
data/docs/devices.rst
CHANGED
|
@@ -5,8 +5,9 @@ Channel Listing
|
|
|
5
5
|
---------------
|
|
6
6
|
|
|
7
7
|
Device lists are fetched by instantiating an iterator object
|
|
8
|
-
using :rb:class:`ChannelList`. For more information, see
|
|
9
|
-
http://docs.urbanairship.com/api/ua.html#channels
|
|
8
|
+
using :rb:class:`ChannelList`. For more information, see `the API
|
|
9
|
+
documentation for channels <http://docs.urbanairship.com/api/ua.html#channels>`_.
|
|
10
|
+
The ``count`` method will give you the number of channels over which you have iterated.
|
|
10
11
|
|
|
11
12
|
.. code-block:: ruby
|
|
12
13
|
|
|
@@ -19,6 +20,8 @@ http://docs.urbanairship.com/api/ua.html#channels
|
|
|
19
20
|
puts(channel)
|
|
20
21
|
end
|
|
21
22
|
|
|
23
|
+
puts(channel_list.count)
|
|
24
|
+
|
|
22
25
|
Channel Lookup
|
|
23
26
|
--------------
|
|
24
27
|
|
|
@@ -39,8 +42,8 @@ Feedback
|
|
|
39
42
|
|
|
40
43
|
Feedback returns a list of dictionaries of device tokens/APIDs that the
|
|
41
44
|
respective push provider has told us are uninstalled since the given
|
|
42
|
-
timestamp. For more information, see
|
|
43
|
-
http://docs.urbanairship.com/api/ua.html#feedback
|
|
45
|
+
timestamp. For more information, see `the API documentation for feedback
|
|
46
|
+
<http://docs.urbanairship.com/api/ua.html#feedback>`_
|
|
44
47
|
|
|
45
48
|
.. code-block:: ruby
|
|
46
49
|
|
|
@@ -51,4 +54,162 @@ http://docs.urbanairship.com/api/ua.html#feedback
|
|
|
51
54
|
since = (Time.now.utc - (60 * 60 * 24 * 3)).iso8601
|
|
52
55
|
feedback = UA::Feedback.new(client: airship)
|
|
53
56
|
tokens = feedback.device_token(since: since)
|
|
54
|
-
apids = feedback.apid(since: since)
|
|
57
|
+
apids = feedback.apid(since: since)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
Device Token Lookup
|
|
61
|
+
-------------------
|
|
62
|
+
|
|
63
|
+
Get information on a particular iOS device token:
|
|
64
|
+
|
|
65
|
+
.. code-block:: ruby
|
|
66
|
+
|
|
67
|
+
require 'urbanairship'
|
|
68
|
+
|
|
69
|
+
UA = Urbanairship
|
|
70
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
71
|
+
device_token = UA::DeviceToken.new(client: airship)
|
|
72
|
+
resp = device_token.lookup(token: 'device_token')
|
|
73
|
+
puts(resp)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
Device Token List
|
|
77
|
+
-----------------
|
|
78
|
+
|
|
79
|
+
Get a list of iOS device tokens for the application:
|
|
80
|
+
|
|
81
|
+
.. code-block:: ruby
|
|
82
|
+
|
|
83
|
+
require 'urbanairship'
|
|
84
|
+
|
|
85
|
+
UA = Urbanairship
|
|
86
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
87
|
+
device_token_list = UA::DeviceTokenList.new(client: airship)
|
|
88
|
+
device_token_list.each do |token|
|
|
89
|
+
puts(token)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
Device Token Count
|
|
94
|
+
------------------
|
|
95
|
+
|
|
96
|
+
Get the total iOS device tokens registered to the application.
|
|
97
|
+
|
|
98
|
+
.. code-block:: ruby
|
|
99
|
+
|
|
100
|
+
require 'urbanairship'
|
|
101
|
+
|
|
102
|
+
UA = Urbanairship
|
|
103
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
104
|
+
device_token_list = UA::DeviceTokenList.new(client: airship)
|
|
105
|
+
puts(device_token_list.count)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
APID Lookup
|
|
109
|
+
-----------
|
|
110
|
+
|
|
111
|
+
Get information on a particular Android APID:
|
|
112
|
+
|
|
113
|
+
.. code-block:: ruby
|
|
114
|
+
|
|
115
|
+
require 'urbanairship'
|
|
116
|
+
|
|
117
|
+
UA = Urbanairship
|
|
118
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
119
|
+
apid = UA::APID.new(client: airship)
|
|
120
|
+
resp = apid.lookup(apid: 'apid')
|
|
121
|
+
puts(resp)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
APID List
|
|
125
|
+
---------
|
|
126
|
+
|
|
127
|
+
List all APIDs for the application. Afterwards, you can get the number of apids
|
|
128
|
+
that have been iterated over by using the ``count`` method.
|
|
129
|
+
|
|
130
|
+
.. code-block:: ruby
|
|
131
|
+
|
|
132
|
+
require 'urbanairship'
|
|
133
|
+
|
|
134
|
+
UA = Urbanairship
|
|
135
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
136
|
+
apid_list = UA::APIDList.new(client: airship)
|
|
137
|
+
apid_list.each do |apid|
|
|
138
|
+
puts(apid)
|
|
139
|
+
end
|
|
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/index.rst
CHANGED
data/docs/location.rst
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
Locations
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
This class allows you to search for location information in
|
|
5
|
+
various ways.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Name Lookup
|
|
9
|
+
-----------
|
|
10
|
+
|
|
11
|
+
Search for a location boundary by name. The search primarily
|
|
12
|
+
uses the location names, but you can also filter the results
|
|
13
|
+
by boundary type. See `the API documentation on location
|
|
14
|
+
<http://docs.urbanairship.com/api/ua.html#location>`_
|
|
15
|
+
for more information.
|
|
16
|
+
|
|
17
|
+
.. code-block:: ruby
|
|
18
|
+
|
|
19
|
+
require 'urbanairship'
|
|
20
|
+
UA = Urbanairship
|
|
21
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
22
|
+
location = UA::Location.new(client: airship)
|
|
23
|
+
location.name_lookup(name: 'name', type: 'type')
|
|
24
|
+
|
|
25
|
+
.. note::
|
|
26
|
+
|
|
27
|
+
``name`` is a required parameter, but ``type`` is optional
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Coordinates Lookup
|
|
31
|
+
------------------
|
|
32
|
+
|
|
33
|
+
Search for a location by latitude and longitude coordinates. Type is
|
|
34
|
+
an optional parameter. See `the API documentation on coordinates lookup
|
|
35
|
+
<http://docs.urbanairship.com/api/ua.html#lat-long-lookup>`_
|
|
36
|
+
for more information.
|
|
37
|
+
|
|
38
|
+
.. code-block:: ruby
|
|
39
|
+
|
|
40
|
+
require 'urbanairship'
|
|
41
|
+
UA = Urbanairship
|
|
42
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
43
|
+
location = UA::Location.new(client: airship)
|
|
44
|
+
location.coordinates_lookup(latitude: 123.45, longitude: 123.45, type: 'type')
|
|
45
|
+
|
|
46
|
+
.. note::
|
|
47
|
+
|
|
48
|
+
``longitude`` and ``latitude`` are required parameters that must be numbers.
|
|
49
|
+
``Type`` is an optional parameter.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
Bounding Box Lookup
|
|
53
|
+
-------------------
|
|
54
|
+
|
|
55
|
+
Search for location using a bounding box. See `the documentation on
|
|
56
|
+
bounding box lookup
|
|
57
|
+
<http://docs.urbanairship.com/api/ua.html#bounding-box-lookup>`_
|
|
58
|
+
for more information.
|
|
59
|
+
|
|
60
|
+
.. code-block:: ruby
|
|
61
|
+
|
|
62
|
+
require 'urbanairship'
|
|
63
|
+
UA = Urbanairship
|
|
64
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
65
|
+
location = UA::Location.new(client: airship)
|
|
66
|
+
location.bounding_box_lookup(lat1: 123.45, long1: 123.45,
|
|
67
|
+
lat2: 321.45, long2: 321.45, type: 'type')
|
|
68
|
+
|
|
69
|
+
.. note::
|
|
70
|
+
|
|
71
|
+
``lat1``, ``long1``, ``lat2``, and ``long2`` and are required parameters that must be numbers.
|
|
72
|
+
``Type`` is an optional parameter.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
Alias Lookup
|
|
76
|
+
------------
|
|
77
|
+
|
|
78
|
+
Search for location by alias. See `the documentation on alias lookup
|
|
79
|
+
<http://docs.urbanairship.com/api/ua.html#alias-lookup>`_
|
|
80
|
+
|
|
81
|
+
.. code-block:: ruby
|
|
82
|
+
|
|
83
|
+
require 'urbanairship'
|
|
84
|
+
UA = Urbanairship
|
|
85
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
86
|
+
location = UA::Location.new(client: airship)
|
|
87
|
+
location.alias_lookup(from_alias: 'us_state=CA')
|
|
88
|
+
|
|
89
|
+
.. note::
|
|
90
|
+
|
|
91
|
+
``from_alias`` can either be a single alias or an array of aliases.
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
Polygon Lookup
|
|
95
|
+
--------------
|
|
96
|
+
|
|
97
|
+
Search for location by polygon id. See `the documentation on polygon
|
|
98
|
+
lookup <http://docs.urbanairship.com/api/ua.html#polygon-lookup>`_
|
|
99
|
+
for more information.
|
|
100
|
+
|
|
101
|
+
.. code-block:: ruby
|
|
102
|
+
|
|
103
|
+
require 'urbanairship'
|
|
104
|
+
UA = Urbanairship
|
|
105
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
106
|
+
location = UA::Location.new(client: airship)
|
|
107
|
+
location.polygon_lookup(polygon_id: 'id', zoom: 1)
|
|
108
|
+
|
|
109
|
+
.. note::
|
|
110
|
+
|
|
111
|
+
``polygon_id`` needs to be a string. ``Zoom`` is a number ranging from 1-20.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
Location Date Ranges
|
|
115
|
+
--------------------
|
|
116
|
+
|
|
117
|
+
Get the possible date ranges that can be used with location endpoints. See `the documentation
|
|
118
|
+
on location date ranges <http://docs.urbanairship.com/api/ua.html#location-date-ranges>`__
|
|
119
|
+
for more information.
|
|
120
|
+
|
|
121
|
+
.. code-block:: ruby
|
|
122
|
+
|
|
123
|
+
require 'urbanairship'
|
|
124
|
+
UA = Urbanairship
|
|
125
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
126
|
+
l = UA::Location.new(client: airship)
|
|
127
|
+
l.date_ranges
|
data/docs/push.rst
CHANGED
|
@@ -414,3 +414,34 @@ notification, you can update or cancel it before it's sent.
|
|
|
414
414
|
|
|
415
415
|
# Cancel
|
|
416
416
|
schedule.cancel
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
Listing a Particular Schedule
|
|
420
|
+
-----------------------------
|
|
421
|
+
|
|
422
|
+
If you have the schedule id, you can use it to list the details of a
|
|
423
|
+
particular schedule.
|
|
424
|
+
|
|
425
|
+
.. code-block:: ruby
|
|
426
|
+
|
|
427
|
+
airship = UA::Client.new(key: '123', secret: 'abc')
|
|
428
|
+
scheduled_push = UA::ScheduledPush.new(airship)
|
|
429
|
+
schedule_details = scheduled_push.list(schedule_id: 'id')
|
|
430
|
+
puts(schedule_details)
|
|
431
|
+
|
|
432
|
+
.. note::
|
|
433
|
+
The schedule_id can be obtained from the url of the schedule.
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
Listing all Schedules
|
|
437
|
+
---------------------
|
|
438
|
+
|
|
439
|
+
You can list all schedules with the ``ScheduledPushList`` class:
|
|
440
|
+
|
|
441
|
+
.. code-block:: ruby
|
|
442
|
+
|
|
443
|
+
airship = UA::Client.new(key: '123', secret: 'abc')
|
|
444
|
+
scheduled_push_list = UA::ScheduledPushList.new(client: airship)
|
|
445
|
+
scheduled_push_list.each do |schedule|
|
|
446
|
+
puts(schedule)
|
|
447
|
+
end
|
data/docs/reports.rst
CHANGED
|
@@ -8,7 +8,7 @@ Individual Push Response Stats
|
|
|
8
8
|
Returns detailed report information about a specific push notification.
|
|
9
9
|
Use the push_id, which is the identifier returned by the API that represents a
|
|
10
10
|
specific push message delivery.
|
|
11
|
-
For more information, see `the API documentation
|
|
11
|
+
For more information, see `the API documentation on individual push statistics
|
|
12
12
|
<http://docs.urbanairship.com/api/ua.html#individual-push-response-statistics>`_
|
|
13
13
|
|
|
14
14
|
.. code-block:: ruby
|
|
@@ -20,12 +20,12 @@ For more information, see `the API documentation
|
|
|
20
20
|
statistics = d.get(push_id: 'push_id')
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
Devices Report
|
|
23
|
+
Devices Report
|
|
24
24
|
==============
|
|
25
25
|
|
|
26
26
|
Returns an app’s opted-in and installed device counts broken out by device
|
|
27
27
|
type. This endpoint returns the same data that populates the Devices Report.
|
|
28
|
-
For more information, see `the API documentation
|
|
28
|
+
For more information, see `the API documentation on device reports
|
|
29
29
|
<http://docs.urbanairship.com/api/ua.html#devices-report-api>`_
|
|
30
30
|
|
|
31
31
|
.. code-block:: ruby
|
|
@@ -41,7 +41,7 @@ Push Report
|
|
|
41
41
|
===========
|
|
42
42
|
|
|
43
43
|
Get the number of pushes you have sent within a specified time period.
|
|
44
|
-
For more information, see `the API documentation
|
|
44
|
+
For more information, see `the API documentation on push reports
|
|
45
45
|
<http://docs.urbanairship.com/api/ua.html#push-report>`_
|
|
46
46
|
|
|
47
47
|
.. code-block:: ruby
|
|
@@ -60,89 +60,91 @@ For more information, see `the API documentation
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
.. note::
|
|
63
|
+
|
|
63
64
|
precision needs to be a member of ['HOURLY', 'DAILY', 'MONTHLY']
|
|
64
65
|
|
|
66
|
+
.. Hiding the perpush endpoints for now per GAG-705 (until rate limiting is in place)
|
|
65
67
|
|
|
68
|
+
Per Push Reporting
|
|
69
|
+
==================
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
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>`_
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
---------------
|
|
77
|
+
Per Push Detail
|
|
78
|
+
---------------
|
|
73
79
|
|
|
74
|
-
---------------
|
|
75
|
-
Per Push Detail
|
|
76
|
-
---------------
|
|
77
80
|
|
|
81
|
+
Single Request
|
|
82
|
+
--------------
|
|
78
83
|
|
|
79
|
-
|
|
80
|
-
|
|
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>`_
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
API documentation
|
|
84
|
-
<http://docs.urbanairship.com/api/ua.html#single-request>`_
|
|
88
|
+
.. code-block:: ruby
|
|
85
89
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
d = UA::PerPushDetail.new(client: airship)
|
|
92
|
-
details = d.get_single(push_id:'push_id')
|
|
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')
|
|
93
95
|
|
|
94
96
|
|
|
95
|
-
Batch Request
|
|
96
|
-
-------------
|
|
97
|
+
Batch Request
|
|
98
|
+
-------------
|
|
97
99
|
|
|
98
|
-
Get the analytics details for an array of Push IDs. For more information,
|
|
99
|
-
see `the API documentation <http://docs.urbanairship.com/api/ua.html#batch-request>`_
|
|
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>`_
|
|
100
102
|
|
|
101
|
-
.. code-block:: ruby
|
|
103
|
+
.. code-block:: ruby
|
|
102
104
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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'])
|
|
108
110
|
|
|
109
|
-
.. note::
|
|
111
|
+
.. note::
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
There is a maximum of 100 Push IDs per request
|
|
112
114
|
|
|
113
|
-
---------------
|
|
114
|
-
Per Push Series
|
|
115
|
-
---------------
|
|
115
|
+
---------------
|
|
116
|
+
Per Push Series
|
|
117
|
+
---------------
|
|
116
118
|
|
|
117
|
-
Get the default time series data. For more information,
|
|
118
|
-
see `the API documentation
|
|
119
|
-
<http://docs.urbanairship.com/api/ua.html#per-push-series>`_
|
|
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>`_
|
|
120
122
|
|
|
121
|
-
.. code-block:: ruby
|
|
123
|
+
.. code-block:: ruby
|
|
122
124
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
+
)
|
|
133
135
|
|
|
134
|
-
.. note::
|
|
136
|
+
.. note::
|
|
135
137
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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'].
|
|
140
142
|
|
|
141
143
|
Response Report
|
|
142
144
|
===============
|
|
143
145
|
|
|
144
146
|
Get the number of direct and influenced opens of your app. For more
|
|
145
|
-
information, see `the API documentation
|
|
147
|
+
information, see `the API documentation on reponse reports
|
|
146
148
|
<http://docs.urbanairship.com/api/ua.html#response-report>`_
|
|
147
149
|
|
|
148
150
|
.. code-block:: ruby
|
|
@@ -169,9 +171,9 @@ Response Listing
|
|
|
169
171
|
================
|
|
170
172
|
|
|
171
173
|
Get a listing of all pushes and basic response information in a given
|
|
172
|
-
timeframe by instantiating an iterator object using ResponseList.
|
|
174
|
+
timeframe by instantiating an iterator object using ResponseList.
|
|
173
175
|
Start and end date times are required parameters.
|
|
174
|
-
For more information, see `the API documentation
|
|
176
|
+
For more information, see `the API documentation on response listings
|
|
175
177
|
<http://docs.urbanairship.com/api/ua.html#response-listing>`_
|
|
176
178
|
|
|
177
179
|
.. code-block:: ruby
|
|
@@ -200,7 +202,7 @@ App Opens Report
|
|
|
200
202
|
================
|
|
201
203
|
|
|
202
204
|
Get the number of users who have opened your app within the specified time
|
|
203
|
-
period. For more information, see `the API documentation
|
|
205
|
+
period. For more information, see `the API documentation on app open reports
|
|
204
206
|
<http://docs.urbanairship.com/api/ua.html#app-opens-report>`_
|
|
205
207
|
|
|
206
208
|
.. code-block:: ruby
|
|
@@ -227,6 +229,7 @@ Time In App Report
|
|
|
227
229
|
|
|
228
230
|
Get the average amount of time users have spent in your app within the
|
|
229
231
|
specified time period. For more information, see `the API documentation
|
|
232
|
+
on time-in-app reports
|
|
230
233
|
<http://docs.urbanairship.com/api/ua.html#time-in-app-report>`_
|
|
231
234
|
|
|
232
235
|
.. code-block:: ruby
|
|
@@ -253,7 +256,7 @@ Opt-In Report
|
|
|
253
256
|
|
|
254
257
|
Get the number of opted-in push users who access the app within the specified
|
|
255
258
|
time period.
|
|
256
|
-
For more information, see `the API documentation
|
|
259
|
+
For more information, see `the API documentation on opt-in reports
|
|
257
260
|
<http://docs.urbanairship.com/api/ua.html#opt-in-report>`_
|
|
258
261
|
|
|
259
262
|
.. code-block:: ruby
|
|
@@ -278,9 +281,9 @@ For more information, see `the API documentation
|
|
|
278
281
|
Opt-Out Report
|
|
279
282
|
==============
|
|
280
283
|
|
|
281
|
-
Get the number of opted-out push users who access the app within the specified
|
|
284
|
+
Get the number of opted-out push users who access the app within the specified
|
|
282
285
|
time period.
|
|
283
|
-
For more information, see `the API documentation
|
|
286
|
+
For more information, see `the API documentation on opt-out reports
|
|
284
287
|
<http://docs.urbanairship.com/api/ua.html#opt-out-report>`_
|
|
285
288
|
|
|
286
289
|
.. code-block:: ruby
|
|
@@ -300,4 +303,3 @@ For more information, see `the API documentation
|
|
|
300
303
|
.. note::
|
|
301
304
|
|
|
302
305
|
precision needs to be a member of ['HOURLY', 'DAILY', 'MONTHLY']
|
|
303
|
-
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Static Lists
|
|
2
|
+
============
|
|
3
|
+
|
|
4
|
+
With the Static List endpoint, you can easily target and manage
|
|
5
|
+
lists of devices that are defined in your systems outside of Urban Airship.
|
|
6
|
+
Any list or grouping of devices for which the canonical source of data about
|
|
7
|
+
the members is elsewhere is a good candidate for Static Lists, e.g., members
|
|
8
|
+
of a customer loyalty program.
|
|
9
|
+
For more information, see: `the API documentation on Static Lists
|
|
10
|
+
<http://docs.urbanairship.com/api/ua.html#static-lists>`__
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Create List
|
|
14
|
+
-----------
|
|
15
|
+
|
|
16
|
+
Creates a static list. The body of the request will contain several of the list
|
|
17
|
+
object parameters, but the actual list content will be provided by a second call
|
|
18
|
+
to the upload endpoint.
|
|
19
|
+
|
|
20
|
+
The create method has two optional parameters including 'description,' which is a
|
|
21
|
+
user-provided description of the list, and 'extras,' which is a dictionary of
|
|
22
|
+
string keys to arbitrary JSON values.
|
|
23
|
+
|
|
24
|
+
.. code-block:: ruby
|
|
25
|
+
|
|
26
|
+
require 'urbanairship'
|
|
27
|
+
UA = Urbanairship
|
|
28
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
29
|
+
static_list = UA::StaticList.new(client: airship)
|
|
30
|
+
static_list.name = 'list_name'
|
|
31
|
+
static_list.create(description: 'description', extras: { 'key' => 'value' })
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Upload List
|
|
35
|
+
-----------
|
|
36
|
+
|
|
37
|
+
Lists target identifiers are specified or replaced with an upload to this endpoint.
|
|
38
|
+
Uploads must be newline delimited identifiers (text/CSV) as described in RFC 4180,
|
|
39
|
+
with commas as the delimiter. The ``StaticList.upload csvfile`` parameter takes an
|
|
40
|
+
open file descriptor. A second optional ``gzip`` parameter specifies whether the csvfile
|
|
41
|
+
to be uploaded is gzipped. This parameter defaults to false.
|
|
42
|
+
|
|
43
|
+
The CSV format consists of two columns: 'identifier_type' and 'identifier'.
|
|
44
|
+
'identifier_type' must be one of 'alias', 'named_user', 'ios_channel', 'android_channel',
|
|
45
|
+
or 'amazon_channel'. 'identifier' is the associated identifier you wish to send to.
|
|
46
|
+
|
|
47
|
+
The maximum number of 'identifier_type,identifier' pairs that may be uploaded to a list
|
|
48
|
+
is 10 million.
|
|
49
|
+
|
|
50
|
+
.. code-block:: ruby
|
|
51
|
+
|
|
52
|
+
require 'urbanairship'
|
|
53
|
+
UA = Urbanairship
|
|
54
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
55
|
+
static_list = UA::StaticList.new(client: airship)
|
|
56
|
+
static_list.name = 'list_name'
|
|
57
|
+
File.open('csv_file', 'rb') do |csv|
|
|
58
|
+
static_list.upload(csv_file: csv, gzip: false)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
Update List
|
|
63
|
+
-----------
|
|
64
|
+
|
|
65
|
+
Updates the metadata of a static list.
|
|
66
|
+
|
|
67
|
+
.. code-block:: ruby
|
|
68
|
+
|
|
69
|
+
require 'urbanairship'
|
|
70
|
+
UA = Urbanairship
|
|
71
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
72
|
+
static_list = UA::StaticList.new(client: airship)
|
|
73
|
+
static_list.name = 'list_name'
|
|
74
|
+
static_list.update(description: 'description', { 'key' => 'value' })
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
Delete List
|
|
78
|
+
-----------
|
|
79
|
+
|
|
80
|
+
Delete a static list.
|
|
81
|
+
|
|
82
|
+
.. code-block:: ruby
|
|
83
|
+
|
|
84
|
+
require 'urbanairship'
|
|
85
|
+
UA = Urbanairship
|
|
86
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
87
|
+
static_list = UA::StaticList.new(client: airship)
|
|
88
|
+
static_list.name = 'list_name'
|
|
89
|
+
static_list.delete
|
|
90
|
+
|
|
91
|
+
.. note::
|
|
92
|
+
|
|
93
|
+
If you are attempting to update a current list by deleting it
|
|
94
|
+
and then recreating it with new data, stop and go to the upload
|
|
95
|
+
endpoint. There is no need to delete a list before uploading a
|
|
96
|
+
new CSV file.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
Lookup List
|
|
100
|
+
-----------
|
|
101
|
+
Retrieve information about one static list.
|
|
102
|
+
|
|
103
|
+
.. code-block:: ruby
|
|
104
|
+
|
|
105
|
+
require 'urbanairship'
|
|
106
|
+
UA = Urbanairship
|
|
107
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
108
|
+
static_list = UA::StaticList.new(client: airship)
|
|
109
|
+
static_list.name = 'list_name'
|
|
110
|
+
static_list.lookup
|
|
111
|
+
|
|
112
|
+
.. note::
|
|
113
|
+
|
|
114
|
+
When looking up lists, the returned information may actually be a combination
|
|
115
|
+
of values from both the last uploaded list and the last successfully processed
|
|
116
|
+
list. If you create a list successfully, and then you update it and the
|
|
117
|
+
processing step fails, then the list status will read "failed", but the
|
|
118
|
+
channel_count and last_modified fields will contain information on the last
|
|
119
|
+
successfully processed list.
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
Lookup All Lists
|
|
123
|
+
----------------
|
|
124
|
+
|
|
125
|
+
Retrieve information about all static lists. This call returns a paginated list of
|
|
126
|
+
metadata that will not contain the actual lists of users.
|
|
127
|
+
|
|
128
|
+
.. code-block:: ruby
|
|
129
|
+
|
|
130
|
+
require 'urbanairship'
|
|
131
|
+
UA = Urbanairship
|
|
132
|
+
airship = UA::Client.new(key:'application_key', secret:'master_secret')
|
|
133
|
+
static_lists = UA::StaticLists.new(client: airship)
|
|
134
|
+
|
|
135
|
+
static_lists.each do |static_list|
|
|
136
|
+
puts(static_list)
|
|
137
|
+
end
|
data/lib/urbanairship.rb
CHANGED
|
@@ -14,6 +14,8 @@ require 'urbanairship/devices/channel_tags'
|
|
|
14
14
|
require 'urbanairship/devices/named_user'
|
|
15
15
|
require 'urbanairship/reports/per_push'
|
|
16
16
|
require 'urbanairship/reports/response_statistics'
|
|
17
|
+
require 'urbanairship/devices/static_lists'
|
|
18
|
+
require 'urbanairship/push/location'
|
|
17
19
|
|
|
18
20
|
module Urbanairship
|
|
19
21
|
extend Urbanairship::Push::Audience
|
|
@@ -22,4 +24,5 @@ module Urbanairship
|
|
|
22
24
|
extend Urbanairship::Push
|
|
23
25
|
include Urbanairship::Devices
|
|
24
26
|
include Urbanairship::Reports
|
|
27
|
+
include Urbanairship::Push
|
|
25
28
|
end
|
data/lib/urbanairship/client.rb
CHANGED
|
@@ -30,7 +30,7 @@ module Urbanairship
|
|
|
30
30
|
# @param [Object] version API Version
|
|
31
31
|
# @return [Object] Push Response
|
|
32
32
|
def send_request(method: required('method'), url: required('url'), body: nil,
|
|
33
|
-
content_type: nil)
|
|
33
|
+
content_type: nil, encoding: nil)
|
|
34
34
|
req_type = case method
|
|
35
35
|
when 'GET'
|
|
36
36
|
:get
|
|
@@ -46,12 +46,17 @@ module Urbanairship
|
|
|
46
46
|
|
|
47
47
|
headers = {'User-agent' => 'UARubyLib/' + Urbanairship::VERSION}
|
|
48
48
|
headers['Accept'] = 'application/vnd.urbanairship+json; version=3'
|
|
49
|
+
headers['Content-type'] = content_type unless content_type.nil?
|
|
50
|
+
headers['Content-Encoding'] = encoding unless encoding.nil?
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
debug = "Making #{method} request to #{url}.\n"+
|
|
53
|
+
"\tHeaders:\n"
|
|
54
|
+
debug += "\t\tcontent-type: #{content_type}\n" unless content_type.nil?
|
|
55
|
+
debug += "\t\tcontent-encoding: gzip\n" unless encoding.nil?
|
|
56
|
+
debug += "\t\taccept: application/vnd.urbanairship+json; version=3\n"
|
|
57
|
+
debug += "\tBody:\n#{body}" unless body.nil?
|
|
53
58
|
|
|
54
|
-
logger.debug(
|
|
59
|
+
logger.debug(debug)
|
|
55
60
|
|
|
56
61
|
response = Unirest.method(req_type).call(
|
|
57
62
|
url,
|
data/lib/urbanairship/common.rb
CHANGED
|
@@ -17,6 +17,10 @@ module Urbanairship
|
|
|
17
17
|
SEGMENTS_URL = BASE_URL + '/segments/'
|
|
18
18
|
NAMED_USER_URL = BASE_URL + '/named_users/'
|
|
19
19
|
REPORTS_URL = BASE_URL + '/reports/'
|
|
20
|
+
LISTS_URL = BASE_URL + '/lists/'
|
|
21
|
+
PIPELINES_URL = BASE_URL + '/pipelines/'
|
|
22
|
+
FEEDS_URL = BASE_URL + '/feeds/'
|
|
23
|
+
LOCATION_URL = BASE_URL + '/location/'
|
|
20
24
|
|
|
21
25
|
# Helper method for required keyword args in Ruby 2.0 that is compatible with 2.1+
|
|
22
26
|
# @example
|
|
@@ -114,6 +118,7 @@ module Urbanairship
|
|
|
114
118
|
@next_page = nil
|
|
115
119
|
@data_list = nil
|
|
116
120
|
@data_attribute = nil
|
|
121
|
+
@count = 0
|
|
117
122
|
end
|
|
118
123
|
|
|
119
124
|
def load_page
|
|
@@ -140,10 +145,15 @@ module Urbanairship
|
|
|
140
145
|
def each
|
|
141
146
|
while load_page
|
|
142
147
|
@data_list.each do | value |
|
|
148
|
+
@count += 1
|
|
143
149
|
yield value
|
|
144
150
|
end
|
|
145
151
|
end
|
|
146
152
|
end
|
|
153
|
+
|
|
154
|
+
def count
|
|
155
|
+
@count
|
|
156
|
+
end
|
|
147
157
|
end
|
|
148
158
|
end
|
|
149
159
|
end
|
|
@@ -57,5 +57,126 @@ module Urbanairship
|
|
|
57
57
|
response
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
|
+
|
|
61
|
+
class DeviceToken
|
|
62
|
+
include Urbanairship::Common
|
|
63
|
+
include Urbanairship::Loggable
|
|
64
|
+
|
|
65
|
+
def initialize(client: required('client'))
|
|
66
|
+
@client = client
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def lookup(token: required('token'))
|
|
70
|
+
fail ArgumentError, 'token needs to be a string' unless token.is_a? String
|
|
71
|
+
|
|
72
|
+
resp = @client.send_request(
|
|
73
|
+
method: 'GET',
|
|
74
|
+
url: DEVICE_TOKEN_URL + token
|
|
75
|
+
)
|
|
76
|
+
logger.info("Looking up info on device token #{token}")
|
|
77
|
+
resp
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
class DeviceTokenList < Urbanairship::Common::PageIterator
|
|
82
|
+
include Urbanairship::Common
|
|
83
|
+
include Urbanairship::Loggable
|
|
84
|
+
|
|
85
|
+
def initialize(client: required('client'))
|
|
86
|
+
super(client: client)
|
|
87
|
+
@next_page = DEVICE_TOKEN_URL
|
|
88
|
+
@data_attribute = 'device_tokens'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def count
|
|
92
|
+
resp = @client.send_request(
|
|
93
|
+
method: 'GET',
|
|
94
|
+
url: DEVICE_TOKEN_URL + 'count/'
|
|
95
|
+
)
|
|
96
|
+
logger.info("Retrieved count of Device Token List.")
|
|
97
|
+
resp
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
class APID
|
|
102
|
+
include Urbanairship::Common
|
|
103
|
+
include Urbanairship::Loggable
|
|
104
|
+
|
|
105
|
+
def initialize(client: required('client'))
|
|
106
|
+
@client = client
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def lookup(apid: required('apid'))
|
|
110
|
+
fail ArgumentError, 'apid needs to be a string' unless apid.is_a? String
|
|
111
|
+
|
|
112
|
+
resp = @client.send_request(
|
|
113
|
+
method: 'GET',
|
|
114
|
+
url: APID_URL + apid
|
|
115
|
+
)
|
|
116
|
+
logger.info("Retrieved info on apid #{apid}")
|
|
117
|
+
resp
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
class APIDList < Urbanairship::Common::PageIterator
|
|
122
|
+
def initialize(client: required('client'))
|
|
123
|
+
super(client: client)
|
|
124
|
+
@next_page = APID_URL
|
|
125
|
+
@data_attribute = 'apids'
|
|
126
|
+
end
|
|
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
|
|
60
181
|
end
|
|
61
182
|
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require 'urbanairship'
|
|
2
|
+
require 'tempfile'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
module Urbanairship
|
|
6
|
+
module Devices
|
|
7
|
+
class StaticList
|
|
8
|
+
include Urbanairship::Common
|
|
9
|
+
include Urbanairship::Loggable
|
|
10
|
+
attr_accessor :name
|
|
11
|
+
def initialize(client: required('client'))
|
|
12
|
+
fail ArgumentError, 'Client cannot be set to nil' if client.nil?
|
|
13
|
+
@client = client
|
|
14
|
+
@name = nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create(description: nil, extras: nil)
|
|
18
|
+
fail ArgumentError, 'Name must be set' if @name.nil?
|
|
19
|
+
payload = {'name' => @name}
|
|
20
|
+
payload['description'] = description unless description.nil?
|
|
21
|
+
payload['extras'] = extras unless extras.nil?
|
|
22
|
+
|
|
23
|
+
response = @client.send_request(
|
|
24
|
+
method: 'POST',
|
|
25
|
+
body: JSON.dump(payload),
|
|
26
|
+
url: LISTS_URL,
|
|
27
|
+
content_type: 'application/json'
|
|
28
|
+
)
|
|
29
|
+
logger.info("Created static list for #{@name}")
|
|
30
|
+
response
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def upload(csv_file: required('csv_file'), gzip: false)
|
|
34
|
+
fail ArgumentError, 'Name must be set' if @name.nil?
|
|
35
|
+
if gzip
|
|
36
|
+
response = @client.send_request(
|
|
37
|
+
method: 'PUT',
|
|
38
|
+
body: csv_file,
|
|
39
|
+
url: LISTS_URL + @name + '/csv/',
|
|
40
|
+
content_type: 'text/csv',
|
|
41
|
+
encoding: gzip
|
|
42
|
+
)
|
|
43
|
+
else
|
|
44
|
+
response = @client.send_request(
|
|
45
|
+
method: 'PUT',
|
|
46
|
+
body: csv_file,
|
|
47
|
+
url: LISTS_URL + @name + '/csv/',
|
|
48
|
+
content_type: 'text/csv'
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
logger.info("Uploading a list for #{@name}")
|
|
52
|
+
response
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def update(description: nil, extras: nil)
|
|
56
|
+
fail ArgumentError, 'Name must be set' if @name.nil?
|
|
57
|
+
fail ArgumentError,
|
|
58
|
+
'Either description or extras must be set to a value' if description.nil? and extras.nil?
|
|
59
|
+
payload = {}
|
|
60
|
+
payload['description'] = description unless description.nil?
|
|
61
|
+
payload['extras'] = extras unless extras.nil?
|
|
62
|
+
response = @client.send_request(
|
|
63
|
+
method: 'PUT',
|
|
64
|
+
body: JSON.dump(payload),
|
|
65
|
+
url: LISTS_URL + @name,
|
|
66
|
+
content_type: 'application/json'
|
|
67
|
+
)
|
|
68
|
+
logger.info("Updating the metadata for list #{@name}")
|
|
69
|
+
response
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def lookup
|
|
73
|
+
fail ArgumentError, 'Name must be set' if @name.nil?
|
|
74
|
+
response = @client.send_request(
|
|
75
|
+
method: 'GET',
|
|
76
|
+
url: LISTS_URL + @name
|
|
77
|
+
)
|
|
78
|
+
logger.info("Retrieving info for list #{@name}")
|
|
79
|
+
response
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def delete
|
|
83
|
+
fail ArgumentError, 'Name must be set' if @name.nil?
|
|
84
|
+
response = @client.send_request(
|
|
85
|
+
method: 'DELETE',
|
|
86
|
+
url: LISTS_URL + @name
|
|
87
|
+
)
|
|
88
|
+
logger.info("Deleted list #{@name}")
|
|
89
|
+
response
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
class StaticLists < Urbanairship::Common::PageIterator
|
|
94
|
+
def initialize(client: required('client'))
|
|
95
|
+
super(client: client)
|
|
96
|
+
@next_page = LISTS_URL
|
|
97
|
+
@data_attribute = 'lists'
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require 'urbanairship'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module Urbanairship
|
|
5
|
+
module Push
|
|
6
|
+
class Location
|
|
7
|
+
include Urbanairship::Common
|
|
8
|
+
include Urbanairship::Loggable
|
|
9
|
+
|
|
10
|
+
def initialize(client: required('client'))
|
|
11
|
+
@client = client
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def name_lookup(name: required('name'), type: nil)
|
|
15
|
+
fail ArgumentError, 'name needs to be a string' unless name.is_a? String
|
|
16
|
+
fail ArgumentError, 'type needs to be a string' unless type.nil? or type.is_a? String
|
|
17
|
+
url = LOCATION_URL + '?q=' + name
|
|
18
|
+
url += '&type=' + type unless type.nil?
|
|
19
|
+
resp = @client.send_request(
|
|
20
|
+
method: 'GET',
|
|
21
|
+
url: url
|
|
22
|
+
)
|
|
23
|
+
logger.info("Retrieved location information for #{name}")
|
|
24
|
+
resp
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def coordinates_lookup(latitude: required('latitude'), longitude: required('longitude'), type: nil)
|
|
28
|
+
fail ArgumentError,
|
|
29
|
+
'latitude and longitude need to be numbers' unless latitude.is_a? Numeric and longitude.is_a? Numeric
|
|
30
|
+
fail ArgumentError, 'type needs to be a string' unless type.nil? or type.is_a? String
|
|
31
|
+
url = LOCATION_URL + latitude.to_s + ',' + longitude.to_s
|
|
32
|
+
url += '?type=' + type unless type.nil?
|
|
33
|
+
resp = @client.send_request(
|
|
34
|
+
method: 'GET',
|
|
35
|
+
url: url
|
|
36
|
+
)
|
|
37
|
+
logger.info("Retrieved location information for latitude #{latitude} and longitude #{longitude}")
|
|
38
|
+
resp
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def bounding_box_lookup(lat1: required('lat1'), long1: required('long1'),
|
|
42
|
+
lat2: required('lat2'), long2: required('long2'), type: nil)
|
|
43
|
+
|
|
44
|
+
fail ArgumentError,
|
|
45
|
+
'lat1, long1, lat2, and long2 need to be numbers' unless lat1.is_a? Numeric and long2.is_a? Numeric\
|
|
46
|
+
and lat2.is_a? Numeric and long2.is_a? Numeric
|
|
47
|
+
fail ArgumentError, 'type needs to be a string' unless type.nil? or type.is_a? String
|
|
48
|
+
url = LOCATION_URL + lat1.to_s + ',' + long1.to_s + ',' + lat2.to_s + ',' + long2.to_s
|
|
49
|
+
url += '?type=' + type unless type.nil?
|
|
50
|
+
resp = @client.send_request(
|
|
51
|
+
method: 'GET',
|
|
52
|
+
url: url
|
|
53
|
+
)
|
|
54
|
+
logger.info("Retrieved location information for bounding box with lat1 #{lat1}, long1 #{long1}," +
|
|
55
|
+
" lat2 #{lat2}, and long2 #{long2}")
|
|
56
|
+
resp
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def alias_lookup(from_alias: required('from_alias'))
|
|
60
|
+
fail ArgumentError, 'from_alias needs to be a string or an array of strings' unless from_alias.is_a? String or from_alias.is_a? Array
|
|
61
|
+
url = LOCATION_URL + 'from-alias?'
|
|
62
|
+
if from_alias.is_a? Array
|
|
63
|
+
from_alias.each do |a|
|
|
64
|
+
fail ArgumentError, 'from_alias needs to be a string or an array of strings' unless a.is_a? String
|
|
65
|
+
url += a + '&'
|
|
66
|
+
end
|
|
67
|
+
url = url.chop
|
|
68
|
+
else
|
|
69
|
+
url += from_alias
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
resp = @client.send_request(
|
|
73
|
+
method: 'GET',
|
|
74
|
+
url: url
|
|
75
|
+
)
|
|
76
|
+
logger.info("Retrieved location info from alias #{from_alias}")
|
|
77
|
+
resp
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def polygon_lookup(polygon_id: required('polygon_id'), zoom: required('zoom'))
|
|
81
|
+
fail ArgumentError, 'polygon_id needs to be a string' unless polygon_id.is_a? String
|
|
82
|
+
fail ArgumentError, 'zoom needs to be an integer' unless zoom.is_a? Integer
|
|
83
|
+
|
|
84
|
+
url = LOCATION_URL + polygon_id + '?zoom=' + zoom.to_s
|
|
85
|
+
resp = @client.send_request(
|
|
86
|
+
method: 'GET',
|
|
87
|
+
url: url
|
|
88
|
+
)
|
|
89
|
+
logger.info("Retrieved location info for polygon #{polygon_id} and zoom level #{zoom}")
|
|
90
|
+
resp
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def date_ranges
|
|
94
|
+
resp = @client.send_request(
|
|
95
|
+
method: 'GET',
|
|
96
|
+
url: SEGMENTS_URL + 'dates/'
|
|
97
|
+
)
|
|
98
|
+
logger.info('Retrieved location date ranges')
|
|
99
|
+
resp
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -10,7 +10,7 @@ module Urbanairship
|
|
|
10
10
|
class Push
|
|
11
11
|
attr_writer :client, :audience, :notification, :options,
|
|
12
12
|
:device_types, :message
|
|
13
|
-
attr_reader :device_types
|
|
13
|
+
attr_reader :device_types, :audience
|
|
14
14
|
include Urbanairship::Common
|
|
15
15
|
include Urbanairship::Loggable
|
|
16
16
|
|
|
@@ -124,7 +124,7 @@ module Urbanairship
|
|
|
124
124
|
# @return [Object] Push Response
|
|
125
125
|
def cancel
|
|
126
126
|
fail ArgumentError,
|
|
127
|
-
|
|
127
|
+
'Cannot cancel ScheduledPush without a url.' if @url.nil?
|
|
128
128
|
|
|
129
129
|
response = @client.send_request(
|
|
130
130
|
method: 'DELETE',
|
|
@@ -142,7 +142,7 @@ module Urbanairship
|
|
|
142
142
|
# @return [Object]
|
|
143
143
|
def update
|
|
144
144
|
fail ArgumentError,
|
|
145
|
-
|
|
145
|
+
'Cannot update a ScheduledPush without a url.' if @url.nil?
|
|
146
146
|
response = @client.send_request(
|
|
147
147
|
method: 'PUT',
|
|
148
148
|
body: JSON.dump(self.payload),
|
|
@@ -153,9 +153,28 @@ module Urbanairship
|
|
|
153
153
|
logger.info { pr.format }
|
|
154
154
|
pr
|
|
155
155
|
end
|
|
156
|
+
|
|
157
|
+
def list(schedule_id: required('schedule_id'))
|
|
158
|
+
fail ArgumentError,
|
|
159
|
+
'schedule_id must be a string' unless schedule_id.is_a? String
|
|
160
|
+
resp = @client.send_request(
|
|
161
|
+
method: 'GET',
|
|
162
|
+
url: SCHEDULES_URL + schedule_id
|
|
163
|
+
)
|
|
164
|
+
logger.info("Retrieved info for schedule_id #{schedule_id}")
|
|
165
|
+
resp
|
|
166
|
+
end
|
|
156
167
|
end
|
|
157
168
|
|
|
158
169
|
|
|
170
|
+
class ScheduledPushList < Urbanairship::Common::PageIterator
|
|
171
|
+
def initialize(client: required('client'))
|
|
172
|
+
super(client: client)
|
|
173
|
+
@next_page = SCHEDULES_URL
|
|
174
|
+
@data_attribute = 'schedules'
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
159
178
|
# Response to a successful push notification send or schedule.
|
|
160
179
|
class PushResponse
|
|
161
180
|
attr_reader :ok, :push_ids, :schedule_url, :operation_id, :payload, :status_code
|
data/lib/urbanairship/version.rb
CHANGED
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.
|
|
4
|
+
version: 3.2.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: 2015-
|
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: unirest
|
|
@@ -140,10 +140,12 @@ files:
|
|
|
140
140
|
- docs/examples.rst
|
|
141
141
|
- docs/exceptions.rst
|
|
142
142
|
- docs/index.rst
|
|
143
|
+
- docs/location.rst
|
|
143
144
|
- docs/named_user.rst
|
|
144
145
|
- docs/push.rst
|
|
145
146
|
- docs/reports.rst
|
|
146
147
|
- docs/segment.rst
|
|
148
|
+
- docs/static_lists.rst
|
|
147
149
|
- docs/tags.rst
|
|
148
150
|
- lib/urbanairship.rb
|
|
149
151
|
- lib/urbanairship/client.rb
|
|
@@ -153,8 +155,10 @@ files:
|
|
|
153
155
|
- lib/urbanairship/devices/devicelist.rb
|
|
154
156
|
- lib/urbanairship/devices/named_user.rb
|
|
155
157
|
- lib/urbanairship/devices/segment.rb
|
|
158
|
+
- lib/urbanairship/devices/static_lists.rb
|
|
156
159
|
- lib/urbanairship/loggable.rb
|
|
157
160
|
- lib/urbanairship/push/audience.rb
|
|
161
|
+
- lib/urbanairship/push/location.rb
|
|
158
162
|
- lib/urbanairship/push/payload.rb
|
|
159
163
|
- lib/urbanairship/push/push.rb
|
|
160
164
|
- lib/urbanairship/push/schedule.rb
|