Class: BeyondApi::CategoriesView
- Includes:
- Utils
- Defined in:
- lib/beyond_api/resources/categories_view.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#all(params = {}) ⇒ OpenStruct
A
GET
request is used to list all product categories. -
#find(category_id) ⇒ OpenStruct
A
GET
request is used to retrieve the details of a product category. -
#preview(body, params = {}) ⇒ OpenStruct
A
POST
request is read-only and cannot create data. -
#products(category_id, params = {}) ⇒ OpenStruct
A
GET
request is used to list all products of a category. -
#search_by_label(label) ⇒ OpenStruct
A
GET
request is used to find a product category by its unique label. -
#search_by_product(body, params = {}) ⇒ OpenStruct
A
POST
request is used to search for categories a new product will be part of using the request body. -
#search_by_product_id(product_id, params = {}) ⇒ OpenStruct
A
GET
request is used to list all product categories a product is part of using the request parameter productId.
Methods included from Utils
#file_content_type, #handle_all_request, #handle_error, #handle_response, #sanitize_key, #sanitize_response, #to_object_struct
Methods inherited from Base
Constructor Details
This class inherits a constructor from BeyondApi::Base
Instance Method Details
#all(params = {}) ⇒ OpenStruct
A GET
request is used to list all product categories.
$ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json'
26 27 28 |
# File 'lib/beyond_api/resources/categories_view.rb', line 26 def all(params = {}) handle_all_request("/product-view/categories", :categories, params) end |
#find(category_id) ⇒ OpenStruct
A GET
request is used to retrieve the details of a product category.
$ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/23bb1430-6e82-40e4-9a92-4cb404da74a8' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json'
44 45 46 47 48 49 |
# File 'lib/beyond_api/resources/categories_view.rb', line 44 def find(category_id) response, status = BeyondApi::Request.get(@session, "/product-view/categories/#{category_id}") handle_response(response, status) end |
#preview(body, params = {}) ⇒ OpenStruct
A POST
request is read-only and cannot create data. It is used to find products that match the filter criteria. Thus, it can be used to preview all products that are included in a category that shares the respective filter criteria.
$ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/preview?page=0&size=10&sortBy=NEWEST_FIRST' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Content-Type: application/json' \
-d '{
"filters" : [ {
"key" : "manufacturer",
"values" : [ "Grape Vineyard" ]
}, {
"key" : "all_tags",
"values" : [ "Power Bar", "Bestseller", "High Protein" ]
}, {
"key" : "price_range",
"min" : 3.7,
"max" : 13.7
} ]
}'
100 101 102 103 104 105 106 107 |
# File 'lib/beyond_api/resources/categories_view.rb', line 100 def preview(body, params = {}) response, status = BeyondApi::Request.post(@session, "/product-view/categories/preview", body, params) handle_response(response, status) end |
#products(category_id, params = {}) ⇒ OpenStruct
A GET
request is used to list all products of a category.
$ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/681beef2-cd3e-4ce3-8034-4d07c1184447/products' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json'
125 126 127 128 129 |
# File 'lib/beyond_api/resources/categories_view.rb', line 125 def products(category_id, params = {}) path = "/product-view/categories/#{category_id}/products" handle_all_request(path, :products, params) end |
#search_by_label(label) ⇒ OpenStruct
A GET
request is used to find a product category by its unique label.
$ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/search/find-by-label?label=power-bar' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json'
145 146 147 148 149 150 151 |
# File 'lib/beyond_api/resources/categories_view.rb', line 145 def search_by_label(label) response, status = BeyondApi::Request.get(@session, "/product-view/categories/search/find-by-label", { label: label }) handle_response(response, status) end |
#search_by_product(body, params = {}) ⇒ OpenStruct
A POST
request is used to search for categories a new product will be part of using the request body. An existing product can also be part of the call. This endpoint can handle all properties a product can have. This request is read-only and cannot create data.
$ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/search/find-by-product' -i -X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json'
-d '{
"tags" : [ "books" ],
"manufacturer" : "The Standard Manufacturer",
"salesPrice" : {
"amount" : 10.0,
"currency" : "EUR"
}
}'
209 210 211 212 213 214 215 216 |
# File 'lib/beyond_api/resources/categories_view.rb', line 209 def search_by_product(body, params = {}) response, status = BeyondApi::Request.post(@session, "/product-view/categories/search/find-by-product", body, params) handle_response(response, status) end |
#search_by_product_id(product_id, params = {}) ⇒ OpenStruct
A GET
request is used to list all product categories a product is part of using the request parameter productId.
$ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/search/find-by-product?productId=ba68427f-603c-4741-9185-3b379f7769b5' -i -X GET \
-H 'Content-Type: application/json' \
-H 'Accept: application/hal+json'
167 168 169 170 171 172 173 |
# File 'lib/beyond_api/resources/categories_view.rb', line 167 def search_by_product_id(product_id, params = {}) response, status = BeyondApi::Request.get(@session, "/product-view/categories/search/find-by-product", params.merge(product_id: product_id)) handle_response(response, status) end |