Class: Moneybird::Token

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, refresh_token: nil, token_type: "bearer", scope: nil, created_at: nil) ⇒ Token

Returns a new instance of Token.



7
8
9
10
11
12
13
# File 'lib/moneybird/token.rb', line 7

def initialize(access_token:, refresh_token: nil, token_type: "bearer", scope: nil, created_at: nil)
  @access_token = access_token
  @refresh_token = refresh_token
  @token_type = token_type
  @scope = scope
  @created_at = created_at.is_a?(Numeric) ? Time.at(created_at) : created_at
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



5
6
7
# File 'lib/moneybird/token.rb', line 5

def access_token
  @access_token
end

#created_atObject (readonly)

Returns the value of attribute created_at.



5
6
7
# File 'lib/moneybird/token.rb', line 5

def created_at
  @created_at
end

#refresh_tokenObject (readonly)

Returns the value of attribute refresh_token.



5
6
7
# File 'lib/moneybird/token.rb', line 5

def refresh_token
  @refresh_token
end

#scopeObject (readonly)

Returns the value of attribute scope.



5
6
7
# File 'lib/moneybird/token.rb', line 5

def scope
  @scope
end

#token_typeObject (readonly)

Returns the value of attribute token_type.



5
6
7
# File 'lib/moneybird/token.rb', line 5

def token_type
  @token_type
end

Instance Method Details

#clientObject

Create a Client from this token



16
17
18
# File 'lib/moneybird/token.rb', line 16

def client
  Client.new(access_token)
end