Module: ArrowPayments::Customers

Included in:
Client
Defined in:
lib/arrow_payments/client/customers.rb

Instance Method Summary collapse

Instance Method Details

#create_customer(options = {}) ⇒ Customer

Create a new customer

Parameters:

  • customer (Hash)

    attributes

Returns:



21
22
23
24
# File 'lib/arrow_payments/client/customers.rb', line 21

def create_customer(options={})
  customer = options.kind_of?(Hash) ? Customer.new(options) : options
  Customer.new(post("/customer/add", customer.to_source_hash))
end

#customer(id) ⇒ Customer

Get an existing customer

Parameters:

  • customer (Integer)

    ID

Returns:



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

#customersArray<Customer>

Get all existing customers

Returns:



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

Parameters:

  • customer (Integer)

    ID

Returns:

  • (Boolean)


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

Parameters:

Returns:

  • (Boolean)

    update result



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