Class: Iwoca::Application
- Inherits:
-
Object
- Object
- Iwoca::Application
- Defined in:
- lib/iwoca/application.rb
Class Method Summary collapse
-
.create(customer_id:, data: {}) ⇒ Object
This needs to be used after the customer has been created.
-
.latest(customer_id:) ⇒ Object
Sending across the customer_id in the URL - you will receive back an object with the latest application information that we have.
-
.offers(application_id:) ⇒ Object
Use this endpoint after creating an application to generate offers that your customer is eligible for.
Class Method Details
.create(customer_id:, data: {}) ⇒ Object
This needs to be used after the customer has been created. It returns an application_id that can be used to identify the application in all future requests. The params argument needs to have the following structure: {
data: {
requests: [
{
amount: 15000,
duration: {
amount: 12,
unit: "months"
},
product_type: "flexi_loan", # check the schema JSON for more options
purpose: "equipment_purchase", # check the schema JSON for more options
urgency: "asap"
}
]
}
}
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/iwoca/application.rb', line 26 def self.create(customer_id:, data: {}) requests = (data.dig(:data, :requests) || []).first.to_json # # Add the introducer so we can get a login link later # data[:data][:introducer] = { # entity_to_contact: 'customer', # introducer_id: customer_id # } schema = File.join(Iwoca.root, 'lib/iwoca/schemas/requested_product.json') JSON::Validator.validate!(schema, requests) Iwoca.connection.post("customers/#{customer_id}/applications/", data) end |
.latest(customer_id:) ⇒ Object
Sending across the customer_id in the URL - you will receive back an object with the latest application information that we have.
This will include a status field that can be one of the following options: open, deferred, declined, offered, conditional_offer, customer_to_link_open_banking, action_required, awaiting_underwriter, in_underwriting, expired, funded, offer_revoked, talking_to_customer.
Check more info in the docs: iwoca.stoplight.io/docs/lapi-uk/branches/2.1.0/84660933e0b17-get-user-latest-application
52 53 54 |
# File 'lib/iwoca/application.rb', line 52 def self.latest(customer_id:) Iwoca.connection.get("customers/#{customer_id}/applications/latest/") end |
.offers(application_id:) ⇒ Object
Use this endpoint after creating an application to generate offers that your customer is eligible for. Offers are associated with the Application, so are retrieved using the customer’s current application_id that you would have received in the previous request.
60 61 62 |
# File 'lib/iwoca/application.rb', line 60 def self.offers(application_id:) Iwoca.connection.get("applications/#{application_id}/offers/") end |