class EcwidApi::Api::Customers

Public Instance Methods

all(params = {}) click to toggle source

Public: Get all of the Customer objects for the Ecwid store

Returns an Array of Customer objects

# File lib/ecwid_api/api/customers.rb, line 9
def all(params = {})
  PagedEcwidResponse.new(client, "customers", params) do |customer_hash|
    Customer.new(customer_hash, client: client)
  end
end
create(params) click to toggle source

Public: Creates a new Customer

params - a Hash

Raises an Error if there is a problem

Returns a Customer object

# File lib/ecwid_api/api/customers.rb, line 34
def create(params)
  response = client.post("customers", params)
  find(response.body["id"])
end
find(id) click to toggle source

Public: Finds a single customer by customer ID

id - an Ecwid customer ID

Returns a Customer object, or nil if one can't be found

# File lib/ecwid_api/api/customers.rb, line 20
def find(id)
  response = client.get("customers/#{id}")
  if response.success?
    Customer.new(response.body, client: client)
  end
end
update(id, params) click to toggle source

Public: Updates an existing Customer

id - the Ecwid customer ID params - a Hash

Raises an Error if there is a problem

Returns a Customer object

# File lib/ecwid_api/api/customers.rb, line 47
def update(id, params)
  client.put("customers/#{id}", params)
  find(id)
end