Class: Experian::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/experian/client.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
4
5
6
|
# File 'lib/experian/client.rb', line 4
def request
@request
end
|
#response ⇒ Object
Returns the value of attribute response.
4
5
6
|
# File 'lib/experian/client.rb', line 4
def response
@response
end
|
Instance Method Details
#invalid_login? ⇒ Boolean
24
25
26
|
# File 'lib/experian/client.rb', line 24
def invalid_login?
!!(@raw_response.["Location"] =~ /sso_logon/)
end
|
#request_body ⇒ Object
16
17
18
|
# File 'lib/experian/client.rb', line 16
def request_body
URI.encode_www_form('NETCONNECT_TRANSACTION' => request.xml)
end
|
20
21
22
|
# File 'lib/experian/client.rb', line 20
def
{ "Content-Type" => "application/x-www-form-urlencoded" }
end
|
#submit_request ⇒ Object
6
7
8
9
10
11
12
13
14
|
# 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: )
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
|