Class: BeyondApi::Products
- Includes:
- ProductAttachments, ProductAvailability, ProductCrossSells, ProductCustomAttributes, ProductImages, ProductSearches, ProductVariationProperties, ProductVideos, Utils
- Defined in:
- lib/beyond_api/resources/products.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#all(params = {}) ⇒ OpenStruct
A
GET
request will list all of the products in a paged manner. -
#assign_variation_attribute_as_differentiator(product_id, variation_attribute_id) ⇒ true
A
POST
request is used to assign a variation attribute as the variation images differentiator for a variation product. -
#create(body) ⇒ OpenStruct
(also: #create_variation)
A
POST
request is used to create a product. -
#delete(product_id) ⇒ Object
A
DELETE
request is used to delete a product or variation product. -
#find(product_id) ⇒ OpenStruct
(also: #find_variation)
A
GET
request is used to retrieve the details of a product. -
#update(product_id, body) ⇒ OpenStruct
(also: #update_variation)
A
PATCH
request is used to update a product partially with json content type.
Methods included from Utils
#file_content_type, #handle_all_request, #handle_error, #handle_response, #sanitize_key, #sanitize_response, #to_object_struct
Methods included from ProductVideos
#add_video, #delete_video, #update_video, #video, #videos
Methods included from ProductVariationProperties
#update_variation_properties, #variation_properties
Methods included from ProductSearches
#search, #search_by_sku, #search_tags_starting_by
Methods included from ProductImages
#add_image, #delete_image, #image, #images, #set_image_as_default, #sort_images, #upload_image, #upload_multiple_images
Methods included from ProductCustomAttributes
#create_custom_attribute, #custom_attribute, #custom_attributes, #delete_custom_attribute, #update_custom_attribute
Methods included from ProductCrossSells
#create_cross_sell, #cross_sell, #cross_sells, #delete_cross_sell, #update_cross_sell
Methods included from ProductAvailability
#adjust_stock_level, #availability, #disable_purchasability, #disable_stock_management, #enable_purchasability, #enable_stock_management, #update_reserve_stock
Methods included from ProductAttachments
#add_attachment, #attachment, #attachments, #delete_attachment
Methods inherited from Base
Constructor Details
This class inherits a constructor from BeyondApi::Base
Instance Method Details
#all(params = {}) ⇒ OpenStruct
A GET
request will list all of the products in a paged manner. The returned data is an excerpt projection, which includes a small subset of product properties.
$ curl 'https://api-shop.beyondshop.cloud/api/products' -i -X GET \
-H 'Content-Type: application/hal+json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
45 46 47 48 49 |
# File 'lib/beyond_api/resources/products.rb', line 45 def all(params = {}) path = "/products" handle_all_request(path, :products, params) end |
#assign_variation_attribute_as_differentiator(product_id, variation_attribute_id) ⇒ true
A POST
request is used to assign a variation attribute as the variation images differentiator for a variation product.
289 290 291 292 293 294 295 296 |
# File 'lib/beyond_api/resources/products.rb', line 289 def assign_variation_attribute_as_differentiator(product_id, variation_attribute_id) path = "/products/#{product_id}/variation-attributes/#{variation_attribute_id}/make-differentiator" response, status = BeyondApi::Request.post(@session, path) handle_response(response, status, respond_with_true: true) end |
#create(body) ⇒ OpenStruct Also known as: create_variation
A POST
request is used to create a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <Access token>' \
-d '{
"sku" : "123456789-001",
"name" : "Rioja Castillo de Puerto (2013)",
"description" : "Spain\nRioja Tempranillo",
"manufacturer" : "Grape Vineyard",
"essentialFeatures" : "Dry. 12% alcohol. Best vine variety.",
"tags" : [ "Bestseller", "Red Wine", "Sale" ],
"productIdentifiers" : [ {
"type" : "EAN",
"value" : "9780134308135"
} ],
"salesPrice" : {
"taxModel" : "NET",
"amount" : 8.7,
"currency" : "EUR"
},
"listPrice" : {
"taxModel" : "NET",
"amount" : 10.95,
"currency" : "EUR"
},
"manufacturerPrice" : {
"taxModel" : "NET",
"amount" : 99.95,
"currency" : "EUR"
},
"visible" : true,
"taxClass" : "REGULAR",
"shippingWeight" : 100,
"maxOrderQuantity" : 6,
"shippingDimension" : {
"length" : 1500,
"width" : 1000,
"height" : 2000
},
"refPrice" : {
"refQuantity" : 1,
"unit" : "LITER",
"quantity" : 0.75,
"price" : {
"taxModel" : "NET",
"amount" : 11.6,
"currency" : "EUR"
}
},
"shippingPeriod" : {
"min" : 2,
"max" : 4,
"displayUnit" : "WEEKS"
}
}'
170 171 172 173 174 175 176 177 178 |
# File 'lib/beyond_api/resources/products.rb', line 170 def create(body) path = "/products" response, status = BeyondApi::Request.post(@session, path, body) handle_response(response, status) end |
#delete(product_id) ⇒ Object
A DELETE
request is used to delete a product or variation product. When a variation product is deleted, all its variations are deleted as well.
$ curl 'https://api-shop.beyondshop.cloud/api/products/c06c61af-f99a-4698-90fa-8c3199ca732f' -i -X DELETE \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
196 197 198 199 200 201 202 203 |
# File 'lib/beyond_api/resources/products.rb', line 196 def delete(product_id) path = "/products/#{product_id}" response, status = BeyondApi::Request.delete(@session, path) handle_response(response, status, respond_with_true: true) end |
#find(product_id) ⇒ OpenStruct Also known as: find_variation
A GET
request is used to retrieve the details of a product.
$ curl 'https://api-shop.beyondshop.cloud/api/products/75ebcb57-aefb-4963-8225-060c528e070d' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json' \
-H 'Authorization: Bearer <Access token>'
222 223 224 225 226 227 228 229 |
# File 'lib/beyond_api/resources/products.rb', line 222 def find(product_id) path = "/products/#{product_id}" response, status = BeyondApi::Request.get(@session, path) handle_response(response, status) end |
#update(product_id, body) ⇒ OpenStruct Also known as: update_variation
A PATCH
request is used to update a product partially with json content type.
261 262 263 264 265 266 267 268 269 |
# File 'lib/beyond_api/resources/products.rb', line 261 def update(product_id, body) path = "/products/#{product_id}" response, status = BeyondApi::Request.patch(@session, path, body) handle_response(response, status) end |