Class: Fortnox::Client
- Inherits:
-
Object
- Object
- Fortnox::Client
- Extended by:
- Forwardable
- Includes:
- Configurable, HTTParty
- Defined in:
- lib/fortnox/client.rb
Instance Attribute Summary
Attributes included from Configurable
#access_token, #authorization_code, #client_id, #client_secret
Instance Method Summary collapse
- #auth_headers ⇒ Object
- #fetch_access_token ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from Configurable
#configure, keys, #options, #reset!
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
19 20 21 22 23 |
# File 'lib/fortnox/client.rb', line 19 def initialize( = {}) Fortnox::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", [key] || Fortnox.instance_variable_get(:"@#{key}")) end end |
Instance Method Details
#auth_headers ⇒ Object
35 36 37 |
# File 'lib/fortnox/client.rb', line 35 def auth_headers { 'Client-Secret' => client_secret, 'Access-Token' => access_token} end |
#fetch_access_token ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/fortnox/client.rb', line 25 def fetch_access_token headers = { 'Client-Secret' => client_secret, 'Authorization-Code' => } response = get('/', headers: headers) @access_token = response.fetch('Authorization').fetch('AccessToken') end |