Class: EcwidApi::Api::ProductTypes
- Defined in:
- lib/ecwid_api/api/product_types.rb
Instance Method Summary collapse
-
#all(params = {}) ⇒ Object
Public: Get all of the ProductType objects for the Ecwid store.
-
#create(params) ⇒ Object
params - a Hash.
-
#find(id) ⇒ Object
id - an Ecwid product_type ID.
-
#update(id, params) ⇒ Object
id - the Ecwid product_type ID params - a Hash.
Methods inherited from Base
Constructor Details
This class inherits a constructor from EcwidApi::Api::Base
Instance Method Details
#all(params = {}) ⇒ Object
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.
12 13 14 15 16 |
# 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) ⇒ Object
params - a Hash
Raises an Error if there is a problem
Returns a ProductType object
37 38 39 40 |
# 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) ⇒ Object
id - an Ecwid product_type ID
Returns a ProductType object, or nil if one can’t be found
23 24 25 26 27 28 |
# 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) ⇒ Object
id - the Ecwid product_type ID params - a Hash
Raises an Error if there is a problem
Returns a ProductType object
50 51 52 53 |
# File 'lib/ecwid_api/api/product_types.rb', line 50 def update(id, params) client.put("classes/#{id}", params) find(id) end |