Class: PinPays::Customers
Constant Summary collapse
- PATH =
'/customers'
Constants inherited from Api
Class Method Summary collapse
-
.charges(customer_token, page = nil) ⇒ Object
List all charges for a customer Page - the page number to return (optional).
-
.create(email, card) ⇒ Object
Creates a customer card - either a card token (string), or a hash of card details.
-
.list(page = nil) ⇒ Object
List all customers Page - the page number to return (optional).
-
.show(customer_token) ⇒ Object
Retrieve details of a specific customer.
-
.update(customer_token, options) ⇒ Object
Update a customer Options - a hash specifying one or more of: email, card_token, or card (hash).
Methods inherited from Api
Class Method Details
.charges(customer_token, page = nil) ⇒ Object
List all charges for a customer Page - the page number to return (optional)
35 36 37 38 |
# File 'lib/pin_pays/customers.rb', line 35 def charges(customer_token, page = nil) = (page.nil? ? nil : { page: page }) api_paginated_response(api_get("#{PATH}/#{customer_token}/charges", )) end |
.create(email, card) ⇒ Object
Creates a customer
card - either a card token (string), or a hash of card details
9 10 11 12 13 |
# File 'lib/pin_pays/customers.rb', line 9 def create(email, card) = { email: email } = .merge(card.is_a?(String) ? { card_token: card } : { card: card }) api_response(api_post(PATH, )) end |
.list(page = nil) ⇒ Object
List all customers Page - the page number to return (optional)
17 18 19 20 |
# File 'lib/pin_pays/customers.rb', line 17 def list(page = nil) = (page.nil? ? nil : { page: page }) api_paginated_response(api_get(PATH, )) end |
.show(customer_token) ⇒ Object
Retrieve details of a specific customer
23 24 25 |
# File 'lib/pin_pays/customers.rb', line 23 def show(customer_token) api_response(api_get("#{PATH}/#{customer_token}")) end |
.update(customer_token, options) ⇒ Object
Update a customer Options - a hash specifying one or more of: email, card_token, or card (hash)
29 30 31 |
# File 'lib/pin_pays/customers.rb', line 29 def update(customer_token, ) api_response(api_put("#{PATH}/#{customer_token}", )) end |