Class: FractalApi::Authenticate

Inherits:
Object
  • Object
show all
Defined in:
lib/fractal_api/authenticate.rb

Instance Method Summary collapse

Instance Method Details

#call(api_key, partner_id) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fractal_api/authenticate.rb', line 9

def call(api_key, partner_id)
  response = post(
    '/token',
    api_key: api_key,
    partner_id: partner_id
  )

  if response.success?
    response.body[:access_token]
  elsif response.status == 403
    raise UnauthorizedError, response.body
  else
    raise GenericError, response.body
  end
end