Class: Maia::FCM::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/maia/fcm/credentials.rb

Constant Summary collapse

SCOPE =
'https://www.googleapis.com/auth/firebase.messaging'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(path = ENV['GOOGLE_APPLICATION_CREDENTIALS']) ⇒ Credentials

Returns a new instance of Credentials.



8
9
10
# File 'lib/maia/fcm/credentials.rb', line 8

def initialize(path = ENV['GOOGLE_APPLICATION_CREDENTIALS'])
  @path = path
end

Instance Method Details

#projectObject



12
13
14
# File 'lib/maia/fcm/credentials.rb', line 12

def project
  to_h['project_id']
end

#to_hObject



20
21
22
# File 'lib/maia/fcm/credentials.rb', line 20

def to_h
  @to_h ||= JSON.parse file.read
end

#tokenObject



16
17
18
# File 'lib/maia/fcm/credentials.rb', line 16

def token
  credentials.fetch_access_token!['access_token']
end