lib/revo/loans_api/client.rb in revo-loans_api-0.0.47 vs lib/revo/loans_api/client.rb in revo-loans_api-0.0.49
- old
+ new
@@ -15,17 +15,19 @@
def initialize(
base_url:,
login: nil,
password: nil,
session_token: nil,
- application_source: nil
+ application_source: nil,
+ timeouts: nil
)
@base_url = base_url
@login = login
@password = password
@session_token = session_token
@application_source = application_source
+ @timeouts = timeouts
end
def create_session
make_request(
:post, 'sessions',
@@ -337,18 +339,37 @@
"loan_applications/#{loan_application_id}/certificate",
params: { kind: kind }
)
end
+ def create_credit_report(client_id:)
+ make_request(:post, "clients/#{client_id}/credit_ratings")
+ end
+ def credit_reports_list(client_id:)
+ make_request(:get, "clients/#{client_id}/credit_ratings")
+ end
+
+ def credit_report(client_id:, report_id:)
+ make_request(:get, "clients/#{client_id}/credit_ratings/#{report_id}")
+ end
+
+ def credit_report_document(client_id:, report_id:)
+ make_request(:get, "clients/#{client_id}/credit_ratings/#{report_id}/document")
+ end
+
private
API_CONTENT_TYPE = 'application/json'.freeze
attr_reader :base_url, :login, :password, :application_source
def connection
- @connection ||= HTTP.persistent(base_url)
+ @connection ||= if @timeouts.present?
+ HTTP.timeout(@timeouts).persistent(base_url)
+ else
+ HTTP.persistent(base_url)
+ end
end
def loan_request_terms(&block)
result = make_request(:get, "loan_requests/#{loan_request_token}", &block)
return result if result.success?