Class: FidorApi::Token

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

Constant Summary collapse

ATTRIBUTES =
%i[
  access_token
  expires_in
  token_type
  refresh_token
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Token

Returns a new instance of Token.



12
13
14
15
16
17
18
# File 'lib/fidor_api/token.rb', line 12

def initialize(args = {})
  args.each do |key, value|
    next unless ATTRIBUTES.include?(key.to_sym)

    instance_variable_set("@#{key}", value)
  end
end

Instance Method Details

#to_hObject



20
21
22
# File 'lib/fidor_api/token.rb', line 20

def to_h
  Hash[ATTRIBUTES.map { |key| [key, instance_variable_get("@#{key}")] }]
end