Class: Mercadopago::Customer
- Defined in:
- lib/mercadopago/resources/customer.rb
Overview
Manages customer records for the authenticated MercadoPago account.
Storing customer data enables one-click purchases when combined with the Card resource, which links saved cards to customers.
Instance Method Summary collapse
-
#create(customer_data, request_options: nil) ⇒ Hash{Symbol => Object}
Creates a new customer.
-
#delete(customer_id, request_options: nil) ⇒ Hash{Symbol => Object}
Deletes a customer permanently.
-
#get(customer_id, request_options: nil) ⇒ Hash{Symbol => Object}
Retrieves a single customer by ID.
-
#search(filters: nil, request_options: nil) ⇒ Hash{Symbol => Object}
Searches customers matching the given filters.
-
#update(customer_id, customer_data, request_options: nil) ⇒ Hash{Symbol => Object}
Updates an existing customer.
Methods inherited from MPBase
#_check_headers, #_check_request_options, #_delete, #_get, #_post, #_put, #initialize
Constructor Details
This class inherits a constructor from Mercadopago::MPBase
Instance Method Details
#create(customer_data, request_options: nil) ⇒ Hash{Symbol => Object}
Creates a new customer.
39 40 41 42 43 |
# File 'lib/mercadopago/resources/customer.rb', line 39 def create(customer_data, request_options: nil) raise TypeError, 'Param customer_data must be a Hash' unless customer_data.is_a?(Hash) _post(uri: '/v1/customers', data: customer_data, request_options: ) end |
#delete(customer_id, request_options: nil) ⇒ Hash{Symbol => Object}
Deletes a customer permanently.
64 65 66 |
# File 'lib/mercadopago/resources/customer.rb', line 64 def delete(customer_id, request_options: nil) _delete(uri: "/v1/customers/#{customer_id}", request_options: ) end |
#get(customer_id, request_options: nil) ⇒ Hash{Symbol => Object}
Retrieves a single customer by ID.
28 29 30 |
# File 'lib/mercadopago/resources/customer.rb', line 28 def get(customer_id, request_options: nil) _get(uri: "/v1/customers/#{customer_id}", request_options: ) end |
#search(filters: nil, request_options: nil) ⇒ Hash{Symbol => Object}
Searches customers matching the given filters.
18 19 20 |
# File 'lib/mercadopago/resources/customer.rb', line 18 def search(filters: nil, request_options: nil) _get(uri: '/v1/customers/search', filters: filters, request_options: ) end |
#update(customer_id, customer_data, request_options: nil) ⇒ Hash{Symbol => Object}
Updates an existing customer.
53 54 55 56 57 |
# File 'lib/mercadopago/resources/customer.rb', line 53 def update(customer_id, customer_data, request_options: nil) raise TypeError, 'Param customer_data must be a Hash' unless customer_data.is_a?(Hash) _put(uri: "/v1/customers/#{customer_id}", data: customer_data, request_options: ) end |