Module: Orderspace::Endpoint::Customers
- Includes:
- Structs
- Included in:
- Client::CustomersEndpoint
- Defined in:
- lib/orderspace/endpoint/customers.rb
Overview
Contains the methods to interact with the customers endpoint.
Instance Method Summary collapse
-
#create_customer(customer) ⇒ Orderspace::Structs::Customer
Used to add a customer to your orderspace account.
-
#edit_customer(customer) ⇒ Object
Allows to edit the customer and change it’s attributes.
-
#get_customer(customer_id) ⇒ Orderspace::Structs::Customer
Returns a customer searching by it’s id.
-
#list_customers(options = {}) ⇒ Object
Lists all the customers in your account.
Methods included from Structs
Instance Method Details
#create_customer(customer) ⇒ Orderspace::Structs::Customer
Used to add a customer to your orderspace account
18 19 20 21 |
# File 'lib/orderspace/endpoint/customers.rb', line 18 def create_customer(customer) response = client.post('customers', { customer: Orderspace::Structs.hashify(customer) }) Orderspace::Structs.from(JSON.parse(response.body)['customer'], Customer) end |
#edit_customer(customer) ⇒ Object
Allows to edit the customer and change it’s attributes
53 54 55 56 57 |
# File 'lib/orderspace/endpoint/customers.rb', line 53 def edit_customer(customer) response = client.put("customers/#{customer.id}", { customer: Orderspace::Structs.hashify(customer) }) Orderspace::Structs.from(JSON.parse(response.body)['customer'], Customer) end |
#get_customer(customer_id) ⇒ Orderspace::Structs::Customer
Returns a customer searching by it’s id
44 45 46 47 48 |
# File 'lib/orderspace/endpoint/customers.rb', line 44 def get_customer(customer_id) response = client.get("customers/#{customer_id}") Orderspace::Structs.from(JSON.parse(response.body)['customer'], Customer) end |
#list_customers(options = {}) ⇒ Object
Lists all the customers in your account.
You can pass in options like so: { query: { starting_after: ‘cu_53zjgvnm’, limit: 1 } }
Check tho orderspace API documentation to know all the options available.
34 35 36 37 38 |
# File 'lib/orderspace/endpoint/customers.rb', line 34 def list_customers( = {}) response = client.get('customers', ) Orderspace::Structs.from(JSON.parse(response.body), CustomerList) end |