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:



25
26
27
28
# File 'lib/arrow_payments/client/customers.rb', line 25

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 Also known as: get_customer

Get an existing customer

Parameters:

  • customer (Integer)

    ID

Returns:



14
15
16
17
18
# File 'lib/arrow_payments/client/customers.rb', line 14

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)


44
45
46
47
# File 'lib/arrow_payments/client/customers.rb', line 44

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



33
34
35
36
37
38
39
# File 'lib/arrow_payments/client/customers.rb', line 33

def update_customer(customer)
  params = customer.to_source_hash
  params['CustomerID'] = customer.id

  resp = post('/customer/update', params)
  resp['Success'] == true
end