class Experian::Client

Attributes

request[R]
response[R]

Public Instance Methods

invalid_login?() click to toggle source
# File lib/experian/client.rb, line 24
def invalid_login?
  !!(@raw_response.headers["Location"] =~ /sso_logon/)
end
request_body() click to toggle source
# File lib/experian/client.rb, line 16
def request_body
  URI.encode_www_form('NETCONNECT_TRANSACTION' => request.xml)
end
request_headers() click to toggle source
# File lib/experian/client.rb, line 20
def request_headers
  { "Content-Type" => "application/x-www-form-urlencoded" }
end
submit_request() click to toggle source
# File lib/experian/client.rb, line 6
def submit_request
  connection = Excon.new(Experian.net_connect_uri.to_s, idempotent: true)
  @raw_response = connection.post(body: request_body, headers: request_headers)
  raise Experian::Forbidden, "Invalid Experian login credentials" if invalid_login?
  @raw_response.body

rescue Excon::Errors::SocketError => e
  raise Experian::ClientError, "Could not connect to Experian: #{e.message}"
end