Class: Dodopayments::Resources::Customers
- Inherits:
-
Object
- Object
- Dodopayments::Resources::Customers
show all
- Defined in:
- lib/dodopayments/resources/customers.rb,
lib/dodopayments/resources/customers/wallets.rb,
lib/dodopayments/resources/customers/customer_portal.rb,
lib/dodopayments/resources/customers/wallets/ledger_entries.rb
Defined Under Namespace
Classes: CustomerPortal, Wallets
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#create(email:, name:, metadata: nil, phone_number: nil, request_options: {}) ⇒ Dodopayments::Models::Customer
-
#delete_payment_method(payment_method_id, customer_id:, request_options: {}) ⇒ nil
-
#initialize(client:) ⇒ Customers
constructor
private
A new instance of Customers.
-
#list(created_at_gte: nil, created_at_lte: nil, email: nil, name: nil, page_number: nil, page_size: nil, request_options: {}) ⇒ Dodopayments::Internal::DefaultPageNumberPagination<Dodopayments::Models::Customer>
-
#list_credit_entitlements(customer_id, request_options: {}) ⇒ Dodopayments::Models::CustomerListCreditEntitlementsResponse
List all credit entitlements for a customer with their current balances.
-
#retrieve(customer_id, request_options: {}) ⇒ Dodopayments::Models::Customer
-
#retrieve_payment_methods(customer_id, request_options: {}) ⇒ Dodopayments::Models::CustomerRetrievePaymentMethodsResponse
-
#update(customer_id, email: nil, metadata: nil, name: nil, phone_number: nil, request_options: {}) ⇒ Dodopayments::Models::Customer
Constructor Details
#initialize(client:) ⇒ Customers
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Customers.
Instance Attribute Details
7
8
9
|
# File 'lib/dodopayments/resources/customers.rb', line 7
def customer_portal
@customer_portal
end
|
10
11
12
|
# File 'lib/dodopayments/resources/customers.rb', line 10
def wallets
@wallets
end
|
Instance Method Details
#create(email:, name:, metadata: nil, phone_number: nil, request_options: {}) ⇒ Dodopayments::Models::Customer
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/dodopayments/resources/customers.rb', line 27
def create(params)
parsed, options = Dodopayments::CustomerCreateParams.dump_request(params)
@client.request(
method: :post,
path: "customers",
body: parsed,
model: Dodopayments::Customer,
options: options
)
end
|
#delete_payment_method(payment_method_id, customer_id:, request_options: {}) ⇒ nil
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/dodopayments/resources/customers.rb', line 127
def delete_payment_method(payment_method_id, params)
parsed, options = Dodopayments::CustomerDeletePaymentMethodParams.dump_request(params)
customer_id =
parsed.delete(:customer_id) do
raise ArgumentError.new("missing required path argument #{_1}")
end
@client.request(
method: :delete,
path: ["customers/%1$s/payment-methods/%2$s", customer_id, payment_method_id],
model: NilClass,
options: options
)
end
|
List all credit entitlements for a customer with their current balances
152
153
154
155
156
157
158
159
|
# File 'lib/dodopayments/resources/customers.rb', line 152
def list_credit_entitlements(customer_id, params = {})
@client.request(
method: :get,
path: ["customers/%1$s/credit-entitlements", customer_id],
model: Dodopayments::Models::CustomerListCreditEntitlementsResponse,
options: params[:request_options]
)
end
|
47
48
49
50
51
52
53
54
|
# File 'lib/dodopayments/resources/customers.rb', line 47
def retrieve(customer_id, params = {})
@client.request(
method: :get,
path: ["customers/%1$s", customer_id],
model: Dodopayments::Customer,
options: params[:request_options]
)
end
|
170
171
172
173
174
175
176
177
|
# File 'lib/dodopayments/resources/customers.rb', line 170
def retrieve_payment_methods(customer_id, params = {})
@client.request(
method: :get,
path: ["customers/%1$s/payment-methods", customer_id],
model: Dodopayments::Models::CustomerRetrievePaymentMethodsResponse,
options: params[:request_options]
)
end
|
#update(customer_id, email: nil, metadata: nil, name: nil, phone_number: nil, request_options: {}) ⇒ Dodopayments::Models::Customer
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/dodopayments/resources/customers.rb', line 73
def update(customer_id, params = {})
parsed, options = Dodopayments::CustomerUpdateParams.dump_request(params)
@client.request(
method: :patch,
path: ["customers/%1$s", customer_id],
body: parsed,
model: Dodopayments::Customer,
options: options
)
end
|