Class: Creditsafe::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/creditsafe/client.rb

Constant Summary collapse

XMLNS_OPER =
'oper'.freeze
XMLNS_OPER_VAL =
'http://www.creditsafe.com/globaldata/operations'.freeze
XMLNS_DAT =
'dat'.freeze
XMLNS_DAT_VAL =
'http://www.creditsafe.com/globaldata/datatypes'.freeze
XMLNS_CRED =
'cred'.freeze
XMLNS_CRED_VAL =
'http://schemas.datacontract.org/2004/07/Creditsafe.GlobalData'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(username: nil, password: nil, savon_opts: {}) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
# File 'lib/creditsafe/client.rb', line 20

def initialize(username: nil, password: nil, savon_opts: {})
  raise ArgumentError, "Username must be provided" if username.nil?
  raise ArgumentError, "Password must be provided" if password.nil?

  @username = username
  @password = password
  @savon_opts = savon_opts
end

Instance Method Details

#company_report(creditsafe_id, custom_data: nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/creditsafe/client.rb', line 45

def company_report(creditsafe_id, custom_data: nil)
  response = wrap_soap_errors do
    message = retrieve_company_report_message(creditsafe_id, custom_data)
    client.call(:retrieve_company_online_report, message: message)
  end

  response.
    fetch(:retrieve_company_online_report_response).
    fetch(:retrieve_company_online_report_result).
    fetch(:reports).
    fetch(:report)
end

#find_company(search_criteria = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/creditsafe/client.rb', line 29

def find_company(search_criteria = {})
  check_search_criteria(search_criteria)

  response = wrap_soap_errors do
    message = find_company_message(search_criteria)
    client.call(:find_companies, message: message)
  end

  companies = response.
              fetch(:find_companies_response).
              fetch(:find_companies_result).
              fetch(:companies)

  companies.nil? ? nil : companies.fetch(:company)
end