Module: Vindi::Rest::Customer

Included in:
Vindi::Rest
Defined in:
lib/vindi/rest/customer.rb

Overview

Methods for the Customers API

Instance Method Summary collapse

Instance Method Details

#create_customer(options = {}) ⇒ Hash

Create a customer for a merchant vindi

Examples:

Create a customer for a merchant vindi

client.create_customer(name: 'John Doe', email: '[email protected]')

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :options (Hash)

    customer attributes

Returns:

  • (Hash)

    The customer created

See Also:



33
34
35
# File 'lib/vindi/rest/customer.rb', line 33

def create_customer(options = {})
  post('customers', options)[:customer]
end

#customer(customer_id, options = {}) ⇒ Hash

Get a single customer from a merchant

Examples:

Get customer #2 from vindi

client.customer(2)

Parameters:

  • customer_id (Integer)

    ID of the customer

Returns:

  • (Hash)

    The customer you requested, if it exists

See Also:



22
23
24
# File 'lib/vindi/rest/customer.rb', line 22

def customer(customer_id, options = {})
  get("customers/#{customer_id}", options)[:customer]
end

#delete_customer(customer_id, options = {}) ⇒ Object

Delete a customer from merchant vindi

Examples:

Delete customer #2

client.delete_customer(2)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :options (Hash)

    customer attributes

See Also:



56
57
58
# File 'lib/vindi/rest/customer.rb', line 56

def delete_customer(customer_id, options = {})
  delete("customers/#{customer_id}", options)[:customer]
end

#list_customers(options = {}) ⇒ Array<Hash>

List customer for the authenticate user

Examples:

Get all customers from merchant vindi

Returns:

  • (Array<Hash>)

    A list of customers for a merchant.



11
12
13
# File 'lib/vindi/rest/customer.rb', line 11

def list_customers(options = {})
  get('customers', options)[:customers]
end

#unarchive_customer(customer_id, options = {}) ⇒ Object

Unarchive a customer from merchant vindi

Examples:

Unarchive customer #2

client.unarchive_customer(2)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :options (Hash)

    customer attributes

See Also:



69
70
71
# File 'lib/vindi/rest/customer.rb', line 69

def unarchive_customer(customer_id, options = {})
  post("customers/#{customer_id}/unarchive", options)[:customer]
end

#update_customer(customer_id, options = {}) ⇒ Object

Edit a customer

Examples:

update customer #2

client.update_customer(2, name: 'Joana Doe', email: '[email protected]')

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :options (Hash)

    customer attributes

See Also:



44
45
46
# File 'lib/vindi/rest/customer.rb', line 44

def update_customer(customer_id, options = {})
  put("customers/#{customer_id}", options)[:customer]
end