Class: BambooId::ApiKeyFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/bamboo_id/api_key_fetcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, subdomain:) ⇒ ApiKeyFetcher

Returns a new instance of ApiKeyFetcher.



5
6
7
8
9
# File 'lib/bamboo_id/api_key_fetcher.rb', line 5

def initialize(code:, subdomain:)
  self.code      = code
  self.subdomain = subdomain
  self.error     = nil
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/bamboo_id/api_key_fetcher.rb', line 3

def error
  @error
end

Instance Method Details

#fetchObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bamboo_id/api_key_fetcher.rb', line 11

def fetch
  unless access_token_request.successful?
    self.error = "Could not get access token: #{access_token_request.error}"
    return false
  end

  unless api_key_request.successful?
    self.error = "Could not get API key."
    return false
  end

  api_key_request.key
end