urbanairship 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +33 -10
- data/lib/urbanairship.rb +19 -36
- data/lib/urbanairship/response.rb +33 -0
- data/spec/response_spec.rb +77 -0
- data/spec/spec_helper.rb +14 -1
- data/spec/urbanairship_spec.rb +22 -59
- metadata +79 -46
data/README.markdown
CHANGED
@@ -22,13 +22,13 @@ Usage
|
|
22
22
|
Registering a device token
|
23
23
|
--------------------------
|
24
24
|
```ruby
|
25
|
-
Urbanairship.register_device
|
25
|
+
Urbanairship.register_device('DEVICE-TOKEN')
|
26
26
|
```
|
27
27
|
|
28
28
|
Unregistering a device token
|
29
29
|
----------------------------
|
30
30
|
```ruby
|
31
|
-
Urbanairship.unregister_device
|
31
|
+
Urbanairship.unregister_device('DEVICE-TOKEN')
|
32
32
|
```
|
33
33
|
|
34
34
|
Sending a push notification
|
@@ -40,7 +40,10 @@ notification = {
|
|
40
40
|
:aps => {:alert => 'You have a new message!', :badge => 1}
|
41
41
|
}
|
42
42
|
|
43
|
-
Urbanairship.push
|
43
|
+
Urbanairship.push(notification) # =>
|
44
|
+
# {
|
45
|
+
# "scheduled_notifications" => ["https://go.urbanairship.com/api/push/scheduled/123456"]
|
46
|
+
# }
|
44
47
|
```
|
45
48
|
|
46
49
|
Batching push notification sends
|
@@ -48,7 +51,7 @@ Batching push notification sends
|
|
48
51
|
```ruby
|
49
52
|
notifications = [
|
50
53
|
{
|
51
|
-
:schedule_for => [{ :alias => 'deadbeef', :scheduled_time => 1.hour.from_now }],
|
54
|
+
:schedule_for => [{ :alias => 'deadbeef', :scheduled_time => 1.hour.from_now }],
|
52
55
|
:device_tokens => ['DEVICE-TOKEN-ONE', 'DEVICE-TOKEN-TWO'],
|
53
56
|
:aps => {:alert => 'You have a new message!', :badge => 1}
|
54
57
|
},
|
@@ -59,7 +62,7 @@ notifications = [
|
|
59
62
|
}
|
60
63
|
]
|
61
64
|
|
62
|
-
Urbanairship.batch_push
|
65
|
+
Urbanairship.batch_push(notifications)
|
63
66
|
```
|
64
67
|
|
65
68
|
|
@@ -73,7 +76,7 @@ notification = {
|
|
73
76
|
:aps => {:alert => 'Important announcement!', :badge => 1}
|
74
77
|
}
|
75
78
|
|
76
|
-
Urbanairship.broadcast_push
|
79
|
+
Urbanairship.broadcast_push(notification)
|
77
80
|
```
|
78
81
|
|
79
82
|
Polling the feedback API
|
@@ -82,7 +85,7 @@ The first time you attempt to send a push notification to a device that has unin
|
|
82
85
|
|
83
86
|
```ruby
|
84
87
|
# find all device tokens deactivated in the past 24 hours
|
85
|
-
Urbanairship.feedback
|
88
|
+
Urbanairship.feedback(24.hours.ago) # =>
|
86
89
|
# [
|
87
90
|
# {
|
88
91
|
# "marked_inactive_on"=>"2011-06-03 22:53:23",
|
@@ -103,7 +106,27 @@ Deleting scheduled notifications
|
|
103
106
|
If you know the alias or id of a scheduled push notification then you can delete it from Urban Airship's queue and it will not be delivered.
|
104
107
|
|
105
108
|
```ruby
|
106
|
-
Urbanairship.delete_scheduled_push("123456789")
|
107
|
-
Urbanairship.delete_scheduled_push(123456789)
|
108
|
-
Urbanairship.delete_scheduled_push(:alias => "deadbeef")
|
109
|
+
Urbanairship.delete_scheduled_push("123456789")
|
110
|
+
Urbanairship.delete_scheduled_push(123456789)
|
111
|
+
Urbanairship.delete_scheduled_push(:alias => "deadbeef")
|
112
|
+
```
|
113
|
+
|
114
|
+
-----------------------------
|
115
|
+
|
116
|
+
Note: all public library methods will return either an array or a hash, depending on the response from the Urban Airship API. In addition, you can inspect these objects to find out if they were successful or not, and what the http response code from Urban Airship was.
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
response = Urbanairship.push(payload)
|
120
|
+
response.success? # => true
|
121
|
+
response.code # => '200'
|
122
|
+
response.inspect # => "{\"scheduled_notifications\"=>[\"https://go.urbanairship.com/api/push/scheduled/123456\"]}"
|
123
|
+
```
|
124
|
+
|
125
|
+
If the call to Urban Airship times out, you'll get a response object with a '503' code.
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
response = Urbanairship.feedback(1.year.ago)
|
129
|
+
response.success? # => false
|
130
|
+
response.code # => '503'
|
131
|
+
response.inspect # => "{\"error\"=>\"Request timeout\"}"
|
109
132
|
```
|
data/lib/urbanairship.rb
CHANGED
@@ -2,6 +2,8 @@ require 'json'
|
|
2
2
|
require 'net/https'
|
3
3
|
require 'time'
|
4
4
|
|
5
|
+
require File.join(File.dirname(__FILE__), 'urbanairship/response')
|
6
|
+
|
5
7
|
module Urbanairship
|
6
8
|
begin
|
7
9
|
require 'system_timer'
|
@@ -15,58 +17,39 @@ module Urbanairship
|
|
15
17
|
attr_accessor :application_key, :application_secret, :master_secret, :logger, :request_timeout
|
16
18
|
|
17
19
|
def register_device(device_token, options = {})
|
18
|
-
|
19
|
-
|
20
|
-
request.add_field "Content-Type", "application/json" unless options.empty?
|
21
|
-
end
|
22
|
-
|
23
|
-
response && %w(200 201).include?(response.code)
|
20
|
+
body = parse_register_options(options).to_json
|
21
|
+
do_request(:put, "/api/device_tokens/#{device_token}", :body => body, :authenticate_with => :application_secret)
|
24
22
|
end
|
25
23
|
|
26
24
|
def unregister_device(device_token)
|
27
|
-
|
28
|
-
response && response.code == "204"
|
25
|
+
do_request(:delete, "/api/device_tokens/#{device_token}", :authenticate_with => :application_secret)
|
29
26
|
end
|
30
27
|
|
31
28
|
def delete_scheduled_push(param)
|
32
|
-
path =
|
33
|
-
|
34
|
-
response && response.code == "204"
|
29
|
+
path = param.is_a?(Hash) ? "/api/push/scheduled/alias/#{param[:alias].to_s}" : "/api/push/scheduled/#{param.to_s}"
|
30
|
+
do_request(:delete, path, :authenticate_with => :master_secret)
|
35
31
|
end
|
36
32
|
|
37
33
|
def push(options = {})
|
38
|
-
|
39
|
-
|
40
|
-
request.add_field "Content-Type", "application/json"
|
41
|
-
end
|
42
|
-
|
43
|
-
response && response.code == "200"
|
34
|
+
body = parse_push_options(options).to_json
|
35
|
+
do_request(:post, "/api/push/", :body => body, :authenticate_with => :master_secret)
|
44
36
|
end
|
45
37
|
|
46
38
|
def batch_push(notifications = [])
|
47
|
-
|
48
|
-
|
49
|
-
request.add_field "Content-Type", "application/json"
|
50
|
-
end
|
51
|
-
|
52
|
-
response && response.code == "200"
|
39
|
+
body = notifications.map{|notification| parse_push_options(notification)}.to_json
|
40
|
+
do_request(:post, "/api/push/batch/", :body => body, :authenticate_with => :master_secret)
|
53
41
|
end
|
54
42
|
|
55
43
|
def broadcast_push(options = {})
|
56
|
-
|
57
|
-
|
58
|
-
request.add_field "Content-Type", "application/json"
|
59
|
-
end
|
60
|
-
|
61
|
-
response && response.code == "200"
|
44
|
+
body = parse_push_options(options).to_json
|
45
|
+
do_request(:post, "/api/push/broadcast/", :body => body, :authenticate_with => :master_secret)
|
62
46
|
end
|
63
47
|
|
64
48
|
def feedback(time)
|
65
|
-
|
66
|
-
response && response.code == "200" ? JSON.parse(response.body) : false
|
49
|
+
do_request(:get, "/api/device_tokens/feedback/?since=#{format_time(time)}", :authenticate_with => :master_secret)
|
67
50
|
end
|
68
51
|
|
69
|
-
|
52
|
+
private
|
70
53
|
|
71
54
|
def do_request(http_method, path, options = {})
|
72
55
|
verify_configuration_values(:application_key, options[:authenticate_with])
|
@@ -75,18 +58,18 @@ module Urbanairship
|
|
75
58
|
|
76
59
|
request = klass.new(path)
|
77
60
|
request.basic_auth @application_key, instance_variable_get("@#{options[:authenticate_with]}")
|
78
|
-
|
79
|
-
|
61
|
+
request.add_field "Content-Type", "application/json"
|
62
|
+
request.body = options[:body] if options[:body]
|
80
63
|
|
81
64
|
Timer.timeout(request_timeout) do
|
82
65
|
start_time = Time.now
|
83
66
|
response = http_client.request(request)
|
84
67
|
log_request_and_response(request, response, Time.now - start_time)
|
85
|
-
response
|
68
|
+
Urbanairship::Response.wrap(response)
|
86
69
|
end
|
87
70
|
rescue Timeout::Error
|
88
71
|
logger.error "Urbanairship request timed out after #{request_timeout} seconds: [#{http_method} #{request.path} #{request.body}]"
|
89
|
-
|
72
|
+
Urbanairship::Response.wrap(nil, :body => {:error => 'Request timeout'}, :code => '503')
|
90
73
|
end
|
91
74
|
|
92
75
|
def verify_configuration_values(*symbols)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Urbanairship
|
2
|
+
module Response
|
3
|
+
module InstanceMethods
|
4
|
+
attr_accessor :ua_response, :ua_options
|
5
|
+
|
6
|
+
def code
|
7
|
+
(ua_options[:code] || ua_response.code).to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
def success?
|
11
|
+
!!(code =~ /^2/)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.wrap(response, options = {})
|
16
|
+
if options[:body]
|
17
|
+
output = options[:body]
|
18
|
+
else
|
19
|
+
begin
|
20
|
+
output = JSON.parse(response.body || '{}')
|
21
|
+
rescue JSON::ParserError
|
22
|
+
output = {}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
output.extend(Urbanairship::Response::InstanceMethods)
|
27
|
+
output.ua_response = response
|
28
|
+
output.ua_options = options
|
29
|
+
|
30
|
+
return output
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
describe Urbanairship::Response do
|
2
|
+
|
3
|
+
before do
|
4
|
+
FakeWeb.allow_net_connect = false
|
5
|
+
end
|
6
|
+
|
7
|
+
context "#code" do
|
8
|
+
subject { Urbanairship.register_device("new_device_token") }
|
9
|
+
|
10
|
+
before do
|
11
|
+
FakeWeb.register_uri(:put, "https://my_app_key:my_app_secret@go.urbanairship.com/api/device_tokens/new_device_token", :status => ["201", "Created"])
|
12
|
+
FakeWeb.register_uri(:put, /bad_key\:my_app_secret\@go\.urbanairship\.com/, :status => ["401", "Unauthorized"])
|
13
|
+
Urbanairship.application_secret = "my_app_secret"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be set correctly on new registraion token" do
|
17
|
+
Urbanairship.application_key = "my_app_key"
|
18
|
+
subject.code.should eql '201'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should set correctly on unauthhorized" do
|
22
|
+
Urbanairship.application_key = "bad_key"
|
23
|
+
subject.code.should eql '401'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "#success?" do
|
28
|
+
subject { Urbanairship.register_device("new_device_token") }
|
29
|
+
|
30
|
+
before do
|
31
|
+
FakeWeb.register_uri(:put, "https://my_app_key:my_app_secret@go.urbanairship.com/api/device_tokens/new_device_token", :status => ["201", "Created"])
|
32
|
+
FakeWeb.register_uri(:put, /bad_key\:my_app_secret\@go\.urbanairship\.com/, :status => ["401", "Unauthorized"])
|
33
|
+
Urbanairship.application_secret = "my_app_secret"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should be true with good key" do
|
37
|
+
Urbanairship.application_key = "my_app_key"
|
38
|
+
subject.success?.should == true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should be false with bad key" do
|
42
|
+
Urbanairship.application_key = "bad_key"
|
43
|
+
subject.success?.should == false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "body array accessor" do
|
48
|
+
subject { Urbanairship.feedback(Time.now) }
|
49
|
+
|
50
|
+
before do
|
51
|
+
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\"},{\"device_token\":\"token2\",\"marked_inactive_on\":\"2010-10-14T19:15:13Z\",\"alias\":\"my_alias\"}]")
|
52
|
+
Urbanairship.application_secret = "my_app_secret"
|
53
|
+
Urbanairship.application_key = "my_app_key"
|
54
|
+
Urbanairship.master_secret = "my_master_secret"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should set up correct indexes" do
|
58
|
+
subject[0]['device_token'].should eql "token"
|
59
|
+
subject[1]['device_token'].should eql "token2"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "non array response" do
|
64
|
+
subject { Urbanairship.feedback(Time.now) }
|
65
|
+
|
66
|
+
before do
|
67
|
+
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\"}")
|
68
|
+
Urbanairship.application_secret = "my_app_secret"
|
69
|
+
Urbanairship.application_key = "my_app_key"
|
70
|
+
Urbanairship.master_secret = "my_master_secret"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should set up correct keys" do
|
74
|
+
subject['device_token'].should eql "token"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
require 'base64'
|
2
2
|
require 'fakeweb'
|
3
3
|
|
4
|
-
require File.
|
4
|
+
require File.join(File.dirname(__FILE__), '/../lib/urbanairship')
|
5
|
+
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.after(:each) do
|
9
|
+
# reset configuration
|
10
|
+
Urbanairship.application_key = nil
|
11
|
+
Urbanairship.application_secret = nil
|
12
|
+
Urbanairship.master_secret = nil
|
13
|
+
Urbanairship.logger = nil
|
14
|
+
|
15
|
+
FakeWeb.instance_variable_set("@last_request", nil)
|
16
|
+
end
|
17
|
+
end
|
data/spec/urbanairship_spec.rb
CHANGED
@@ -35,16 +35,6 @@ describe Urbanairship do
|
|
35
35
|
FakeWeb.register_uri(:get, /my_app_key2\:my_master_secret2\@go\.urbanairship.com\/api\/device_tokens\/feedback/, :status => ["500", "Internal Server Error"])
|
36
36
|
end
|
37
37
|
|
38
|
-
after(:each) do
|
39
|
-
# reset configuration
|
40
|
-
Urbanairship.application_key = nil
|
41
|
-
Urbanairship.application_secret = nil
|
42
|
-
Urbanairship.master_secret = nil
|
43
|
-
Urbanairship.logger = nil
|
44
|
-
|
45
|
-
FakeWeb.instance_variable_set("@last_request", nil)
|
46
|
-
end
|
47
|
-
|
48
38
|
describe "configuration" do
|
49
39
|
it "enables you to configure the application key" do
|
50
40
|
Urbanairship.application_key.should be_nil
|
@@ -92,30 +82,20 @@ describe Urbanairship do
|
|
92
82
|
end
|
93
83
|
|
94
84
|
it "returns true when the device is registered for the first time" do
|
95
|
-
Urbanairship.register_device("new_device_token").should == true
|
85
|
+
Urbanairship.register_device("new_device_token").success?.should == true
|
96
86
|
end
|
97
87
|
|
98
88
|
it "returns true when the device is registered again" do
|
99
|
-
Urbanairship.register_device("existing_device_token").should == true
|
89
|
+
Urbanairship.register_device("existing_device_token").success?.should == true
|
100
90
|
end
|
101
91
|
|
102
92
|
it "returns false when the authorization is invalid" do
|
103
93
|
Urbanairship.application_key = "bad_key"
|
104
|
-
Urbanairship.register_device("new_device_token").should == false
|
105
|
-
end
|
106
|
-
|
107
|
-
it "doesn't set the content-type header to application/json if options are empty" do
|
108
|
-
Urbanairship.register_device("device_token_one")
|
109
|
-
FakeWeb.last_request['content-type'].should_not == 'application/json'
|
94
|
+
Urbanairship.register_device("new_device_token").success?.should == false
|
110
95
|
end
|
111
96
|
|
112
97
|
it "accepts an alias" do
|
113
|
-
Urbanairship.register_device("device_token_one", @valid_params).should == true
|
114
|
-
end
|
115
|
-
|
116
|
-
it "sets the content-type header to application/json when options are added" do
|
117
|
-
Urbanairship.register_device("device_token_one", @valid_params)
|
118
|
-
FakeWeb.last_request['content-type'].should == 'application/json'
|
98
|
+
Urbanairship.register_device("device_token_one", @valid_params).success?.should == true
|
119
99
|
end
|
120
100
|
|
121
101
|
it "adds alias to the JSON payload" do
|
@@ -155,13 +135,13 @@ describe Urbanairship do
|
|
155
135
|
end
|
156
136
|
|
157
137
|
it "returns true when the device is successfully unregistered" do
|
158
|
-
Urbanairship.unregister_device("key_to_delete").should == true
|
138
|
+
Urbanairship.unregister_device("key_to_delete").success?.should == true
|
159
139
|
FakeWeb.last_request.body.should be_nil
|
160
140
|
end
|
161
141
|
|
162
142
|
it "returns false when the authorization is invalid" do
|
163
143
|
Urbanairship.application_key = "bad_key"
|
164
|
-
Urbanairship.unregister_device("key_to_delete").should == false
|
144
|
+
Urbanairship.unregister_device("key_to_delete").success?.should == false
|
165
145
|
end
|
166
146
|
end
|
167
147
|
|
@@ -201,13 +181,13 @@ describe Urbanairship do
|
|
201
181
|
end
|
202
182
|
|
203
183
|
it "returns true when the push notification is successfully deleted" do
|
204
|
-
Urbanairship.delete_scheduled_push("123456789").should == true
|
184
|
+
Urbanairship.delete_scheduled_push("123456789").success?.should == true
|
205
185
|
FakeWeb.last_request.body.should be_nil
|
206
186
|
end
|
207
187
|
|
208
188
|
it "returns false when the authorization is invalid" do
|
209
189
|
Urbanairship.application_key = "bad_key"
|
210
|
-
Urbanairship.delete_scheduled_push("123456789").should == false
|
190
|
+
Urbanairship.delete_scheduled_push("123456789").success?.should == false
|
211
191
|
end
|
212
192
|
end
|
213
193
|
|
@@ -233,17 +213,12 @@ describe Urbanairship do
|
|
233
213
|
end
|
234
214
|
|
235
215
|
it "returns true when it successfully pushes a notification" do
|
236
|
-
Urbanairship.push(@valid_params).should == true
|
216
|
+
Urbanairship.push(@valid_params).success?.should == true
|
237
217
|
end
|
238
218
|
|
239
219
|
it "returns false when the authorization is invalid" do
|
240
220
|
Urbanairship.application_key = "bad_key"
|
241
|
-
Urbanairship.push(@valid_params).should == false
|
242
|
-
end
|
243
|
-
|
244
|
-
it "sets the content-type header to application/json" do
|
245
|
-
Urbanairship.push(@valid_params)
|
246
|
-
FakeWeb.last_request['content-type'].should == 'application/json'
|
221
|
+
Urbanairship.push(@valid_params).success?.should == false
|
247
222
|
end
|
248
223
|
|
249
224
|
it "adds schedule_for to the JSON payload" do
|
@@ -260,7 +235,7 @@ describe Urbanairship do
|
|
260
235
|
it "returns false if urbanairship responds with a non-200 response" do
|
261
236
|
Urbanairship.application_key = "my_app_key2"
|
262
237
|
Urbanairship.master_secret = "my_master_secret2"
|
263
|
-
Urbanairship.push.should == false
|
238
|
+
Urbanairship.push.success?.should == false
|
264
239
|
end
|
265
240
|
end
|
266
241
|
|
@@ -289,17 +264,12 @@ describe Urbanairship do
|
|
289
264
|
end
|
290
265
|
|
291
266
|
it "returns true when it successfully pushes a notification" do
|
292
|
-
Urbanairship.batch_push(@valid_params).should == true
|
267
|
+
Urbanairship.batch_push(@valid_params).success?.should == true
|
293
268
|
end
|
294
269
|
|
295
270
|
it "returns false when the authorization is invalid" do
|
296
271
|
Urbanairship.application_key = "bad_key"
|
297
|
-
Urbanairship.batch_push(@valid_params).should == false
|
298
|
-
end
|
299
|
-
|
300
|
-
it "sets the content-type header to application/json" do
|
301
|
-
Urbanairship.batch_push(@valid_params)
|
302
|
-
FakeWeb.last_request['content-type'].should == 'application/json'
|
272
|
+
Urbanairship.batch_push(@valid_params).success?.should == false
|
303
273
|
end
|
304
274
|
|
305
275
|
it "adds schedule_for to the JSON payload" do
|
@@ -318,7 +288,7 @@ describe Urbanairship do
|
|
318
288
|
it "returns false if urbanairship responds with a non-200 response" do
|
319
289
|
Urbanairship.application_key = "my_app_key2"
|
320
290
|
Urbanairship.master_secret = "my_master_secret2"
|
321
|
-
Urbanairship.batch_push.should == false
|
291
|
+
Urbanairship.batch_push.success?.should == false
|
322
292
|
end
|
323
293
|
end
|
324
294
|
|
@@ -344,17 +314,12 @@ describe Urbanairship do
|
|
344
314
|
end
|
345
315
|
|
346
316
|
it "returns true when it successfully pushes a notification" do
|
347
|
-
Urbanairship.broadcast_push(@valid_params).should == true
|
317
|
+
Urbanairship.broadcast_push(@valid_params).success?.should == true
|
348
318
|
end
|
349
319
|
|
350
320
|
it "returns false when the authorization is invalid" do
|
351
321
|
Urbanairship.application_key = "bad_key"
|
352
|
-
Urbanairship.broadcast_push(@valid_params).should == false
|
353
|
-
end
|
354
|
-
|
355
|
-
it "sets the content-type header to application/json" do
|
356
|
-
Urbanairship.broadcast_push(@valid_params)
|
357
|
-
FakeWeb.last_request['content-type'].should == 'application/json'
|
322
|
+
Urbanairship.broadcast_push(@valid_params).success?.should == false
|
358
323
|
end
|
359
324
|
|
360
325
|
it "adds schedule_for to the JSON payload" do
|
@@ -373,7 +338,7 @@ describe Urbanairship do
|
|
373
338
|
it "returns false if urbanairship responds with a non-200 response" do
|
374
339
|
Urbanairship.application_key = "my_app_key2"
|
375
340
|
Urbanairship.master_secret = "my_master_secret2"
|
376
|
-
Urbanairship.broadcast_push.should == false
|
341
|
+
Urbanairship.broadcast_push.success?.should == false
|
377
342
|
end
|
378
343
|
end
|
379
344
|
|
@@ -411,17 +376,15 @@ describe Urbanairship do
|
|
411
376
|
|
412
377
|
it "returns an array of responses from the feedback API" do
|
413
378
|
response = Urbanairship.feedback(Time.now)
|
414
|
-
response.
|
415
|
-
response[0].
|
416
|
-
response[0].
|
417
|
-
response[0].keys.should include("alias")
|
379
|
+
response[0].should include("device_token")
|
380
|
+
response[0].should include("marked_inactive_on")
|
381
|
+
response[0].should include("alias")
|
418
382
|
end
|
419
383
|
|
420
|
-
it "
|
384
|
+
it "success? is false when the call doesn't return 200" do
|
421
385
|
Urbanairship.application_key = "my_app_key2"
|
422
386
|
Urbanairship.master_secret = "my_master_secret2"
|
423
|
-
|
424
|
-
Urbanairship.feedback(Time.now).should == false
|
387
|
+
Urbanairship.feedback(Time.now).success?.should == false
|
425
388
|
end
|
426
389
|
end
|
427
390
|
|
metadata
CHANGED
@@ -1,87 +1,120 @@
|
|
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
|
+
hash: 15
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Groupon, Inc.
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-02-17 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
15
22
|
name: json
|
16
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
25
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
22
33
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
26
36
|
name: rspec
|
27
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
33
47
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
37
50
|
name: fakeweb
|
38
|
-
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
53
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
44
61
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
(http://urbanairship.com) API.
|
49
|
-
email:
|
62
|
+
version_requirements: *id003
|
63
|
+
description: Urbanairship is a Ruby library for interacting with the Urban Airship (http://urbanairship.com) API.
|
64
|
+
email:
|
50
65
|
- rubygems@groupon.com
|
51
66
|
executables: []
|
67
|
+
|
52
68
|
extensions: []
|
69
|
+
|
53
70
|
extra_rdoc_files: []
|
54
|
-
|
71
|
+
|
72
|
+
files:
|
55
73
|
- README.markdown
|
56
74
|
- LICENSE
|
57
75
|
- Rakefile
|
76
|
+
- lib/urbanairship/response.rb
|
58
77
|
- lib/urbanairship.rb
|
78
|
+
- spec/response_spec.rb
|
59
79
|
- spec/spec_helper.rb
|
60
80
|
- spec/urbanairship_spec.rb
|
81
|
+
has_rdoc: true
|
61
82
|
homepage: http://github.com/groupon/urbanairship
|
62
83
|
licenses: []
|
84
|
+
|
63
85
|
post_install_message:
|
64
86
|
rdoc_options: []
|
65
|
-
|
87
|
+
|
88
|
+
require_paths:
|
66
89
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
91
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 59
|
96
|
+
segments:
|
97
|
+
- 1
|
98
|
+
- 8
|
99
|
+
- 6
|
72
100
|
version: 1.8.6
|
73
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
102
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
79
110
|
requirements: []
|
111
|
+
|
80
112
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.6.2
|
82
114
|
signing_key:
|
83
115
|
specification_version: 3
|
84
116
|
summary: A Ruby wrapper for the Urban Airship API
|
85
|
-
test_files:
|
117
|
+
test_files:
|
118
|
+
- spec/response_spec.rb
|
86
119
|
- spec/spec_helper.rb
|
87
120
|
- spec/urbanairship_spec.rb
|