Class: Pin::Customer
Overview
This class models Pins Customers API
Class Method Summary collapse
-
.all ⇒ Object
Lists all customers for your account returns: a collection of customer objects pin.net.au/docs/api/customers#get-customers.
-
.charges(token) ⇒ Object
Get a list of charges for a customer args: token (String) returns: a collection of charge objects pin.net.au/docs/api/customers#get-customers-charges.
-
.create(email, card) ⇒ Object
Create a customer given customer details and a card OR a card_token args: email(String), card (Hash) returns: a customer object pin.net.au/docs/api/customers#post-customers.
-
.find(token) ⇒ Object
Find a customer for your account given a token args: token (String) returns: a customer object pin.net.au/docs/api/customers#get-customers.
-
.update(token, options = {}) ⇒ Object
Update a customer for your account given a token and any of: email, card (hash),card_token args: token (String), options (Hash) returns: a customer object pin.net.au/docs/api/customers#put-customer NB: When providing a card (hash), you need to specify the full list of details.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Pin::Base
Class Method Details
.all ⇒ Object
Lists all customers for your account returns: a collection of customer objects pin.net.au/docs/api/customers#get-customers
10 11 12 |
# File 'lib/pin_up/customer.rb', line 10 def self.all build_collection_response(auth_get('customers')) end |
.charges(token) ⇒ Object
Get a list of charges for a customer args: token (String) returns: a collection of charge objects pin.net.au/docs/api/customers#get-customers-charges
53 54 55 |
# File 'lib/pin_up/customer.rb', line 53 def self.charges(token) build_collection_response(auth_get("customers/#{token}/charges")) end |
.create(email, card) ⇒ Object
Create a customer given customer details and a card OR a card_token args: email(String), card (Hash) returns: a customer object pin.net.au/docs/api/customers#post-customers
19 20 21 22 23 24 25 26 27 |
# File 'lib/pin_up/customer.rb', line 19 def self.create(email, card) = if card.respond_to?(:to_hash) {card: card.to_hash} else {card_token: card} end.merge(email: email) build_response(auth_post('customers', )) end |
.find(token) ⇒ Object
Find a customer for your account given a token args: token (String) returns: a customer object pin.net.au/docs/api/customers#get-customers
34 35 36 |
# File 'lib/pin_up/customer.rb', line 34 def self.find(token) build_response(auth_get("customers/#{token}")) end |
.update(token, options = {}) ⇒ Object
Update a customer for your account given a token and any of: email, card (hash),card_token args: token (String), options (Hash) returns: a customer object pin.net.au/docs/api/customers#put-customer NB: When providing a card (hash), you need to specify the full list of details.
44 45 46 |
# File 'lib/pin_up/customer.rb', line 44 def self.update(token, = {}) build_response(auth_put("customers/#{token}", )) end |