zero_push 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/zero_push/client.rb +17 -1
- data/lib/zero_push/version.rb +1 -1
- data/spec/fixtures/inactive_tokens.yml +52 -0
- data/spec/fixtures/set_badge.yml +57 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/zero_push_spec.rb +30 -0
- metadata +6 -2
data/Gemfile.lock
CHANGED
data/lib/zero_push/client.rb
CHANGED
@@ -22,12 +22,28 @@ module ZeroPush
|
|
22
22
|
|
23
23
|
# Registers a device token with the ZeroPush backend
|
24
24
|
#
|
25
|
-
# @
|
25
|
+
# @param device_token
|
26
26
|
# @return response
|
27
27
|
def register(device_token)
|
28
28
|
client.post('/register', device_token: device_token)
|
29
29
|
end
|
30
30
|
|
31
|
+
# Sets the badge for a particular device
|
32
|
+
#
|
33
|
+
# @param device_token
|
34
|
+
# @param badge
|
35
|
+
# @return response
|
36
|
+
def set_badge(device_token, badge)
|
37
|
+
client.post('/set_badge', device_token: device_token, badge: badge)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns a list of tokens that have been marked inactive
|
41
|
+
#
|
42
|
+
# @returns array
|
43
|
+
def inactive_tokens
|
44
|
+
client.get('/inactive_tokens')
|
45
|
+
end
|
46
|
+
|
31
47
|
# the HTTP client configured for API requests
|
32
48
|
#
|
33
49
|
def client
|
data/lib/zero_push/version.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.zeropush.com/inactive_tokens
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ""
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- Token token="test_token"
|
12
|
+
User-Agent:
|
13
|
+
- Faraday v0.8.7
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message:
|
18
|
+
headers:
|
19
|
+
server:
|
20
|
+
- nginx/1.2.6
|
21
|
+
date:
|
22
|
+
- Fri, 09 Aug 2013 01:19:03 GMT
|
23
|
+
content-type:
|
24
|
+
- application/json; charset=utf-8
|
25
|
+
transfer-encoding:
|
26
|
+
- chunked
|
27
|
+
connection:
|
28
|
+
- close
|
29
|
+
status:
|
30
|
+
- 200 OK
|
31
|
+
strict-transport-security:
|
32
|
+
- max-age=31536000
|
33
|
+
x-ua-compatible:
|
34
|
+
- IE=Edge
|
35
|
+
etag:
|
36
|
+
- "\"9c9190eec43ccacbad112e6a77dc6a83\""
|
37
|
+
cache-control:
|
38
|
+
- must-revalidate, private, max-age=0
|
39
|
+
x-request-id:
|
40
|
+
- dc4287a5b6dfe69125d0c6b36ab958f9
|
41
|
+
x-runtime:
|
42
|
+
- "0.079937"
|
43
|
+
x-rack-cache:
|
44
|
+
- miss
|
45
|
+
x-powered-by:
|
46
|
+
- Phusion Passenger 4.0.2
|
47
|
+
body:
|
48
|
+
encoding: ASCII-8BIT
|
49
|
+
string: "[{\"device_token\":\"238b8cb09011850cb4bd544dfe0c8f5eeab73d7eeaae9bdca59076db4ae49947\",\"marked_inactive_at\":\"2013-07-17T01:27:53-04:00\"},{\"device_token\":\"8c97be6643eea2143322005bc4c44a1aee5e549bce5e2bb2116114f45484ddaf\",\"marked_inactive_at\":\"2013-07-17T01:27:50-04:00\"}]"
|
50
|
+
http_version:
|
51
|
+
recorded_at: Fri, 09 Aug 2013 01:19:04 GMT
|
52
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.zeropush.com/set_badge
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: device_token=abc&badge=10
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- Token token="test_token"
|
12
|
+
User-Agent:
|
13
|
+
- Faraday v0.8.7
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message:
|
20
|
+
headers:
|
21
|
+
server:
|
22
|
+
- nginx/1.2.6
|
23
|
+
date:
|
24
|
+
- Fri, 09 Aug 2013 00:57:11 GMT
|
25
|
+
content-type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
transfer-encoding:
|
28
|
+
- chunked
|
29
|
+
connection:
|
30
|
+
- close
|
31
|
+
status:
|
32
|
+
- 200 OK
|
33
|
+
strict-transport-security:
|
34
|
+
- max-age=31536000
|
35
|
+
x-ua-compatible:
|
36
|
+
- IE=Edge
|
37
|
+
etag:
|
38
|
+
- ! '"4548a4f1a11a241120f97a1c3737817a"'
|
39
|
+
cache-control:
|
40
|
+
- max-age=0, private, must-revalidate
|
41
|
+
set-cookie:
|
42
|
+
- _zero-push-session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRkkiJTdmMmJkMTRmNzVkNGI2NzI1ODA2MjlhMjdlZjdlYjAyBjsAVA%3D%3D--888243f320504a8621f826f76ec84ccb94f81b33;
|
43
|
+
path=/; secure; HttpOnly
|
44
|
+
x-request-id:
|
45
|
+
- fdb9461a5c2e67b8553c871a31d72695
|
46
|
+
x-runtime:
|
47
|
+
- '0.021581'
|
48
|
+
x-rack-cache:
|
49
|
+
- invalidate, pass
|
50
|
+
x-powered-by:
|
51
|
+
- Phusion Passenger 4.0.2
|
52
|
+
body:
|
53
|
+
encoding: US-ASCII
|
54
|
+
string: ! '{"message":"ok"}'
|
55
|
+
http_version:
|
56
|
+
recorded_at: Fri, 09 Aug 2013 00:57:11 GMT
|
57
|
+
recorded_with: VCR 2.4.0
|
data/spec/spec_helper.rb
CHANGED
data/spec/zero_push_spec.rb
CHANGED
@@ -53,4 +53,34 @@ describe ZeroPush do
|
|
53
53
|
response.status.must_equal 200
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
describe "/set_badge" do
|
58
|
+
before do
|
59
|
+
VCR.insert_cassette "set_badge"
|
60
|
+
end
|
61
|
+
|
62
|
+
after do
|
63
|
+
VCR.eject_cassette
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should set the device's badge" do
|
67
|
+
response = ZeroPush.set_badge('abc', 10)
|
68
|
+
response.status.must_equal 200
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "/inactive_tokens" do
|
73
|
+
before do
|
74
|
+
VCR.insert_cassette "inactive_tokens"
|
75
|
+
end
|
76
|
+
|
77
|
+
after do
|
78
|
+
VCR.eject_cassette
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should get a list of inactive tokens" do
|
82
|
+
response = ZeroPush.inactive_tokens
|
83
|
+
response.status.must_equal 200
|
84
|
+
end
|
85
|
+
end
|
56
86
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zero_push
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-08-
|
13
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -160,8 +160,10 @@ files:
|
|
160
160
|
- lib/zero_push.rb
|
161
161
|
- lib/zero_push/client.rb
|
162
162
|
- lib/zero_push/version.rb
|
163
|
+
- spec/fixtures/inactive_tokens.yml
|
163
164
|
- spec/fixtures/notify.yml
|
164
165
|
- spec/fixtures/register.yml
|
166
|
+
- spec/fixtures/set_badge.yml
|
165
167
|
- spec/fixtures/verify_credentials.yml
|
166
168
|
- spec/generator_spec.rb
|
167
169
|
- spec/spec_helper.rb
|
@@ -193,8 +195,10 @@ signing_key:
|
|
193
195
|
specification_version: 3
|
194
196
|
summary: A gem for interacting with the ZeroPush API. (http://zeropush.com)
|
195
197
|
test_files:
|
198
|
+
- spec/fixtures/inactive_tokens.yml
|
196
199
|
- spec/fixtures/notify.yml
|
197
200
|
- spec/fixtures/register.yml
|
201
|
+
- spec/fixtures/set_badge.yml
|
198
202
|
- spec/fixtures/verify_credentials.yml
|
199
203
|
- spec/generator_spec.rb
|
200
204
|
- spec/spec_helper.rb
|