Class: Cordial::Products
- Inherits:
-
Object
- Object
- Cordial::Products
- Extended by:
- Client
- Includes:
- HTTParty
- Defined in:
- lib/cordial/products.rb
Overview
Pragmatic wrapper around the products REST Api.
Class Method Summary collapse
-
.create(id:, name:, options: {}) ⇒ Object
Create a new product.
-
.find(id:) ⇒ Hash, {"error"=>true, "message"=>"record not found"}
Find a product.
Methods included from Client
Class Method Details
.create(id:, name:, options: {}) ⇒ Object
Note:
If the product already exists it will be updated.
Create a new product.
57 58 59 60 61 62 63 64 |
# File 'lib/cordial/products.rb', line 57 def self.create(id:, name:, options: {}) body = { productID: id, productName: name }.merge().compact client.post('/products', body: body.to_json) end |
.find(id:) ⇒ Hash, {"error"=>true, "message"=>"record not found"}
Find a product.
16 17 18 |
# File 'lib/cordial/products.rb', line 16 def self.find(id:) client.get("/products/#{id}") end |