urbanairship 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +89 -0
- data/lib/urbanairship.rb +29 -0
- data/spec/urbanairship_spec.rb +300 -0
- metadata +61 -76
data/README.markdown
CHANGED
@@ -24,6 +24,13 @@ Registering a device token
|
|
24
24
|
```ruby
|
25
25
|
Urbanairship.register_device('DEVICE-TOKEN')
|
26
26
|
```
|
27
|
+
You can also pass an alias, and a set of tags to device registration.
|
28
|
+
```ruby
|
29
|
+
Urbanairship.register_device('DEVICE-TOKEN',
|
30
|
+
:alias => 'user-123',
|
31
|
+
:tags => ['san-francisco-users']
|
32
|
+
)
|
33
|
+
```
|
27
34
|
|
28
35
|
Unregistering a device token
|
29
36
|
----------------------------
|
@@ -65,6 +72,26 @@ notifications = [
|
|
65
72
|
Urbanairship.batch_push(notifications)
|
66
73
|
```
|
67
74
|
|
75
|
+
Sending notifications to a segment
|
76
|
+
---------------------------
|
77
|
+
Urban Airship segments let you send a push notification to a subset of relevant users based on location, time, preferences, and behavior. You can read more about segments in the [Urban Airship docs](https://docs.urbanairship.com/display/DOCS/Server%3A+Segments+API).
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
notification = {
|
81
|
+
:schedule_for => [1.hour.from_now],
|
82
|
+
:segments => ['SEGMENT-ID'],
|
83
|
+
:ios => {
|
84
|
+
:aps => {
|
85
|
+
:alert => 'You have a new message!', :badge => 1
|
86
|
+
}
|
87
|
+
},
|
88
|
+
:android => {
|
89
|
+
:alert => 'You have a new message!', :badge => 1
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
Urbanairship.push_to_segment(notification)
|
94
|
+
```
|
68
95
|
|
69
96
|
Sending broadcast notifications
|
70
97
|
-------------------------------
|
@@ -111,6 +138,68 @@ Urbanairship.delete_scheduled_push(123456789)
|
|
111
138
|
Urbanairship.delete_scheduled_push(:alias => "deadbeef")
|
112
139
|
```
|
113
140
|
|
141
|
+
Tags
|
142
|
+
----
|
143
|
+
|
144
|
+
Urban Airship allows you to create tags and associate them with devices. Then you can easily send a notification to every device matching a certain tag with a single call to the push API.
|
145
|
+
|
146
|
+
### Creating a tag ###
|
147
|
+
|
148
|
+
Tags must be registered before you can use them.
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
Urbanairship.add_tag('TAG')
|
152
|
+
```
|
153
|
+
|
154
|
+
### Listing your tags ###
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
Urbanairship.tags
|
158
|
+
```
|
159
|
+
|
160
|
+
### Removing a tag ##
|
161
|
+
|
162
|
+
This will remove a tag from your set of registered tags, as well as removing that tag from any devices that are currently using it.
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
Urbanairship.remove_tag('TAG')
|
166
|
+
```
|
167
|
+
|
168
|
+
### View tags associated with device ###
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
Urbanairship.tags_for_device('DEVICE-TOKEN')
|
172
|
+
```
|
173
|
+
|
174
|
+
### Tag a device ###
|
175
|
+
|
176
|
+
```ruby
|
177
|
+
Urbanairship.tag_device(:device_token => 'DEVICE-TOKEN', :tag => 'TAG')
|
178
|
+
```
|
179
|
+
|
180
|
+
You can also tag a device during device registration.
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
Urbanairship.register_device('DEVICE-TOKEN', :tags => ['san-francisco-users'])
|
184
|
+
```
|
185
|
+
|
186
|
+
### Untag a device ###
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
Urbanairship.untag_device(:device_token => 'DEVICE-TOKEN', :tag => 'TAG')
|
190
|
+
```
|
191
|
+
|
192
|
+
### Sending a notification to all devices with a given tag ###
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
notification = {
|
196
|
+
:tags => ['san-francisco-users'],
|
197
|
+
:aps => {:alert => 'Good morning San Francisco!', :badge => 1}
|
198
|
+
}
|
199
|
+
|
200
|
+
Urbanairship.push(notification)
|
201
|
+
```
|
202
|
+
|
114
203
|
Using Urbanairship with Android
|
115
204
|
-------------------------------
|
116
205
|
|
data/lib/urbanairship.rb
CHANGED
@@ -44,6 +44,11 @@ module Urbanairship
|
|
44
44
|
do_request(:post, "/api/push/", :body => body, :authenticate_with => :master_secret)
|
45
45
|
end
|
46
46
|
|
47
|
+
def push_to_segment(options = {})
|
48
|
+
body = parse_push_options(options).to_json
|
49
|
+
do_request(:post, "/api/push/segments", :body => body, :authenticate_with => :master_secret)
|
50
|
+
end
|
51
|
+
|
47
52
|
def batch_push(notifications = [])
|
48
53
|
body = notifications.map{|notification| parse_push_options(notification)}.to_json
|
49
54
|
do_request(:post, "/api/push/batch/", :body => body, :authenticate_with => :master_secret)
|
@@ -58,6 +63,30 @@ module Urbanairship
|
|
58
63
|
do_request(:get, "/api/device_tokens/feedback/?since=#{format_time(time)}", :authenticate_with => :master_secret)
|
59
64
|
end
|
60
65
|
|
66
|
+
def tags
|
67
|
+
do_request(:get, "/api/tags/", :authenticate_with => :master_secret)
|
68
|
+
end
|
69
|
+
|
70
|
+
def add_tag(tag)
|
71
|
+
do_request(:put, "/api/tags/#{tag}", :authenticate_with => :master_secret)
|
72
|
+
end
|
73
|
+
|
74
|
+
def remove_tag(tag)
|
75
|
+
do_request(:delete, "/api/tags/#{tag}", :authenticate_with => :master_secret)
|
76
|
+
end
|
77
|
+
|
78
|
+
def tags_for_device(device_token)
|
79
|
+
do_request(:get, "/api/device_tokens/#{device_token}/tags", :authenticate_with => :master_secret)
|
80
|
+
end
|
81
|
+
|
82
|
+
def tag_device(params)
|
83
|
+
do_request(:put, "/api/device_tokens/#{params[:device_token]}/tags/#{params[:tag]}", :authenticate_with => :master_secret)
|
84
|
+
end
|
85
|
+
|
86
|
+
def untag_device(params)
|
87
|
+
do_request(:delete, "/api/device_tokens/#{params[:device_token]}/tags/#{params[:tag]}", :authenticate_with => :master_secret)
|
88
|
+
end
|
89
|
+
|
61
90
|
private
|
62
91
|
|
63
92
|
def do_request(http_method, path, options = {})
|
data/spec/urbanairship_spec.rb
CHANGED
@@ -35,6 +35,41 @@ shared_examples_for "an Urbanairship client" do
|
|
35
35
|
# feedback
|
36
36
|
FakeWeb.register_uri(:get, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/device_tokens\/feedback/, :status => ["200", "OK"], :body => "[{\"device_token\":\"token\",\"marked_inactive_on\":\"2010-10-14T19:15:13Z\",\"alias\":\"my_alias\"}]")
|
37
37
|
FakeWeb.register_uri(:get, /my_app_key2\:my_master_secret2\@go\.urbanairship.com\/api\/device_tokens\/feedback/, :status => ["500", "Internal Server Error"])
|
38
|
+
|
39
|
+
#tags
|
40
|
+
FakeWeb.register_uri(:get, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/tags/, :status => ["200", "OK"], :body => "[{\"tags\":[\"tag1\",\"tag2\"]}]")
|
41
|
+
FakeWeb.register_uri(:get, /my_app_key2\:my_master_secret2\@go\.urbanairship.com\/api\/tags/, :status => ["500", "Internal Server Error"])
|
42
|
+
|
43
|
+
#add_tag
|
44
|
+
FakeWeb.register_uri(:put, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/tags\/new_tag/, :status => ["200", "OK"])
|
45
|
+
FakeWeb.register_uri(:put, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/tags\/existing_tag/, :status => ["201", "OK"])
|
46
|
+
FakeWeb.register_uri(:put, /my_app_key2\:my_master_secret2\@go\.urbanairship.com\/api\/tags\/a_tag/, :status => ["500", "Internal Server Error"])
|
47
|
+
|
48
|
+
#remove_tag
|
49
|
+
FakeWeb.register_uri(:delete, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/tags\/non_deleted_tag/, :status => ["204", "OK"])
|
50
|
+
FakeWeb.register_uri(:delete, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/tags\/deleted_tag/, :status => ["404", "OK"])
|
51
|
+
FakeWeb.register_uri(:delete, /my_app_key2\:my_master_secret2\@go\.urbanairship.com\/api\/tags\/a_tag/, :status => ["500", "Internal Server Error"])
|
52
|
+
|
53
|
+
#tags_for_device_tokens
|
54
|
+
FakeWeb.register_uri(:get, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/device_tokens\/valid_device_token\/tags/, :status => ["200", "OK"], :body => "[{\"tags\":[\"tag1\",\"tag2\"]}]")
|
55
|
+
FakeWeb.register_uri(:get, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/device_tokens\/invalid_device_token\/tags/, :status => ["404", "OK"])
|
56
|
+
FakeWeb.register_uri(:get, /my_app_key2\:my_master_secret2\@go\.urbanairship.com\/api\/device_tokens\/a_device_token\/tags/, :status => ["500", "Internal Server Error"])
|
57
|
+
|
58
|
+
##tag_device
|
59
|
+
FakeWeb.register_uri(:put, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/device_tokens\/valid_device_token\/tags\/new_tag/, :status => ["201", "OK"])
|
60
|
+
FakeWeb.register_uri(:put, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/device_tokens\/valid_device_token\/tags\/existing_tag/, :status => ["200", "OK"])
|
61
|
+
FakeWeb.register_uri(:put, /my_app_key2\:my_master_secret2\@go\.urbanairship.com\/api\/device_tokens\/a_device_token\/tags\/a_tag/, :status => ["500", "Internal Server Error"])
|
62
|
+
|
63
|
+
#untag_device
|
64
|
+
FakeWeb.register_uri(:delete, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/device_tokens\/valid_device_token\/tags\/existing_tag/, :status => ["204", "OK"])
|
65
|
+
FakeWeb.register_uri(:delete, /my_app_key\:my_master_secret\@go\.urbanairship.com\/api\/device_tokens\/valid_device_token\/tags\/non_existant_tag/, :status => ["404", "OK"])
|
66
|
+
FakeWeb.register_uri(:delete, /my_app_key2\:my_master_secret2\@go\.urbanairship.com\/api\/device_tokens\/a_device_token\/tags\/a_tag/, :status => ["500", "Internal Server Error"])
|
67
|
+
|
68
|
+
# push to segment
|
69
|
+
FakeWeb.register_uri(:post, "https://my_app_key:my_master_secret@go.urbanairship.com/api/push/segments", :status => ["200", "OK"])
|
70
|
+
FakeWeb.register_uri(:post, "https://my_app_key2:my_master_secret2@go.urbanairship.com/api/push/segments", :status => ["400", "Bad Request"])
|
71
|
+
FakeWeb.register_uri(:post, /bad_key\:my_master_secret\@go\.urbanairship\.com/, :status => ["401", "Unauthorized"])
|
72
|
+
|
38
73
|
end
|
39
74
|
|
40
75
|
describe "configuration" do
|
@@ -56,6 +91,223 @@ shared_examples_for "an Urbanairship client" do
|
|
56
91
|
subject.master_secret.should == "asdf1234"
|
57
92
|
end
|
58
93
|
end
|
94
|
+
|
95
|
+
describe "::tags" do
|
96
|
+
before(:each) do
|
97
|
+
subject.application_key = "my_app_key"
|
98
|
+
subject.master_secret = "my_master_secret"
|
99
|
+
end
|
100
|
+
|
101
|
+
it "raises an error if call is made without an app key and master secret configured" do
|
102
|
+
subject.application_key = nil
|
103
|
+
subject.master_secret = nil
|
104
|
+
|
105
|
+
lambda {
|
106
|
+
subject.tags
|
107
|
+
}.should raise_error(RuntimeError, "Must configure application_key, master_secret before making this request.")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "uses app key and secret to sign the request" do
|
111
|
+
subject.tags
|
112
|
+
FakeWeb.last_request['authorization'].should == "Basic #{Base64::encode64('my_app_key:my_master_secret').chomp}"
|
113
|
+
end
|
114
|
+
|
115
|
+
it "returns valid tags" do
|
116
|
+
response = subject.tags
|
117
|
+
response.first.should include("tags")
|
118
|
+
response.first["tags"].should include("tag1")
|
119
|
+
response.first["tags"].should include("tag2")
|
120
|
+
end
|
121
|
+
|
122
|
+
it "success? is false when the call doesn't return 200" do
|
123
|
+
subject.application_key = "my_app_key2"
|
124
|
+
subject.master_secret = "my_master_secret2"
|
125
|
+
subject.tags.success?.should == false
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "::add_tag" do
|
131
|
+
before(:each) do
|
132
|
+
subject.application_key = "my_app_key"
|
133
|
+
subject.master_secret = "my_master_secret"
|
134
|
+
end
|
135
|
+
|
136
|
+
it "raises an error if call is made without an app key and master secret configured" do
|
137
|
+
subject.application_key = nil
|
138
|
+
subject.master_secret = nil
|
139
|
+
|
140
|
+
lambda {
|
141
|
+
subject.add_tag('a_tag')
|
142
|
+
}.should raise_error(RuntimeError, "Must configure application_key, master_secret before making this request.")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "uses app key and secret to sign the request" do
|
146
|
+
subject.add_tag('new_tag')
|
147
|
+
FakeWeb.last_request['authorization'].should == "Basic #{Base64::encode64('my_app_key:my_master_secret').chomp}"
|
148
|
+
end
|
149
|
+
|
150
|
+
it "adds a new tag" do
|
151
|
+
subject.add_tag('new_tag').success?.should == true
|
152
|
+
subject.add_tag('new_tag').code.should == "200"
|
153
|
+
end
|
154
|
+
|
155
|
+
it "adds an exisiting tag" do
|
156
|
+
subject.add_tag('existing_tag').success?.should == true
|
157
|
+
subject.add_tag('existing_tag').code.should == "201"
|
158
|
+
end
|
159
|
+
|
160
|
+
it "success? is false when the call doesn't return 200 or 201" do
|
161
|
+
subject.application_key = "my_app_key2"
|
162
|
+
subject.master_secret = "my_master_secret2"
|
163
|
+
subject.add_tag('a_tag').success?.should == false
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "::remove_tag" do
|
169
|
+
before(:each) do
|
170
|
+
subject.application_key = "my_app_key"
|
171
|
+
subject.master_secret = "my_master_secret"
|
172
|
+
end
|
173
|
+
|
174
|
+
it "raises an error if call is made without an app key and master secret configured" do
|
175
|
+
subject.application_key = nil
|
176
|
+
subject.master_secret = nil
|
177
|
+
|
178
|
+
lambda {
|
179
|
+
subject.remove_tag('a_tag')
|
180
|
+
}.should raise_error(RuntimeError, "Must configure application_key, master_secret before making this request.")
|
181
|
+
end
|
182
|
+
|
183
|
+
it "uses app key and secret to sign the request" do
|
184
|
+
subject.remove_tag('non_deleted_tag')
|
185
|
+
FakeWeb.last_request['authorization'].should == "Basic #{Base64::encode64('my_app_key:my_master_secret').chomp}"
|
186
|
+
end
|
187
|
+
|
188
|
+
it "removes a tag that has not been removed yet" do
|
189
|
+
subject.remove_tag('non_deleted_tag').success?.should == true
|
190
|
+
subject.remove_tag('non_deleted_tag').code.should == "204"
|
191
|
+
end
|
192
|
+
|
193
|
+
it "attempts to remove an already deleted tag" do
|
194
|
+
subject.remove_tag('deleted_tag').success?.should == false
|
195
|
+
subject.remove_tag('deleted_tag').code.should == "404"
|
196
|
+
end
|
197
|
+
|
198
|
+
it "success? is false when the call doesn't return 204" do
|
199
|
+
subject.application_key = "my_app_key2"
|
200
|
+
subject.master_secret = "my_master_secret2"
|
201
|
+
subject.add_tag('a_tag').success?.should == false
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "::tags_for_device" do
|
206
|
+
before(:each) do
|
207
|
+
subject.application_key = "my_app_key"
|
208
|
+
subject.master_secret = "my_master_secret"
|
209
|
+
end
|
210
|
+
|
211
|
+
it "raises an error if call is made without an app key and master secret configured" do
|
212
|
+
subject.application_key = nil
|
213
|
+
subject.master_secret = nil
|
214
|
+
|
215
|
+
lambda {
|
216
|
+
subject.tags_for_device('a_device_token')
|
217
|
+
}.should raise_error(RuntimeError, "Must configure application_key, master_secret before making this request.")
|
218
|
+
end
|
219
|
+
|
220
|
+
it "uses app key and secret to sign the request" do
|
221
|
+
subject.tags_for_device('valid_device_token')
|
222
|
+
FakeWeb.last_request['authorization'].should == "Basic #{Base64::encode64('my_app_key:my_master_secret').chomp}"
|
223
|
+
end
|
224
|
+
|
225
|
+
it "returns valid tags for a device" do
|
226
|
+
response = subject.tags_for_device('valid_device_token')
|
227
|
+
response.first.should include("tags")
|
228
|
+
response.first["tags"].should include("tag1")
|
229
|
+
response.first["tags"].should include("tag2")
|
230
|
+
response.code.should == "200"
|
231
|
+
end
|
232
|
+
|
233
|
+
it "returns invalid response for device token that is not found or registered" do
|
234
|
+
response = subject.tags_for_device('invalid_device_token')
|
235
|
+
response.code.should == "404"
|
236
|
+
end
|
237
|
+
|
238
|
+
it "success? is false when the call doesn't return 200" do
|
239
|
+
subject.application_key = "my_app_key2"
|
240
|
+
subject.master_secret = "my_master_secret2"
|
241
|
+
subject.tags_for_device('a_device_token').success?.should == false
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
describe "::tag_device" do
|
246
|
+
before(:each) do
|
247
|
+
subject.application_key = "my_app_key"
|
248
|
+
subject.master_secret = "my_master_secret"
|
249
|
+
end
|
250
|
+
|
251
|
+
it "raises an error if call is made without an app key and master secret configured" do
|
252
|
+
subject.application_key = nil
|
253
|
+
subject.master_secret = nil
|
254
|
+
|
255
|
+
lambda {
|
256
|
+
subject.tag_device({:device_token => 'a_device_token', :tag => 'a_tag'})
|
257
|
+
}.should raise_error(RuntimeError, "Must configure application_key, master_secret before making this request.")
|
258
|
+
end
|
259
|
+
|
260
|
+
it "uses app key and secret to sign the request" do
|
261
|
+
subject.tag_device({:device_token => 'valid_device_token', :tag => 'new_tag'})
|
262
|
+
FakeWeb.last_request['authorization'].should == "Basic #{Base64::encode64('my_app_key:my_master_secret').chomp}"
|
263
|
+
end
|
264
|
+
|
265
|
+
it "adds a valid device token to tag" do
|
266
|
+
response = subject.tag_device({:device_token => 'valid_device_token', :tag => 'new_tag'})
|
267
|
+
response.code.should == "201"
|
268
|
+
response.success?.should == true
|
269
|
+
end
|
270
|
+
|
271
|
+
it "adds a valid device token to an existing tag" do
|
272
|
+
response = subject.tag_device({:device_token => 'valid_device_token', :tag => 'existing_tag'})
|
273
|
+
response.code.should == "200"
|
274
|
+
response.success?.should == true
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
describe "::untag_device" do
|
279
|
+
before(:each) do
|
280
|
+
subject.application_key = "my_app_key"
|
281
|
+
subject.master_secret = "my_master_secret"
|
282
|
+
end
|
283
|
+
|
284
|
+
it "raises an error if call is made without an app key and master secret configured" do
|
285
|
+
subject.application_key = nil
|
286
|
+
subject.master_secret = nil
|
287
|
+
|
288
|
+
lambda {
|
289
|
+
subject.untag_device({:device_token => 'a_device_token', :tag => 'a_tag'})
|
290
|
+
}.should raise_error(RuntimeError, "Must configure application_key, master_secret before making this request.")
|
291
|
+
end
|
292
|
+
|
293
|
+
it "uses app key and secret to sign the request" do
|
294
|
+
subject.untag_device({:device_token => 'valid_device_token', :tag => 'existing_tag'})
|
295
|
+
FakeWeb.last_request['authorization'].should == "Basic #{Base64::encode64('my_app_key:my_master_secret').chomp}"
|
296
|
+
end
|
297
|
+
|
298
|
+
it "removes a valid device token from a tag" do
|
299
|
+
response = subject.untag_device({:device_token => 'valid_device_token', :tag => 'existing_tag'})
|
300
|
+
response.code.should == "204"
|
301
|
+
response.success?.should == true
|
302
|
+
end
|
303
|
+
|
304
|
+
it "removes a device token from a tag that it is not associated with" do
|
305
|
+
response = subject.untag_device({:device_token => 'valid_device_token', :tag => 'non_existant_tag'})
|
306
|
+
response.code.should == "404"
|
307
|
+
response.success?.should == false
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
59
311
|
|
60
312
|
describe "::register_device" do
|
61
313
|
before(:each) do
|
@@ -270,6 +522,54 @@ shared_examples_for "an Urbanairship client" do
|
|
270
522
|
subject.push.success?.should == false
|
271
523
|
end
|
272
524
|
end
|
525
|
+
|
526
|
+
describe "::push_to_segment" do
|
527
|
+
before(:each) do
|
528
|
+
@valid_params = {:segments => ['segment-id'], :aps => {:alert => 'foo'}}
|
529
|
+
subject.application_key = "my_app_key"
|
530
|
+
subject.master_secret = "my_master_secret"
|
531
|
+
end
|
532
|
+
|
533
|
+
it "raises an error if call is made without an app key and master secret configured" do
|
534
|
+
subject.application_key = nil
|
535
|
+
subject.master_secret = nil
|
536
|
+
|
537
|
+
lambda {
|
538
|
+
subject.push(@valid_params)
|
539
|
+
}.should raise_error(RuntimeError, "Must configure application_key, master_secret before making this request.")
|
540
|
+
end
|
541
|
+
|
542
|
+
it "uses app key and secret to sign the request" do
|
543
|
+
subject.push_to_segment(@valid_params)
|
544
|
+
FakeWeb.last_request['authorization'].should == "Basic #{Base64::encode64('my_app_key:my_master_secret').chomp}"
|
545
|
+
end
|
546
|
+
|
547
|
+
it "returns true when it successfully pushes a notification" do
|
548
|
+
subject.push_to_segment(@valid_params).success?.should == true
|
549
|
+
end
|
550
|
+
|
551
|
+
it "returns false when the authorization is invalid" do
|
552
|
+
subject.application_key = "bad_key"
|
553
|
+
subject.push_to_segment(@valid_params).success?.should == false
|
554
|
+
end
|
555
|
+
|
556
|
+
it "adds schedule_for to the JSON payload" do
|
557
|
+
time = Time.parse("Oct 17th, 2010, 8:00 PM UTC")
|
558
|
+
subject.push_to_segment(@valid_params.merge(:schedule_for => [time]))
|
559
|
+
request_json['schedule_for'].should == ['2010-10-17T20:00:00Z']
|
560
|
+
end
|
561
|
+
|
562
|
+
it "only attempts to format schedule_for if it is a time object" do
|
563
|
+
subject.push_to_segment(@valid_params.merge(:schedule_for => ["2010-10-10 09:09:09 UTC"]))
|
564
|
+
request_json['schedule_for'].should == ['2010-10-10T09:09:09Z']
|
565
|
+
end
|
566
|
+
|
567
|
+
it "returns false if urbanairship responds with a non-200 response" do
|
568
|
+
subject.application_key = "my_app_key2"
|
569
|
+
subject.master_secret = "my_master_secret2"
|
570
|
+
subject.push_to_segment.success?.should == false
|
571
|
+
end
|
572
|
+
end
|
273
573
|
|
274
574
|
describe "::batch_push" do
|
275
575
|
before(:each) do
|
metadata
CHANGED
@@ -1,75 +1,72 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: urbanairship
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.2.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 2.2.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Groupon, Inc.
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: json
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rspec
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
47
38
|
type: :development
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: fakeweb
|
51
39
|
prerelease: false
|
52
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
41
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fakeweb
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
61
54
|
type: :development
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Urbanairship is a Ruby library for interacting with the Urban Airship
|
63
|
+
(http://urbanairship.com) API.
|
64
|
+
email:
|
65
65
|
- rubygems@groupon.com
|
66
66
|
executables: []
|
67
|
-
|
68
67
|
extensions: []
|
69
|
-
|
70
68
|
extra_rdoc_files: []
|
71
|
-
|
72
|
-
files:
|
69
|
+
files:
|
73
70
|
- README.markdown
|
74
71
|
- LICENSE
|
75
72
|
- Rakefile
|
@@ -78,43 +75,31 @@ files:
|
|
78
75
|
- spec/response_spec.rb
|
79
76
|
- spec/spec_helper.rb
|
80
77
|
- spec/urbanairship_spec.rb
|
81
|
-
has_rdoc: true
|
82
78
|
homepage: http://github.com/groupon/urbanairship
|
83
79
|
licenses: []
|
84
|
-
|
85
80
|
post_install_message:
|
86
81
|
rdoc_options: []
|
87
|
-
|
88
|
-
require_paths:
|
82
|
+
require_paths:
|
89
83
|
- lib
|
90
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
85
|
none: false
|
92
|
-
requirements:
|
93
|
-
- -
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
hash: 59
|
96
|
-
segments:
|
97
|
-
- 1
|
98
|
-
- 8
|
99
|
-
- 6
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
100
89
|
version: 1.8.6
|
101
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
91
|
none: false
|
103
|
-
requirements:
|
104
|
-
- -
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
segments:
|
108
|
-
- 0
|
109
|
-
version: "0"
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
110
96
|
requirements: []
|
111
|
-
|
112
97
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.8.24
|
114
99
|
signing_key:
|
115
100
|
specification_version: 3
|
116
101
|
summary: A Ruby wrapper for the Urban Airship API
|
117
|
-
test_files:
|
102
|
+
test_files:
|
118
103
|
- spec/response_spec.rb
|
119
104
|
- spec/spec_helper.rb
|
120
105
|
- spec/urbanairship_spec.rb
|