Class: Dinie::Resources::Customers
- Inherits:
-
Object
- Object
- Dinie::Resources::Customers
- 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
-
#create(request_options: {}, **fields) ⇒ Dinie::Customer
Register a new customer (
POST /customers). -
#create_biometrics_session(id, request_options: {}, **fields) ⇒ Dinie::BiometricsSession
Generate a temporary biometrics-capture session (
POST /customers/{id}/biometrics). -
#credit_offers ⇒ Dinie::Resources::Customers::CreditOffers
The customer credit-offers subresource (
customers.credit_offers). -
#initialize(http) ⇒ Customers
constructor
A new instance of Customers.
-
#kyc_attachments ⇒ Dinie::Resources::Customers::KycAttachments
The KYC attachments subresource (
customers.kyc_attachments). -
#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}, **filters) ⇒ Dinie::Page[Dinie::Customer]
List and search customers (
GET /customers), auto-paginating bystarting_after. - #paginated_query ⇒ Hash[Symbol, untyped]
-
#retrieve(id, request_options: {}) ⇒ Dinie::Customer
Retrieve the full customer object (
GET /customers/{id}). -
#retrieve_bank_account(id, request_options: {}) ⇒ Dinie::CustomerBankAccount
Retrieve the customer's linked bank account (
GET /customers/{id}/bank-account). -
#start_kyc_review(id, request_options: {}) ⇒ nil
KYC review trigger (
POST /customers/{id}/kyc-review→ 202, no content). -
#update(id, request_options: {}, **fields) ⇒ Dinie::Customer
Update mutable customer fields (
PATCH /customers/{id}). -
#upsert_bank_account(id, request_options: {}, **fields) ⇒ Dinie::CustomerBankAccount
Create or update the customer's disbursement bank account (
POST /customers/{id}/bank-account).
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) ⇒ Dinie::Customer
Register a new customer (POST /customers).
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).
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 ||= 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.
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]
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}).
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).
83 84 85 86 |
# File 'lib/dinie/generated/resources/customers.rb', line 83 def retrieve_bank_account(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).
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}).
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).
122 123 124 125 126 |
# File 'lib/dinie/generated/resources/customers.rb', line 122 def upsert_bank_account(id, request_options: {}, **fields) body = CustomerBankAccount.serialize_upsert_bank_account(**fields) raw = @http.request(method: :post, path: "/customers/#{id}/bank-account", body:, request_options:) CustomerBankAccount.deserialize(raw) end |