Class: Dinie::Resources::Customers

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

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.

Parameters:



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) ⇒ Dinie::Customer

Register a new customer (POST /customers).

Parameters:

  • email: (String)
  • phone: (String)
  • cpf: (String)
  • cnpj: (String)
  • name: (String)
  • external_id: (String)
  • request_options: (request_opts) (defaults to: {})

Returns:



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) ⇒ Dinie::BiometricsSession

Generate a temporary biometrics-capture session (POST /customers/{id}/biometrics).

Parameters:

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

Returns:



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_offers ⇒ Dinie::Resources::Customers::CreditOffers

The customer credit-offers subresource (customers.credit_offers).



34
35
36
# File 'sig/dinie/generated/resources/customers.rbs', line 34

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

#kyc_attachments ⇒ Dinie::Resources::Customers::KycAttachments

The KYC attachments subresource (customers.kyc_attachments).



37
38
39
# File 'sig/dinie/generated/resources/customers.rbs', line 37

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

#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}, **filters) ⇒ Dinie::Page[Dinie::Customer]

List and search customers (GET /customers), auto-paginating by starting_after.

Parameters:

  • limit: (Integer) (defaults to: Internal::OMIT)
  • starting_after: (String) (defaults to: Internal::OMIT)
  • request_options: (request_opts) (defaults to: {})
  • filters (Object)

Returns:



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

#paginated_query ⇒ Hash[Symbol, untyped]

Parameters:

  • limit: (Object)
  • starting_after: (Object)
  • cursor: (Object)
  • filters: (Hash[Symbol, untyped])

Returns:

  • (Hash[Symbol, untyped])


41
# File 'sig/dinie/generated/resources/customers.rbs', line 41

def paginated_query: (limit: untyped, starting_after: untyped, cursor: untyped, filters: Hash[Symbol, untyped]) -> Hash[Symbol, untyped]

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

Retrieve the full customer object (GET /customers/{id}).

Parameters:

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

Returns:



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

Retrieve the customer's linked bank account (GET /customers/{id}/bank-account).

Parameters:

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

Returns:



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

KYC review trigger (POST /customers/{id}/kyc-review → 202, no content).

Parameters:

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

Returns:

  • (nil)


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) ⇒ Dinie::Customer

Update mutable customer fields (PATCH /customers/{id}).

Parameters:

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

Returns:



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) ⇒ Dinie::CustomerBankAccount

Create or update the customer's disbursement bank account (POST /customers/{id}/bank-account).

Parameters:

  • customer_id (String)
  • request_options: (request_opts) (defaults to: {})
  • fields (Object)

Returns:



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