Class: Inttegro::Resources::Products
- Inherits:
-
Object
- Object
- Inttegro::Resources::Products
- Defined in:
- lib/inttegro/resources/products.rb
Overview
Client for products and their catalog lifecycle.
Access this resource through Client#products.
Instance Method Summary collapse
-
#add_price(payload) ⇒ Inttegro::Price::CatalogPrice
Create a new price for an existing product.
-
#archive(product_id:) ⇒ Inttegro::Product
Archive a product and mark it inactive.
-
#create(payload) ⇒ Inttegro::Product
Create a catalog product.
-
#initialize(http) ⇒ Products
constructor
A new instance of Products.
-
#lookup(product_id:) ⇒ Inttegro::Product
Retrieve a product and its related catalog details.
-
#page(payload = {}) ⇒ Inttegro::Product::Page
Retrieve a page of products.
-
#publish(product_id:) ⇒ Inttegro::Product
Mark a product active and record its publication time.
-
#search(payload) ⇒ Inttegro::Search::Page
Search products using indexed fields and full-text matching.
-
#set_default_unit_price(payload) ⇒ Inttegro::Product
Select an existing catalog price as the product's default unit price.
-
#unpublish(product_id:) ⇒ Inttegro::Product
Mark a product inactive without archiving it.
-
#update(payload) ⇒ Inttegro::Product::Updated
Update mutable product fields.
Constructor Details
#initialize(http) ⇒ Products
Returns a new instance of Products.
11 12 13 |
# File 'lib/inttegro/resources/products.rb', line 11 def initialize(http) @http = T.let(http, Inttegro::HTTPClient) end |
Instance Method Details
#add_price(payload) ⇒ Inttegro::Price::CatalogPrice
Create a new price for an existing product.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/inttegro/resources/products.rb', line 27 def add_price(payload) T.cast( @http.post_union_resource( "/products/add_price", [Inttegro::Price::Fixed, Inttegro::Customer::SelectedCatalogPrice], :price, payload ), Inttegro::Price::CatalogPrice ) end |
#archive(product_id:) ⇒ Inttegro::Product
Archive a product and mark it inactive.
83 84 85 |
# File 'lib/inttegro/resources/products.rb', line 83 def archive(product_id:) @http.post_resource("/products/archive", Inttegro::Product, :product, { product_id: product_id }) end |
#create(payload) ⇒ Inttegro::Product
Create a catalog product.
19 20 21 |
# File 'lib/inttegro/resources/products.rb', line 19 def create(payload) @http.post_resource("/products/create", Inttegro::Product, :product, payload) end |
#lookup(product_id:) ⇒ Inttegro::Product
Retrieve a product and its related catalog details.
51 52 53 |
# File 'lib/inttegro/resources/products.rb', line 51 def lookup(product_id:) @http.post_resource("/products/lookup", Inttegro::Product, :product, { product_id: product_id }) end |
#page(payload = {}) ⇒ Inttegro::Product::Page
Retrieve a page of products.
91 92 93 |
# File 'lib/inttegro/resources/products.rb', line 91 def page(payload = {}) @http.post_resource("/products/page", Inttegro::Product::Page, :page, payload || {}) end |
#publish(product_id:) ⇒ Inttegro::Product
Mark a product active and record its publication time.
67 68 69 |
# File 'lib/inttegro/resources/products.rb', line 67 def publish(product_id:) @http.post_resource("/products/publish", Inttegro::Product, :product, { product_id: product_id }) end |
#search(payload) ⇒ Inttegro::Search::Page
Search products using indexed fields and full-text matching.
99 100 101 |
# File 'lib/inttegro/resources/products.rb', line 99 def search(payload) @http.post_resource("/products/search", Inttegro::Search::Page, :search, payload) end |
#set_default_unit_price(payload) ⇒ Inttegro::Product
Select an existing catalog price as the product's default unit price.
43 44 45 |
# File 'lib/inttegro/resources/products.rb', line 43 def set_default_unit_price(payload) @http.post_resource("/products/set_default_unit_price", Inttegro::Product, :product, payload) end |
#unpublish(product_id:) ⇒ Inttegro::Product
Mark a product inactive without archiving it.
75 76 77 |
# File 'lib/inttegro/resources/products.rb', line 75 def unpublish(product_id:) @http.post_resource("/products/unpublish", Inttegro::Product, :product, { product_id: product_id }) end |
#update(payload) ⇒ Inttegro::Product::Updated
Update mutable product fields.
59 60 61 |
# File 'lib/inttegro/resources/products.rb', line 59 def update(payload) @http.post_resource("/products/update", Inttegro::Product::Updated, :product, payload) end |