zero_push 2.2.0 → 2.3.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.
- data/Gemfile.lock +1 -1
- data/lib/zero_push/client.rb +4 -2
- data/lib/zero_push/version.rb +1 -1
- data/lib/zero_push.rb +2 -2
- data/spec/fixtures/register.yml +49 -0
- data/spec/zero_push_client_spec.rb +15 -5
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/lib/zero_push/client.rb
CHANGED
@@ -66,8 +66,10 @@ module ZeroPush
|
|
66
66
|
#
|
67
67
|
# Ex.
|
68
68
|
# {"message":"ok"}
|
69
|
-
def register(device_token)
|
70
|
-
|
69
|
+
def register(device_token, channel=nil)
|
70
|
+
params = {device_token: device_token}
|
71
|
+
params.merge!(channel: channel) unless channel.nil?
|
72
|
+
client.post('/register', params)
|
71
73
|
end
|
72
74
|
|
73
75
|
# Sets the badge for a particular device
|
data/lib/zero_push/version.rb
CHANGED
data/lib/zero_push.rb
CHANGED
@@ -26,8 +26,8 @@ module ZeroPush
|
|
26
26
|
client.unsubscribe(device_token, channel)
|
27
27
|
end
|
28
28
|
|
29
|
-
def register(device_token)
|
30
|
-
client.register(device_token)
|
29
|
+
def register(device_token, channel=nil)
|
30
|
+
client.register(device_token, channel)
|
31
31
|
end
|
32
32
|
|
33
33
|
def set_badge(device_token, badge)
|
data/spec/fixtures/register.yml
CHANGED
@@ -54,4 +54,53 @@ http_interactions:
|
|
54
54
|
string: ! '{"message":"ok"}'
|
55
55
|
http_version:
|
56
56
|
recorded_at: Thu, 08 Aug 2013 23:50:39 GMT
|
57
|
+
- request:
|
58
|
+
method: post
|
59
|
+
uri: https://api.zeropush.com/register
|
60
|
+
body:
|
61
|
+
encoding: US-ASCII
|
62
|
+
string: device_token=abc&channel=foo
|
63
|
+
headers:
|
64
|
+
Authorization:
|
65
|
+
- Token token="test_token"
|
66
|
+
User-Agent:
|
67
|
+
- Faraday v0.8.9
|
68
|
+
Content-Type:
|
69
|
+
- application/x-www-form-urlencoded
|
70
|
+
response:
|
71
|
+
status:
|
72
|
+
code: 200
|
73
|
+
message:
|
74
|
+
headers:
|
75
|
+
server:
|
76
|
+
- nginx
|
77
|
+
date:
|
78
|
+
- Fri, 21 Mar 2014 04:38:14 GMT
|
79
|
+
content-type:
|
80
|
+
- application/json; charset=utf-8
|
81
|
+
transfer-encoding:
|
82
|
+
- chunked
|
83
|
+
connection:
|
84
|
+
- close
|
85
|
+
status:
|
86
|
+
- 200 OK
|
87
|
+
strict-transport-security:
|
88
|
+
- max-age=31536000
|
89
|
+
x-frame-options:
|
90
|
+
- SAMEORIGIN
|
91
|
+
x-xss-protection:
|
92
|
+
- 1; mode=block
|
93
|
+
x-content-type-options:
|
94
|
+
- nosniff
|
95
|
+
x-ua-compatible:
|
96
|
+
- chrome=1
|
97
|
+
cache-control:
|
98
|
+
- no-cache
|
99
|
+
x-request-id:
|
100
|
+
- 1eb2b29a-00f7-4554-80f3-63aaafbd04ee
|
101
|
+
body:
|
102
|
+
encoding: US-ASCII
|
103
|
+
string: ! '{"message":"ok"}'
|
104
|
+
http_version:
|
105
|
+
recorded_at: Fri, 21 Mar 2014 04:38:18 GMT
|
57
106
|
recorded_with: VCR 2.4.0
|
@@ -54,14 +54,24 @@ describe ZeroPush::Client do
|
|
54
54
|
VCR.eject_cassette
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
describe 'without a channel parameter' do
|
58
|
+
it 'should return a hash' do
|
59
|
+
client.register('abc').body.class.must_equal Hash
|
60
|
+
end
|
58
61
|
|
59
|
-
|
60
|
-
|
62
|
+
it 'should register the device' do
|
63
|
+
client.register('abc').body['message'].must_equal 'ok'
|
64
|
+
end
|
61
65
|
end
|
62
66
|
|
63
|
-
|
64
|
-
|
67
|
+
describe 'with a channel parameter' do
|
68
|
+
it 'should return a hash' do
|
69
|
+
client.register('abc', 'foo').body.class.must_equal Hash
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should register the device' do
|
73
|
+
client.register('abc', 'foo').body['message'].must_equal 'ok'
|
74
|
+
end
|
65
75
|
end
|
66
76
|
end
|
67
77
|
|