zero_push 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zero_push (2.3.0)
4
+ zero_push (2.4.0)
5
5
  faraday (~> 0.8.5)
6
6
  faraday_middleware (~> 0.9.0)
7
7
 
@@ -72,6 +72,17 @@ module ZeroPush
72
72
  client.post('/register', params)
73
73
  end
74
74
 
75
+ # Unregisters a device token that has previously been registered with
76
+ # ZeroPush
77
+ #
78
+ # @param device_token
79
+ #
80
+ # Ex.
81
+ # {"message":"ok"}
82
+ def unregister(device_token)
83
+ client.delete('/unregister', device_token: device_token)
84
+ end
85
+
75
86
  # Sets the badge for a particular device
76
87
  #
77
88
  # @param device_token
@@ -1,3 +1,3 @@
1
1
  module ZeroPush
2
- VERSION = '2.3.0'
2
+ VERSION = '2.4.0'
3
3
  end
data/lib/zero_push.rb CHANGED
@@ -30,6 +30,10 @@ module ZeroPush
30
30
  client.register(device_token, channel)
31
31
  end
32
32
 
33
+ def unregister(device_token)
34
+ client.unregister(device_token)
35
+ end
36
+
33
37
  def set_badge(device_token, badge)
34
38
  client.set_badge(device_token, badge)
35
39
  end
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://api.zeropush.com/unregister?device_token=abc
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - Token token="test_token"
12
+ User-Agent:
13
+ - Faraday v0.8.9
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ server:
20
+ - nginx
21
+ date:
22
+ - Tue, 06 May 2014 19:28:44 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-device-quota:
34
+ - '100'
35
+ x-device-quota-remaining:
36
+ - '97'
37
+ x-device-quota-overage:
38
+ - '0'
39
+ etag:
40
+ - ! '"4548a4f1a11a241120f97a1c3737817a"'
41
+ cache-control:
42
+ - max-age=0, private, must-revalidate
43
+ x-request-id:
44
+ - 9a580c69-b5b9-4b57-91c0-2da521799fd9
45
+ body:
46
+ encoding: US-ASCII
47
+ string: ! '{"message":"ok"}'
48
+ http_version:
49
+ recorded_at: Tue, 06 May 2014 19:28:43 GMT
50
+ recorded_with: VCR 2.4.0
@@ -75,6 +75,28 @@ describe ZeroPush::Client do
75
75
  end
76
76
  end
77
77
 
78
+ describe '#unregister' do
79
+
80
+ before do
81
+ VCR.insert_cassette 'unregister'
82
+ end
83
+
84
+ after do
85
+ VCR.eject_cassette
86
+ end
87
+
88
+ describe 'when the device has been registered' do
89
+ it 'should return a hash' do
90
+ client.unregister('abc').body.class.must_equal Hash
91
+ end
92
+
93
+ it 'should unregister the device' do
94
+ client.unregister('abc').body['message'].must_equal 'ok'
95
+ end
96
+ end
97
+
98
+ end
99
+
78
100
  describe '#subscribe' do
79
101
  before do
80
102
  VCR.insert_cassette 'subscribe'
@@ -12,7 +12,7 @@ describe ZeroPush do
12
12
  end
13
13
 
14
14
  describe 'methods the module responds to' do
15
- [:verify_credentials, :notify, :broadcast, :subscribe, :unsubscribe, :register, :set_badge, :inactive_tokens, :client].each do |method|
15
+ [:verify_credentials, :notify, :broadcast, :subscribe, :unsubscribe, :register, :unregister, :set_badge, :inactive_tokens, :client].each do |method|
16
16
  it "should respond to #{method}" do
17
17
  ZeroPush.respond_to?(method).must_equal(true)
18
18
  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: 2.3.0
4
+ version: 2.4.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: 2014-03-21 00:00:00.000000000 Z
13
+ date: 2014-05-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -182,6 +182,7 @@ files:
182
182
  - spec/fixtures/register.yml
183
183
  - spec/fixtures/set_badge.yml
184
184
  - spec/fixtures/subscribe.yml
185
+ - spec/fixtures/unregister.yml
185
186
  - spec/fixtures/unsubscribe.yml
186
187
  - spec/fixtures/verify_credentials.yml
187
188
  - spec/generator_spec.rb
@@ -222,6 +223,7 @@ test_files:
222
223
  - spec/fixtures/register.yml
223
224
  - spec/fixtures/set_badge.yml
224
225
  - spec/fixtures/subscribe.yml
226
+ - spec/fixtures/unregister.yml
225
227
  - spec/fixtures/unsubscribe.yml
226
228
  - spec/fixtures/verify_credentials.yml
227
229
  - spec/generator_spec.rb