Class: Pago::V2026_04::Services::CustomerPortal::Customers

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/customer_portal.rb,
sig/pago/v2026_04/generated.rbs

Instance Attribute Summary

Attributes inherited from Service

#client

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Pago::Service

Instance Method Details

#add_payment_method(body: {}) ⇒ Object

Add a payment method to the authenticated customer.

Parameters:

Returns:

  • (Object)

Raises:



206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 206

def add_payment_method(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/customer-portal/customers/me/payment-methods",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 400 => Errors::PaymentMethodSetupFailed, 422 => Errors::HTTPValidationError }
  )
  Unions::CustomerPaymentMethodCreateResponse.from_json(data)
end

#check_email_update(token:) ⇒ nil

Check if an email change verification token is still valid.

Parameters:

  • token (String)
  • token: (String)

Returns:

  • (nil)

Raises:



284
285
286
287
288
289
290
291
292
293
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 284

def check_email_update(token:)
  client.request(
    http_method: "GET",
    path: "/v1/customer-portal/customers/me/email-update/check",
    path_params: {},
    query: { "token" => token },
    response_type: :none,
    errors: { 401 => Errors::CheckEmailUpdate401Error, 422 => Errors::HTTPValidationError }
  )
end

#confirm_payment_method(body: {}) ⇒ Object

Confirm a payment method for the authenticated customer.

Parameters:

Returns:

  • (Object)

Raises:



226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 226

def confirm_payment_method(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/customer-portal/customers/me/payment-methods/confirm",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 400 => Errors::CustomerNotReady, 422 => Errors::HTTPValidationError }
  )
  Unions::CustomerPaymentMethodCreateResponse.from_json(data)
end

#delete_payment_method(id) ⇒ nil

Delete a payment method from the authenticated customer.

Parameters:

  • id (String)

Returns:

  • (nil)

Raises:



247
248
249
250
251
252
253
254
255
256
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 247

def delete_payment_method(id)
  client.request(
    http_method: "DELETE",
    path: "/v1/customer-portal/customers/me/payment-methods/{id}",
    path_params: { "id" => id },
    query: {},
    response_type: :none,
    errors: { 400 => Errors::PaymentMethodInUseByActiveSubscription, 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
end

#getModels::CustomerPortalCustomer

Get authenticated customer.

Scopes: customer_portal:read customer_portal:write

Returns:

Raises:



138
139
140
141
142
143
144
145
146
147
148
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 138

def get()
  data = client.request(
    http_method: "GET",
    path: "/v1/customer-portal/customers/me",
    path_params: {},
    query: {},
    response_type: :json,
    errors: {  }
  )
  Models::CustomerPortalCustomer.from_json(data)
end

#list_payment_methods(page: 1, limit: 10) ⇒ Models::ListResourceCustomerPaymentMethod

Get saved payment methods of the authenticated customer.

Parameters:

  • page (Integer) (defaults to: 1)

    Page number, defaults to 1.

  • limit (Integer) (defaults to: 10)

    Size of a page, defaults to 10. Maximum is 100.

  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)

Returns:

Raises:



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 176

def list_payment_methods(page: 1, limit: 10)
  data = client.request(
    http_method: "GET",
    path: "/v1/customer-portal/customers/me/payment-methods",
    path_params: {},
    query: { "page" => page, "limit" => limit },
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::ListResourceCustomerPaymentMethod.from_json(data)
end

#list_payment_methods_each(limit: 10) {|item| ... } ⇒ Pago::Paginator

Enumerate every item of list_payment_methods, fetching pages on demand.

Parameters:

  • limit: (Integer, nil) (defaults to: 10)

Yield Parameters:

  • item (Object)

Returns:



192
193
194
195
196
197
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 192

def list_payment_methods_each(limit: 10, &block)
  paginator = ::Pago::Paginator.new do |page_number|
    list_payment_methods(page: page_number, limit: limit)
  end
  block ? paginator.each(&block) : paginator
end

#request_email_update(body: {}) ⇒ Object

Request an email change for the authenticated customer.

Parameters:

Returns:

  • (Object)

Raises:



264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 264

def request_email_update(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/customer-portal/customers/me/email-update/request",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  data
end

#update(body: {}) ⇒ Models::CustomerPortalCustomer

Update authenticated customer.

Parameters:

Returns:

Raises:



156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 156

def update(body: {})
  data = client.request(
    http_method: "PATCH",
    path: "/v1/customer-portal/customers/me",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::CustomerPortalCustomer.from_json(data)
end

#verify_email_update(body: {}) ⇒ Models::CustomerEmailUpdateVerifyResponse

Verify an email change using the token from the verification email.

Parameters:

Returns:

Raises:



302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/pago/v2026_04/services/customer_portal.rb', line 302

def verify_email_update(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/customer-portal/customers/me/email-update/verify",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 401 => Errors::VerifyEmailUpdate401Error, 422 => Errors::VerifyEmailUpdate422Error }
  )
  Models::CustomerEmailUpdateVerifyResponse.from_json(data)
end