Class: PriceHubble::Client::Authentication

Inherits:
Base
  • Object
show all
Defined in:
lib/price_hubble/client/authentication.rb

Overview

A high level client library for the PriceHubble Authentication API.

Constant Summary

Constants included from Utils::Request

Utils::Request::CONTENT_TYPE

Instance Method Summary collapse

Methods inherited from Base

#configure, #connection

Methods included from Utils::Bangers

bangers

Methods included from Utils::Decision

#decision

Methods included from Utils::Response

#assign_entity, #bang_entity, #failed?, #status?

Methods included from Utils::Request

#use_authentication, #use_default_context

Instance Method Details

#login(**args) ⇒ PriceHubble::Authentication?

Perform a login request while sending the passed credentials.

Parameters:

  • args (Hash{Symbol => Mixed})

    the authentication credentials

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/price_hubble/client/authentication.rb', line 12

def (**args)
  res = connection.post do |req|
    req.path = '/auth/login/credentials'
    req.body = args.except(:bang)
    use_default_context(req, :login)
  end
  decision(bang: args.fetch(:bang, false)) do |result|
    result.bang { PriceHubble::AuthenticationError.new(nil, res) }
    result.good { PriceHubble::Authentication.new(res.body) }
    successful?(res)
  end
end