Module: ArrowPayments::Customers
- Included in:
- Client
- Defined in:
- lib/arrow_payments/client/customers.rb
Instance Method Summary collapse
-
#create_customer(options = {}) ⇒ Customer
Create a new customer.
-
#customer(id) ⇒ Customer
Get an existing customer.
-
#customers ⇒ Array<Customer>
Get all existing customers.
-
#delete_customer(id) ⇒ Boolean
Delete an existing customer.
-
#update_customer(customer) ⇒ Boolean
Update an existing customer attributes.
Instance Method Details
#create_customer(options = {}) ⇒ Customer
Create a new customer
21 22 23 24 |
# File 'lib/arrow_payments/client/customers.rb', line 21 def create_customer(={}) customer = .kind_of?(Hash) ? Customer.new() : Customer.new(post("/customer/add", customer.to_source_hash)) end |
#customer(id) ⇒ Customer
Get an existing customer
12 13 14 15 16 |
# File 'lib/arrow_payments/client/customers.rb', line 12 def customer(id) Customer.new(get("/customer/#{id}")) rescue NotFound nil end |
#customers ⇒ Array<Customer>
Get all existing customers
5 6 7 |
# File 'lib/arrow_payments/client/customers.rb', line 5 def customers get('/customers').map { |c| Customer.new(c) } end |
#delete_customer(id) ⇒ Boolean
Delete an existing customer
40 41 42 43 |
# File 'lib/arrow_payments/client/customers.rb', line 40 def delete_customer(id) resp = post('/customer/delete', 'CustomerID' => id) resp['Success'] == true end |
#update_customer(customer) ⇒ Boolean
Update an existing customer attributes
29 30 31 32 33 34 35 |
# File 'lib/arrow_payments/client/customers.rb', line 29 def update_customer(customer) params = customer.to_source_hash params['CustomerID'] = customer.id resp = post('/customer/update', params) resp['Success'] == true end |