Skip to content

Commit b1e5674

Browse files
authored
EPT-2621 Add categories preview endpoint (#57)
* Add categories preview endpoint * Update categories_view.rb * Update version.rb
1 parent 640f188 commit b1e5674

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### v0.24.0.pre
2+
3+
* features
4+
* Add category preview method
5+
* `CategoriesView#preview`
6+
17
### v0.23.0.pre
28

39
* feature
@@ -20,6 +26,7 @@
2026

2127
* features
2228
* Add `Variations#sort_images` method
29+
2330
### v0.20.0.pre
2431

2532
* features

lib/beyond_api/resources/categories_view.rb

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,64 @@ def find(category_id)
4848
handle_response(response, status)
4949
end
5050

51+
#
52+
# A +POST+ request is read-only and cannot create data. It is used to find products that match the filter criteria.
53+
# Thus, it can be used to preview all products that are included in a category that shares the respective filter criteria.
54+
#
55+
# $ curl 'https://api-shop.beyondshop.cloud/api/product-view/categories/preview?page=0&size=10&sortBy=NEWEST_FIRST' -i -X POST \
56+
# -H 'Content-Type: application/json' \
57+
# -H 'Content-Type: application/json' \
58+
# -d '{
59+
# "filters" : [ {
60+
# "key" : "manufacturer",
61+
# "values" : [ "Grape Vineyard" ]
62+
# }, {
63+
# "key" : "all_tags",
64+
# "values" : [ "Power Bar", "Bestseller", "High Protein" ]
65+
# }, {
66+
# "key" : "price_range",
67+
# "min" : 3.7,
68+
# "max" : 13.7
69+
# } ]
70+
# }'
71+
#
72+
# @param body [Hash] the request body
73+
# @option params [Integer] :size the page size
74+
# @option params [Integer] :page the page number
75+
# @option params [String] :sort_by the sorting applied to the list of products
76+
#
77+
# @return [OpenStruct]
78+
#
79+
# @example
80+
# body = {
81+
# filters => [
82+
# {
83+
# key => "manufacturer",
84+
# values => [ "Grape Vineyard" ]
85+
# },
86+
# {
87+
# key => "all_tags",
88+
# values => [ "Power Bar", "Bestseller", "High Protein" ]
89+
# },
90+
# {
91+
# key => "price_range",
92+
# min => 3.7,
93+
# max => 13.7
94+
# }
95+
# ]
96+
# }
97+
#
98+
# @products = session.categories_view.preview(body, { size: 100, page: 0, sort_by: "NEWEST_FIRST" })
99+
#
100+
def preview(body, params = {})
101+
response, status = BeyondApi::Request.post(@session,
102+
"/product-view/categories/preview",
103+
body,
104+
params)
105+
106+
handle_response(response, status)
107+
end
108+
51109
#
52110
# A +GET+ request is used to list all products of a category.
53111
#

lib/beyond_api/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module BeyondApi
4-
VERSION = "0.23.0.pre"
4+
VERSION = "0.24.0.pre"
55
end

0 commit comments

Comments
 (0)