fcm 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48d3208b5ed6d6f6428d43cc5fbe2d9181e84c1c4a8b28a6947657308bac989d
4
- data.tar.gz: d808e663adaf6b963db7eadffab53ff3f9421af9a25aa5de652677b4259d7610
3
+ metadata.gz: 4dec8402da3cac0b69ca604ad13a371e4c57616cf4ce7fe9d501e08ff93a3322
4
+ data.tar.gz: d21ace2c8431e769b463cfc0d9c4995751e2fce9cdb73548b0160a558e5dacb1
5
5
  SHA512:
6
- metadata.gz: 8cdd5cb73c5740dfddb78aef4e1c432121e44908cf09d5c285b13ab10ab79f6a653ca0f09eaa85ff43a532cc3f3e678cd8fa14fb6c327b5a7b32217ff61d45ce
7
- data.tar.gz: af7a744e9e9c02a0ba64075788bcb71da12689007ee9fcdaa7d0d0c42968ea0b0f22e972f562b5b11f30d77a3b200d4e0d1ede3ca48b40325a4032e84abb3e26
6
+ metadata.gz: cacba1ce61e62b1d535f1f765fb2491eae84af3fac7a579949939c4f40e3a0572aec29956c21f0194ce409283e2ddd87dff7fd483a01116cd8636579133b8197
7
+ data.tar.gz: 78353f02fbdb092e01bc634e7371c57341b168ff65363382b2c6948596aedcf2fa6a39dc82ba06f853357671f10d0578f49af0d0f0158c760da06ee10d806f33
@@ -0,0 +1,30 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - '*'
7
+ push:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ tests:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby: ['2.7', '3.0', '3.1']
17
+
18
+ steps:
19
+ - uses: actions/checkout@master
20
+
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler: default
26
+ bundler-cache: true
27
+
28
+ - name: Run tests
29
+ run: |
30
+ bundle exec rspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Firebase Cloud Messaging (FCM) for Android and iOS
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/fcm.svg)](http://badge.fury.io/rb/fcm) [![Build Status](https://secure.travis-ci.org/decision-labs/fcm.svg?branch=master)](http://travis-ci.org/decision-labs/fcm)
3
+ [![Gem Version](https://badge.fury.io/rb/fcm.svg)](http://badge.fury.io/rb/fcm) [![Build Status](https://github.com/decision-labs/fcm/workflows/Tests/badge.svg)](https://github.com/decision-labs/fcm/actions)
4
4
 
5
5
  The FCM gem lets your ruby backend send notifications to Android and iOS devices via [
6
6
  Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/).
@@ -210,9 +210,17 @@ The guide to set up an iOS app to get notifications is here: [Setting up a FCM C
210
210
 
211
211
  ## ChangeLog
212
212
 
213
+ ### 1.0.7
214
+
215
+ - Fix passing `DEFAULT_TIMEOUT` to `faraday` [#96](https://github.com/decision-labs/fcm/pull/96)
216
+ - Fix issue with `get_instance_id_info` option params [#98](https://github.com/decision-labs/fcm/pull/98)
217
+ - Accept any IO object for credentials [#95](https://github.com/decision-labs/fcm/pull/94)
218
+
219
+ Huge thanks to @excid3 @jsparling @jensljungblad
220
+
213
221
  ### 1.0.3
214
222
 
215
- - Fix overly strict faraday depenecy
223
+ - Fix overly strict faraday dependency
216
224
 
217
225
  ### 1.0.2
218
226
 
@@ -232,6 +240,7 @@ The guide to set up an iOS app to get notifications is here: [Setting up a FCM C
232
240
  - Fixed group messaging url.
233
241
  - Added API to `recover_notification_key`.
234
242
 
243
+
235
244
  ### 0.0.1
236
245
 
237
246
  - Initial version.
@@ -250,7 +259,7 @@ Update version in `fcm.gemspec` with `VERSION` and update `README.md` `## Change
250
259
 
251
260
  ```bash
252
261
  # set the version
253
- # VERSION="1.0.4"
262
+ # VERSION="1.0.7"
254
263
  gem build fcm.gemspec
255
264
  git tag -a v${VERSION} -m "Releasing version v${VERSION}"
256
265
  git push origin --tags
data/fcm.gemspec CHANGED
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fcm"
6
- s.version = "1.0.6"
6
+ s.version = "1.0.7"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Kashif Rasul", "Shoaib Burq"]
9
9
  s.email = ["kashif@decision-labs.com", "shoaib@decision-labs.com"]
10
- s.homepage = "https://github.com/spacialdb/fcm"
10
+ s.homepage = "https://github.com/decision-labs/fcm"
11
11
  s.summary = %q{Reliably deliver messages and notifications via FCM}
12
12
  s.description = %q{fcm provides ruby bindings to Firebase Cloud Messaging (FCM) a cross-platform messaging solution that lets you reliably deliver messages and notifications at no cost to Android, iOS or Web browsers.}
13
13
  s.license = "MIT"
data/lib/fcm.rb CHANGED
@@ -188,9 +188,7 @@ class FCM
188
188
  end
189
189
 
190
190
  def get_instance_id_info(iid_token, options = {})
191
- params = {
192
- query: options,
193
- }
191
+ params = options
194
192
 
195
193
  for_uri(INSTANCE_ID_API) do |connection|
196
194
  response = connection.get("/iid/info/" + iid_token, params)
@@ -224,7 +222,10 @@ class FCM
224
222
  private
225
223
 
226
224
  def for_uri(uri, extra_headers = {})
227
- connection = ::Faraday.new(:url => uri) do |faraday|
225
+ connection = ::Faraday.new(
226
+ url: uri,
227
+ request: { timeout: DEFAULT_TIMEOUT }
228
+ ) do |faraday|
228
229
  faraday.adapter Faraday.default_adapter
229
230
  faraday.headers["Content-Type"] = "application/json"
230
231
  faraday.headers["Authorization"] = "key=#{api_key}"
@@ -320,10 +321,18 @@ class FCM
320
321
  def jwt_token
321
322
  scope = "https://www.googleapis.com/auth/firebase.messaging"
322
323
  authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
323
- json_key_io: File.open(@json_key_path),
324
+ json_key_io: json_key,
324
325
  scope: scope,
325
326
  )
326
327
  token = authorizer.fetch_access_token!
327
328
  token["access_token"]
328
329
  end
330
+
331
+ def json_key
332
+ @json_key ||= if @json_key_path.respond_to?(:read)
333
+ @json_key_path
334
+ else
335
+ File.open(@json_key_path)
336
+ end
337
+ end
329
338
  end
data/spec/fcm_spec.rb CHANGED
@@ -498,4 +498,50 @@ describe FCM do
498
498
  describe "subscribing to a topic" do
499
499
  # TODO
500
500
  end
501
+
502
+ describe 'getting instance info' do
503
+ subject(:get_info) { client.get_instance_id_info(registration_id, options) }
504
+
505
+ let(:options) { nil }
506
+ let(:client) { FCM.new('TEST_SERVER_KEY') }
507
+ let(:base_uri) { "#{FCM::INSTANCE_ID_API}/iid/info" }
508
+ let(:uri) { "#{base_uri}/#{registration_id}" }
509
+ let(:mock_request_attributes) do
510
+ { headers: {
511
+ 'Authorization' => 'key=TEST_SERVER_KEY',
512
+ 'Content-Type' => 'application/json'
513
+ } }
514
+ end
515
+
516
+ context 'without options' do
517
+ it 'calls info endpoint' do
518
+ endpoint = stub_request(:get, uri).with(mock_request_attributes)
519
+ get_info
520
+ expect(endpoint).to have_been_requested
521
+ end
522
+ end
523
+
524
+ context 'with detail option' do
525
+ let(:uri) { "#{base_uri}/#{registration_id}?details=true" }
526
+ let(:options) { { details: true } }
527
+
528
+ it 'calls info endpoint' do
529
+ endpoint = stub_request(:get, uri).with(mock_request_attributes)
530
+ get_info
531
+ expect(endpoint).to have_been_requested
532
+ end
533
+ end
534
+ end
535
+
536
+ describe "credentials path" do
537
+ it "can be a path to a file" do
538
+ fcm = FCM.new("test", "README.md")
539
+ expect(fcm.__send__(:json_key).class).to eq(File)
540
+ end
541
+
542
+ it "can be an IO object" do
543
+ fcm = FCM.new("test", StringIO.new("hey"))
544
+ expect(fcm.__send__(:json_key).class).to eq(StringIO)
545
+ end
546
+ end
501
547
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fcm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kashif Rasul
8
8
  - Shoaib Burq
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-11-26 00:00:00.000000000 Z
12
+ date: 2022-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -49,9 +49,9 @@ executables: []
49
49
  extensions: []
50
50
  extra_rdoc_files: []
51
51
  files:
52
+ - ".github/workflows/ci.yml"
52
53
  - ".gitignore"
53
54
  - ".rspec"
54
- - ".travis.yml"
55
55
  - Gemfile
56
56
  - LICENSE.txt
57
57
  - README.md
@@ -60,11 +60,11 @@ files:
60
60
  - lib/fcm.rb
61
61
  - spec/fcm_spec.rb
62
62
  - spec/spec_helper.rb
63
- homepage: https://github.com/spacialdb/fcm
63
+ homepage: https://github.com/decision-labs/fcm
64
64
  licenses:
65
65
  - MIT
66
66
  metadata: {}
67
- post_install_message:
67
+ post_install_message:
68
68
  rdoc_options: []
69
69
  require_paths:
70
70
  - lib
@@ -79,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.0.3.1
83
- signing_key:
82
+ rubygems_version: 3.2.22
83
+ signing_key:
84
84
  specification_version: 4
85
85
  summary: Reliably deliver messages and notifications via FCM
86
86
  test_files:
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.0
4
- - 2.4.5
5
- - 2.5.3
6
- - 2.6.1
7
- - 2.7.0