Class: Celery::Product
- Inherits:
-
Object
- Object
- Celery::Product
- Defined in:
- lib/celery/resources/product.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
Instance Method Summary collapse
-
#all(params = {}) ⇒ JSON
Returns a list of products you have.
-
#destroy(product_id) ⇒ JSON
Deletes an existing product object.
-
#find(product_id) ⇒ JSON
Retrieves a product that has previously been created.
-
#initialize(api) ⇒ Product
constructor
A new instance of Product.
-
#new(product) ⇒ JSON
Creates a new product object.
-
#update(product_id, product) ⇒ JSON
Updates an existing product object.
Constructor Details
#initialize(api) ⇒ Product
Returns a new instance of Product.
5 6 7 |
# File 'lib/celery/resources/product.rb', line 5 def initialize(api) @api = api end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
3 4 5 |
# File 'lib/celery/resources/product.rb', line 3 def api @api end |
Instance Method Details
#all(params = {}) ⇒ JSON
Returns a list of products you have.
32 33 34 |
# File 'lib/celery/resources/product.rb', line 32 def all(params = {}) @api.get("products", query: params) end |
#destroy(product_id) ⇒ JSON
Deletes an existing product object.
117 118 119 |
# File 'lib/celery/resources/product.rb', line 117 def destroy(product_id) @api.delete("products/#{product_id}") end |
#find(product_id) ⇒ JSON
Retrieves a product that has previously been created.
50 51 52 |
# File 'lib/celery/resources/product.rb', line 50 def find(product_id) @api.get("products/#{product_id}") end |
#new(product) ⇒ JSON
Creates a new product object.
76 77 78 |
# File 'lib/celery/resources/product.rb', line 76 def new(product) @api.post("products", body: {product: product}) end |
#update(product_id, product) ⇒ JSON
Updates an existing product object.
98 99 100 |
# File 'lib/celery/resources/product.rb', line 98 def update(product_id, product) @api.put("products/#{product_id}", body: {product: product}) end |