Class: Dinie::Resources::Customers

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

Overview

Operations on the customers resource.

Defined Under Namespace

Classes: CreditOffers, KycAttachments

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Customers

Returns a new instance of Customers.



16
17
18
# File 'lib/dinie/generated/resources/customers.rb', line 16

def initialize(http)
  @http = http
end

Instance Method Details

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

Register a new customer

Register a new customer in ‘creating` status, idempotent on CPF

Parameters:

  • fields (Hash)

    Request body fields.

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

    Request options.

Returns:

  • (Object)


27
28
29
30
31
# File 'lib/dinie/generated/resources/customers.rb', line 27

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

#create_biometrics_session(id, request_options: {}, **fields) ⇒ Object

Create a biometrics capture session

Generate a single-use bootstrap code for the customer-facing biometrics flow. The response includes a ‘session_url` the partner can embed or redirect to — the kyc-app reads the code from the URL and exchanges it for a scoped session token via `POST /biometrics/session-exchange`.

Parameters:

  • id (String)

    Identificador único do cliente

  • fields (Hash)

    Request body fields.

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

    Request options.

Returns:

  • (Object)


41
42
43
44
45
# File 'lib/dinie/generated/resources/customers.rb', line 41

def create_biometrics_session(id, request_options: {}, **fields)
  body = fields
  raw = @http.request(method: :post, path: "/customers/#{id}/biometrics", body:, request_options:)
  BiometricsSession.deserialize(raw)
end

#credit_offersObject



128
129
130
# File 'lib/dinie/generated/resources/customers.rb', line 128

def credit_offers
  @credit_offers ||= CreditOffers.new(@http)
end

#kyc_attachmentsObject



132
133
134
# File 'lib/dinie/generated/resources/customers.rb', line 132

def kyc_attachments
  @kyc_attachments ||= KycAttachments.new(@http)
end

#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}, **filters) ⇒ Object

List customers

List and search customers with optional filters for ‘cpf`, `external_id`, and `status`

Parameters:

  • fields (Hash)

    Request body fields.

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

    Request options.

Returns:

  • (Object)


54
55
56
57
58
59
60
61
62
# File 'lib/dinie/generated/resources/customers.rb', line 54

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: "/customers", query:, request_options:)
    { data: body[:data].map { |raw| Customer.deserialize(raw) }, has_more: body[:has_more] }
  end
  Dinie::Page.from_fetch(fetch_page)
end

#retrieve(id, request_options: {}) ⇒ Object

Retrieve a customer

Return the full customer object including registration data, status, and KYC progress

Parameters:

  • id (String)

    Identificador único do cliente

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

    Request options.

Returns:

  • (Object)


71
72
73
74
# File 'lib/dinie/generated/resources/customers.rb', line 71

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

#retrieve_bank_account(id, request_options: {}) ⇒ Object

Get customer bank account

Return the bank account currently linked to this customer, if one exists.

Parameters:

  • id (String)

    Identificador único do cliente

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

    Request options.

Returns:

  • (Object)


83
84
85
86
# File 'lib/dinie/generated/resources/customers.rb', line 83

def (id, request_options: {})
  raw = @http.request(method: :get, path: "/customers/#{id}/bank-account", request_options:)
  CustomerBankAccount.deserialize(raw)
end

#start_kyc_review(id, request_options: {}) ⇒ Object

Submit documents for KYC review

Signal that all KYC documents have been uploaded and are ready for review. Submits documents to the verification pipeline. Also handles resubmission after document corrections.

Parameters:

  • id (String)

    Identificador único do cliente

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

    Request options.

Returns:

  • (Object)


95
96
97
98
# File 'lib/dinie/generated/resources/customers.rb', line 95

def start_kyc_review(id, request_options: {})
  @http.request(method: :post, path: "/customers/#{id}/kyc-review", request_options:)
  nil
end

#update(id, request_options: {}, **fields) ⇒ Object

Update customer data

Update customer fields such as email or phone; ‘cpf`, `cnpj`, `name`, `trading_name`, and `external_id` are read-only

Parameters:

  • id (String)

    Identificador único do cliente

  • fields (Hash)

    Request body fields.

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

    Request options.

Returns:

  • (Object)


108
109
110
111
112
# File 'lib/dinie/generated/resources/customers.rb', line 108

def update(id, request_options: {}, **fields)
  body = Customer.serialize_update(**fields)
  raw = @http.request(method: :patch, path: "/customers/#{id}", body:, request_options:)
  Customer.deserialize(raw)
end

#upsert_bank_account(id, request_options: {}, **fields) ⇒ Object

Create or update customer bank account

Create or update the bank account linked to this customer. This endpoint is available to biometrics session tokens so the kyc-app can collect disbursement bank data.

Parameters:

  • id (String)

    Identificador único do cliente

  • fields (Hash)

    Request body fields.

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

    Request options.

Returns:

  • (Object)


122
123
124
125
126
# File 'lib/dinie/generated/resources/customers.rb', line 122

def (id, request_options: {}, **fields)
  body = CustomerBankAccount.(**fields)
  raw = @http.request(method: :post, path: "/customers/#{id}/bank-account", body:, request_options:)
  CustomerBankAccount.deserialize(raw)
end