class Pin::Customer
This class models Pins Customers API
Public Class Methods
Lists all customers for your account args: page (Fixnum), pagination (Boolean) returns: a collection of customer objects
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
pinpayments.com/docs/api/customers#get-customers
# File lib/pin_up/customer.rb, line 14 def self.all(page = nil, pagination = false) build_collection_response(make_request(:get, {url: "customers?page=#{page}" } ), pagination) end
Get a list of cards for a customer args: token (String), page (Fixnum), pagination (Boolean) returns: a collection of cards objects
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
pinpayments.com/docs/api/customers#get-customers-cards
# File lib/pin_up/customer.rb, line 78 def self.cards(token, page = nil, pagination = false) build_collection_response( make_request(:get, {url: "customers/#{token}/cards?page=#{page}" }), pagination ) end
Get a list of charges for a customer args: token (String), page (Fixnum), pagination (Boolean) returns: a collection of charge objects
if pagination is passed, access the response hash with [:response] and the pagination hash with [:pagination]
pinpayments.com/docs/api/customers#get-customers-charges
# File lib/pin_up/customer.rb, line 63 def self.charges(token, page = nil, pagination = false) build_collection_response( make_request(:get, {url: "customers/#{token}/charges?page=#{page}" }), pagination ) end
Create a customer given customer details and a card OR a card_token args: email(String), card (Hash) returns: a customer object pinpayments.com/docs/api/customers#post-customers
# File lib/pin_up/customer.rb, line 23 def self.create(email, card) options = if card.respond_to?(:to_hash) { card: card.to_hash } else { card_token: card } end.merge(email: email) build_response(make_request(:post, { url: 'customers', options: options })) end
Create a card for customer given a card OR a card_token args: customer_token (String), card (Hash) or (String) see docs. returns: a card object pinpayments.com/docs/api/customers#post-customers-cards
# File lib/pin_up/customer.rb, line 89 def self.create_card(token, card) options = if card.respond_to?(:to_hash) card else { card_token: card } end build_response(make_request(:post, {url: "customers/#{token}/cards", options: options} )) end
Deletes a card for customer given a card_token args: customer_token (String), card_token (String) returns: a card object pinpayments.com/docs/api/customers#delete-customers-card
# File lib/pin_up/customer.rb, line 104 def self.delete_card(token, card_token) build_response(make_request(:delete, {url: "customers/#{token}/cards/#{card_token}"} )) end
Find a customer for your account given a token args: token (String) returns: a customer object pinpayments.com/docs/api/customers#get-customers
# File lib/pin_up/customer.rb, line 38 def self.find(token) build_response(make_request(:get, {url: "customers/#{token}" } )) end
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 pinpayments.com/docs/api/customers#put-customer NB: When providing a card (hash), you need to specify the full list of details.
# File lib/pin_up/customer.rb, line 50 def self.update(token, options = {}) build_response(make_request(:put, { url: "customers/#{token}", options: options })) end