class Creditsafe::Authenticate
Public Instance Methods
call(username, password)
click to toggle source
# File lib/creditsafe/authenticate.rb, line 9 def call(username, password) response = post('authenticate', username: username, password: password) if response.success? response.body[:token] elsif response.status == 401 raise UnauthorizedError, response.body else raise GenericError, response.body end end
Private Instance Methods
connection()
click to toggle source
# File lib/creditsafe/authenticate.rb, line 27 def connection api_url = Client.new.api_url @connection ||= Faraday.new(url: api_url) do |conn| conn.headers.merge!( content_type: 'application/json', user_agent: "finpoint/#{Creditsafe::VERSION}" ) conn.response :multi_json, symbolize_keys: true conn.response :logger if Creditsafe.configuration.debug conn.adapter Faraday.default_adapter end end
post(path, params = {})
click to toggle source
# File lib/creditsafe/authenticate.rb, line 23 def post(path, params = {}) connection.post(path, MultiJson.dump(params)) end