Class: PinPays::Customers

Inherits:
Api
  • Object
show all
Defined in:
lib/pin_pays/customers.rb

Constant Summary collapse

PATH =
'/customers'

Constants inherited from Api

Api::LIVE_URI, Api::TEST_URI

Class Method Summary collapse

Methods inherited from Api

setup

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)
  options = (page.nil? ? nil : { page: page })
  api_paginated_response(api_get("#{PATH}/#{customer_token}/charges", options))
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)
  options = { email: email }
  options = options.merge(card.is_a?(String) ? { card_token: card } : { card: card })
  api_response(api_post(PATH, options))
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)
  options = (page.nil? ? nil : { page: page })
  api_paginated_response(api_get(PATH, options))
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, options)
  api_response(api_put("#{PATH}/#{customer_token}", options))
end