Class: Dinie::Resources::Loans

Inherits:
Object
  • Object
show all
Defined in:
lib/dinie/generated/resources/loans.rb,
sig/dinie/generated/resources/loans.rbs

Overview

Operations on the loans resource.

Defined Under Namespace

Classes: Transactions

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Loans

Returns a new instance of Loans.

Parameters:



11
12
13
# File 'lib/dinie/generated/resources/loans.rb', line 11

def initialize(http)
  @http = http
end

Instance Method Details

#create(request_options: {}, **fields) ⇒ Dinie::Loan

Create a loan from an accepted credit-offer simulation (POST /loans).

Parameters:

  • credit_offer_id: (String)
  • simulation_id: (String)
  • installment_count: (Integer)
  • installment_amount: (Float)
  • first_due_date: (String)
  • request_options: (request_opts) (defaults to: {})

Returns:



22
23
24
25
26
# File 'lib/dinie/generated/resources/loans.rb', line 22

def create(request_options: {}, **fields)
  body = Loan.serialize_create(**fields)
  raw = @http.request(method: :post, path: "/loans", body:, request_options:)
  Loan.deserialize(raw)
end

#retrieve(id, request_options: {}) ⇒ Dinie::Loan

Retrieve a single loan (GET /loans/{id}).

Parameters:

  • id (String)
  • request_options: (request_opts) (defaults to: {})

Returns:



35
36
37
38
# File 'lib/dinie/generated/resources/loans.rb', line 35

def retrieve(id, request_options: {})
  raw = @http.request(method: :get, path: "/loans/#{id}", request_options:)
  Loan.deserialize(raw)
end

#transactions ⇒ Dinie::Resources::Loans::Transactions

The loan transactions subresource (loans.transactions).



16
17
18
# File 'sig/dinie/generated/resources/loans.rbs', line 16

def transactions
  @transactions ||= Transactions.new(@http)
end