Class: Dinie::Resources::Loans

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

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.



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) ⇒ Object

Create a loan

Create a loan from a credit offer and accepted simulation; the CCB contract is generated synchronously and the loan starts in ‘awaiting_signatures` status

Parameters:

  • fields (Hash)

    Request body fields.

  • request_options (Hash) (defaults to: {})

    Request options.

Returns:

  • (Object)


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: {}) ⇒ Object

Retrieve a loan

Return the full loan object with lifecycle details

Parameters:

  • id (String)

    Identificador único do empréstimo

  • request_options (Hash) (defaults to: {})

    Request options.

Returns:

  • (Object)


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

#transactionsObject



40
41
42
# File 'lib/dinie/generated/resources/loans.rb', line 40

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