Class: Dinie::Resources::CreditOffers
- Inherits:
-
Object
- Object
- Dinie::Resources::CreditOffers
- Defined in:
- lib/dinie/generated/resources/credit_offers.rb
Overview
Operations on the credit offers resource.
Instance Method Summary collapse
-
#create_simulation(id, request_options: {}, **fields) ⇒ Object
Simulate a loan.
-
#initialize(http) ⇒ CreditOffers
constructor
A new instance of CreditOffers.
-
#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}, **filters) ⇒ Object
List credit offers.
-
#retrieve(id, request_options: {}) ⇒ Object
Retrieve a credit offer.
Constructor Details
#initialize(http) ⇒ CreditOffers
Returns a new instance of CreditOffers.
11 12 13 |
# File 'lib/dinie/generated/resources/credit_offers.rb', line 11 def initialize(http) @http = http end |
Instance Method Details
#create_simulation(id, request_options: {}, **fields) ⇒ Object
Simulate a loan
Simulate a loan scenario for a credit offer, returning installment value, fees, and total cost
23 24 25 26 27 |
# File 'lib/dinie/generated/resources/credit_offers.rb', line 23 def create_simulation(id, request_options: {}, **fields) body = Simulation.serialize_create_simulation(**fields) raw = @http.request(method: :post, path: "/credit-offers/#{id}/simulations", body:, request_options:) Simulation.deserialize(raw) end |
#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}, **filters) ⇒ Object
List credit offers
List credit offers across all customers, filterable by ‘customer_id` and `status`
36 37 38 39 40 41 42 43 44 |
# File 'lib/dinie/generated/resources/credit_offers.rb', line 36 def list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}, **filters) fetch_page = lambda do |cursor| query = { limit:, starting_after: cursor || starting_after, **filters } .reject { |_key, value| Internal.omitted?(value) } body = @http.request(method: :get, path: "/credit-offers", query:, request_options:) { data: body[:data].map { |raw| CreditOffer.deserialize(raw) }, has_more: body[:has_more] } end Dinie::Page.from_fetch(fetch_page) end |
#retrieve(id, request_options: {}) ⇒ Object
Retrieve a credit offer
Return the full credit offer object with approved amount, interest rate, and validity
53 54 55 56 |
# File 'lib/dinie/generated/resources/credit_offers.rb', line 53 def retrieve(id, request_options: {}) raw = @http.request(method: :get, path: "/credit-offers/#{id}", request_options:) CreditOffer.deserialize(raw) end |