rgcm 1.0.0 → 1.0.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.
- checksums.yaml +4 -4
- data/README.md +17 -10
- data/lib/rgcm/response.rb +14 -2
- data/lib/rgcm/version.rb +1 -1
- data/spec/fixtures/responses/with_cannonical_ids.json +15 -0
- data/spec/rgcm/response_spec.rb +17 -3
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 276471a1b8d92a01fb28e1e40653a58b3f0766d1
|
|
4
|
+
data.tar.gz: 341d7136f942fbd50b9f948175c0e826c9cf4f5f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 071ba22fb749d6b039b67f9127dcf686f5941424b80bf79ab09aae1b8837b2c68364f7c6981112aace79aabf37cbcb468162e8f8fbc38c480f8c25beceb9732a
|
|
7
|
+
data.tar.gz: bfc4a47d903f23d39ad5b6af3c2b132be2ba1dcb7f91ccf61aa6bd0a2aba4cac522f58d37f469f6bf508ea9bf05202d1690be28a23890f895feb421e82cb89af
|
data/README.md
CHANGED
|
@@ -30,14 +30,24 @@ Or install it yourself as:
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
32
|
``` ruby
|
|
33
|
-
|
|
34
|
-
data = { foo: 'bar' }
|
|
33
|
+
Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', { foo: 'bar' }) # => Rgcm::Response
|
|
35
34
|
|
|
36
|
-
Rgcm::Message.new('_API_KEY_').post('
|
|
35
|
+
Rgcm::Message.new('_API_KEY_').post(['_GCM_REGESTRATION_ID_1_', '_GCM_REGESTRATION_ID_2_'], { foo: 'bar' }) # => Rgcm::Response
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
With collapse_key:
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
``` ruby
|
|
41
|
+
Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', { foo: 'bar' }, {collapse_key: 'collapse_key'}) # => Rgcm::Response
|
|
39
42
|
```
|
|
40
43
|
|
|
44
|
+
With time_to_live:
|
|
45
|
+
|
|
46
|
+
``` ruby
|
|
47
|
+
Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', { foo: 'bar' }, {time_to_live: 3}) # => Rgcm::Response
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
|
|
41
51
|
With rails YML config file:
|
|
42
52
|
|
|
43
53
|
``` yml
|
|
@@ -52,12 +62,9 @@ production:
|
|
|
52
62
|
```
|
|
53
63
|
|
|
54
64
|
``` ruby
|
|
55
|
-
|
|
56
|
-
data = { foo: 'bar' }
|
|
57
|
-
|
|
58
|
-
Rgcm::Message.new.post('_GCM_REGESTRATION_ID_', collapse_key, data) # => Rgcm::Response
|
|
65
|
+
Rgcm::Message.new.post('_GCM_REGESTRATION_ID_', { foo: 'bar' }) # => Rgcm::Response
|
|
59
66
|
|
|
60
|
-
Rgcm::Message.new.post(['_GCM_REGESTRATION_ID_1_', '_GCM_REGESTRATION_ID_2_'],
|
|
67
|
+
Rgcm::Message.new.post(['_GCM_REGESTRATION_ID_1_', '_GCM_REGESTRATION_ID_2_'], { foo: 'bar' }) # => Rgcm::Response
|
|
61
68
|
```
|
|
62
69
|
|
|
63
70
|
Rgcm::Response methods:
|
|
@@ -75,7 +82,7 @@ Rgcm::Response methods:
|
|
|
75
82
|
```
|
|
76
83
|
|
|
77
84
|
``` ruby
|
|
78
|
-
response = Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_',
|
|
85
|
+
response = Rgcm::Message.new('_API_KEY_').post('_GCM_REGESTRATION_ID_', { foo: 'bar' })
|
|
79
86
|
|
|
80
87
|
response.count_successes # => 1
|
|
81
88
|
response.count_failures # => 0
|
data/lib/rgcm/response.rb
CHANGED
|
@@ -22,17 +22,29 @@ module Rgcm
|
|
|
22
22
|
self.count_failures > 0
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
def count_canonical_ids
|
|
26
|
+
self.body[:canonical_ids]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def has_canonical_ids?
|
|
30
|
+
self.count_canonical_ids > 0
|
|
31
|
+
end
|
|
32
|
+
|
|
25
33
|
def results
|
|
26
34
|
self.body[:results]
|
|
27
35
|
end
|
|
28
36
|
|
|
29
|
-
def
|
|
37
|
+
def results_with_errors
|
|
30
38
|
self.results.select { |result| result.key?(:error) }
|
|
31
39
|
end
|
|
32
40
|
|
|
33
|
-
def
|
|
41
|
+
def results_with_successes
|
|
34
42
|
self.results.select { |result| !result.key?(:error) }
|
|
35
43
|
end
|
|
36
44
|
|
|
45
|
+
def results_with_canonical_ids
|
|
46
|
+
self.results.select { |result| result.key?(:registration_id) }
|
|
47
|
+
end
|
|
48
|
+
|
|
37
49
|
end
|
|
38
50
|
end
|
data/lib/rgcm/version.rb
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"multicast_id":6612807694841069664,
|
|
3
|
+
"success":2,
|
|
4
|
+
"failure":0,
|
|
5
|
+
"canonical_ids":1,
|
|
6
|
+
"results":[
|
|
7
|
+
{
|
|
8
|
+
"message_id":"0:1403425286258916%62dfd0f6e116c072"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"registration_id" : "APA91bEEXJH2YMRhc3cQ2OF0N4BX4SfSlUjNYKsMhGWiaiqvJ4pSLB9mAvdMwt_UVOtAc7egxkFImkdfNLHJHkT-yRpaBuw4duDhoJa52YdzXw1dR05mb0R_mfdegzpfA5rEi1iSfHInxgaDoin0xlOdmsKoYU7YXw",
|
|
12
|
+
"message_id" : "0:1409742140784985%62dfd0f6f9fd7ecd"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
data/spec/rgcm/response_spec.rb
CHANGED
|
@@ -34,7 +34,7 @@ describe Rgcm::Response do
|
|
|
34
34
|
expect(response.count_failures).to eql(1)
|
|
35
35
|
end
|
|
36
36
|
it '#errors' do
|
|
37
|
-
expect(response.
|
|
37
|
+
expect(response.results_with_errors.size).to eql(1)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -53,10 +53,24 @@ describe Rgcm::Response do
|
|
|
53
53
|
expect(response.count_failures).to eql(11)
|
|
54
54
|
end
|
|
55
55
|
it '#errors' do
|
|
56
|
-
expect(response.
|
|
56
|
+
expect(response.results_with_errors.size).to eql(11)
|
|
57
57
|
end
|
|
58
58
|
it '#successes' do
|
|
59
|
-
expect(response.
|
|
59
|
+
expect(response.results_with_successes.size).to eql(3)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context 'with canonical_ids' do
|
|
64
|
+
let(:json) { File.open("#{FIXTURES_PATH}/responses/with_cannonical_ids.json").read }
|
|
65
|
+
|
|
66
|
+
it '#has_canonical_ids?' do
|
|
67
|
+
expect(response.has_canonical_ids?).to be true
|
|
68
|
+
end
|
|
69
|
+
it '#count_canonical_ids' do
|
|
70
|
+
expect(response.count_canonical_ids).to eql(1)
|
|
71
|
+
end
|
|
72
|
+
it '#canonical_ids' do
|
|
73
|
+
expect(response.results_with_canonical_ids.size).to eql(1)
|
|
60
74
|
end
|
|
61
75
|
end
|
|
62
76
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rgcm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Klaiber
|
|
@@ -105,6 +105,7 @@ files:
|
|
|
105
105
|
- spec/fixtures/responses/failure.json
|
|
106
106
|
- spec/fixtures/responses/multi.json
|
|
107
107
|
- spec/fixtures/responses/successfully.json
|
|
108
|
+
- spec/fixtures/responses/with_cannonical_ids.json
|
|
108
109
|
- spec/rgcm/message_spec.rb
|
|
109
110
|
- spec/rgcm/request_builder_spec.rb
|
|
110
111
|
- spec/rgcm/response_spec.rb
|
|
@@ -138,6 +139,7 @@ test_files:
|
|
|
138
139
|
- spec/fixtures/responses/failure.json
|
|
139
140
|
- spec/fixtures/responses/multi.json
|
|
140
141
|
- spec/fixtures/responses/successfully.json
|
|
142
|
+
- spec/fixtures/responses/with_cannonical_ids.json
|
|
141
143
|
- spec/rgcm/message_spec.rb
|
|
142
144
|
- spec/rgcm/request_builder_spec.rb
|
|
143
145
|
- spec/rgcm/response_spec.rb
|