Class: Icasework::Token::Bearer

Inherits:
Object
  • Object
show all
Defined in:
lib/icasework/token/bearer.rb

Overview

Generate access token for Bearer authorisation header

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Bearer

Returns a new instance of Bearer.



26
27
28
29
30
# File 'lib/icasework/token/bearer.rb', line 26

def initialize(data)
  @access_token = data.fetch(:access_token)
  @token_type = data.fetch(:token_type)
  @expires_in = data.fetch(:expires_in)
end

Class Method Details

.generateObject



10
11
12
13
14
# File 'lib/icasework/token/bearer.rb', line 10

def generate
  new Icasework::Resource.token(payload).data
rescue RequestError, ResponseError => e
  raise AuthenticationError, e.message
end

Instance Method Details

#to_sObject



32
33
34
# File 'lib/icasework/token/bearer.rb', line 32

def to_s
  @access_token
end