class EcwidApi::Api::ProductTypes

Public Instance Methods

all(params = {}) click to toggle source

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

Returns an Array of ProductType objects NOTE: This endpoint does not behave like other Ecwid endpoints in that

it does not return paged results.  It simply returns every
result in an array, without a wrapper with an "items" property.
# File lib/ecwid_api/api/product_types.rb, line 12
def all(params = {})
  UnpagedEcwidResponse.new(client, "classes") do |product_type_hash|
    ProductType.new(product_type_hash, client: client)
  end
end
create(params) click to toggle source

Public: Creates a new ProductType

params - a Hash

Raises an Error if there is a problem

Returns a ProductType object

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

Public: Finds a single product_type by product_type ID

id - an Ecwid product_type ID

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

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

Public: Updates an existing ProductType

id - the Ecwid product_type ID params - a Hash

Raises an Error if there is a problem

Returns a ProductType object

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