Module: A55

Defined in:
lib/a55.rb,
lib/a55/client.rb,
lib/a55/errors.rb,
lib/a55/version.rb,
lib/a55/configuration.rb,
lib/a55/client/bank_slip.rb,
lib/a55/client/instruction.rb

Defined Under Namespace

Classes: A55Error, Client, Configuration, MissingAccountIdError, MissingApiTokenError, MissingTokenError

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.authenticate(token = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/a55.rb', line 15

def authenticate(token = nil)
  app_token = token || api_token || ENV['A55_API_TOKEN']
  raise MissingApiTokenError unless app_token
  response = HTTParty.post(
    "#{configuration.auth_api}",
    body: {},
    headers:  {
      "Content-Type" => 'application/json',
      "Authorization" => "ApiKey #{app_token}"
    }
  ).parsed_response
  response.fetch('user', {}).fetch('token', nil)
end

.configurationObject



11
12
13
# File 'lib/a55.rb', line 11

def configuration
  @configuration ||= Configuration.new
end