Class: Creditsafe::Client
- Inherits:
-
Object
- Object
- Creditsafe::Client
- Defined in:
- lib/creditsafe/client.rb
Constant Summary collapse
- ENVIRONMENTS =
%i[live test].freeze
Instance Method Summary collapse
- #company_report(creditsafe_id, custom_data: nil) ⇒ Object
- #find_company(search_criteria = {}) ⇒ Object
-
#initialize(username: nil, password: nil, savon_opts: {}, environment: :live, log_level: :warn) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
Constructor Details
#initialize(username: nil, password: nil, savon_opts: {}, environment: :live, log_level: :warn) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/creditsafe/client.rb', line 20 def initialize(username: nil, password: nil, savon_opts: {}, environment: :live, log_level: :warn) raise ArgumentError, "Username must be provided" if username.nil? raise ArgumentError, "Password must be provided" if password.nil? unless ENVIRONMENTS.include?(environment.to_sym) raise ArgumentError, "Environment needs to be one of #{ENVIRONMENTS.join('/')}" end @environment = environment.to_s @log_level = log_level @username = username @password = password @savon_opts = savon_opts end |
Instance Method Details
#company_report(creditsafe_id, custom_data: nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/creditsafe/client.rb', line 48 def company_report(creditsafe_id, custom_data: nil) request = Creditsafe::Request::CompanyReport.new(creditsafe_id, custom_data) response = invoke_soap(:retrieve_company_online_report, request.) response. fetch(:retrieve_company_online_report_response). fetch(:retrieve_company_online_report_result). fetch(:reports). fetch(:report) end |
#find_company(search_criteria = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/creditsafe/client.rb', line 36 def find_company(search_criteria = {}) request = Creditsafe::Request::FindCompany.new(search_criteria) response = invoke_soap(:find_companies, request.) companies = response. fetch(:find_companies_response). fetch(:find_companies_result). fetch(:companies) companies.nil? ? nil : companies.fetch(:company) end |
#inspect ⇒ Object
60 61 62 |
# File 'lib/creditsafe/client.rb', line 60 def inspect "#<#{self.class} @username='#{@username}'>" end |