beyond_api 0.5.1.pre → 0.6.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -3
- data/Gemfile.lock +3 -3
- data/lib/beyond_api/resources/carts.rb +18 -9
- data/lib/beyond_api/resources/categories.rb +2 -2
- data/lib/beyond_api/resources/categories_view.rb +13 -2
- data/lib/beyond_api/resources/checkout_settings.rb +16 -1
- data/lib/beyond_api/resources/customers.rb +333 -0
- data/lib/beyond_api/resources/newsletter_target.rb +1 -1
- data/lib/beyond_api/resources/order_settings.rb +45 -28
- data/lib/beyond_api/resources/orders.rb +175 -87
- data/lib/beyond_api/resources/payment_methods.rb +28 -25
- data/lib/beyond_api/resources/product_attribute_definitions.rb +3 -5
- data/lib/beyond_api/resources/products/attachments.rb +13 -14
- data/lib/beyond_api/resources/products/availability.rb +12 -10
- data/lib/beyond_api/resources/products/cross_sells.rb +159 -0
- data/lib/beyond_api/resources/products/custom_attributes.rb +7 -7
- data/lib/beyond_api/resources/products/images.rb +47 -8
- data/lib/beyond_api/resources/products/videos.rb +146 -0
- data/lib/beyond_api/resources/products.rb +11 -9
- data/lib/beyond_api/resources/products_view.rb +6 -51
- data/lib/beyond_api/resources/shipping_zones.rb +5 -5
- data/lib/beyond_api/resources/shop.rb +16 -21
- data/lib/beyond_api/resources/signers.rb +1 -1
- data/lib/beyond_api/resources/users.rb +13 -10
- data/lib/beyond_api/resources/variations/images.rb +160 -0
- data/lib/beyond_api/resources/variations.rb +40 -37
- data/lib/beyond_api/resources/webhook_subscriptions.rb +1 -1
- data/lib/beyond_api/session.rb +5 -5
- data/lib/beyond_api/version.rb +1 -1
- metadata +7 -4
- data/lib/beyond_api/resources/product_settings.rb +0 -28
@@ -13,14 +13,14 @@ module BeyondApi
|
|
13
13
|
# -H 'Accept: application/hal+json' \
|
14
14
|
# -H 'Authorization: Bearer <Access token>'
|
15
15
|
#
|
16
|
-
# @beyond_api.scopes pymt:u
|
16
|
+
# @beyond_api.scopes +pymt:u+
|
17
17
|
#
|
18
18
|
# @param payment_method_id [String] the payment method UUID
|
19
19
|
#
|
20
20
|
# @return true
|
21
21
|
#
|
22
22
|
# @example
|
23
|
-
# session.payment_methods.activate("
|
23
|
+
# session.payment_methods.activate("da313b73-ea6b-49c7-8a3d-d707934098b8")
|
24
24
|
#
|
25
25
|
def activate(payment_method_id)
|
26
26
|
response, status = BeyondApi::Request.post(@session, "/payment-methods/#{payment_method_id}/activate")
|
@@ -36,7 +36,7 @@ module BeyondApi
|
|
36
36
|
# -H 'Accept: application/hal+json' \
|
37
37
|
# -H 'Authorization: Bearer <Access token>'
|
38
38
|
#
|
39
|
-
# @beyond_api.scopes +pymt:r
|
39
|
+
# @beyond_api.scopes +pymt:r+
|
40
40
|
#
|
41
41
|
# @option params [Integer] :size the page size
|
42
42
|
# @option params [Integer] :page the page number
|
@@ -44,7 +44,7 @@ module BeyondApi
|
|
44
44
|
# @return [OpenStruct]
|
45
45
|
#
|
46
46
|
# @example
|
47
|
-
# session.payment_methods.all(size: 100, page: 0)
|
47
|
+
# @payment_methods = session.payment_methods.all(size: 100, page: 0)
|
48
48
|
#
|
49
49
|
def all(params = {})
|
50
50
|
response, status = BeyondApi::Request.get(@session, "/payment-methods", params)
|
@@ -59,14 +59,14 @@ module BeyondApi
|
|
59
59
|
# -H 'Accept: application/hal+json' \
|
60
60
|
# -H 'Authorization: Bearer <Access token>'
|
61
61
|
#
|
62
|
-
# @beyond_api.scopes pymt:u
|
62
|
+
# @beyond_api.scopes +pymt:u+
|
63
63
|
#
|
64
64
|
# @param payment_method_id [String] the payment method UUID
|
65
65
|
#
|
66
66
|
# @return true
|
67
67
|
#
|
68
68
|
# @example
|
69
|
-
# session.payment_methods.deactivate("
|
69
|
+
# session.payment_methods.deactivate("157f930f-328a-4d7a-974d-66bc3b4dd28e")
|
70
70
|
#
|
71
71
|
def deactivate(payment_method_id)
|
72
72
|
response, status = BeyondApi::Request.post(@session, "/payment-methods/#{payment_method_id}/deactivate")
|
@@ -75,16 +75,21 @@ module BeyondApi
|
|
75
75
|
end
|
76
76
|
|
77
77
|
#
|
78
|
-
# A +GET+ request is used to
|
78
|
+
# A +GET+ request is used to retrieve the details of a payment method.
|
79
79
|
#
|
80
|
-
#
|
80
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/payment-methods/7d964402-8f67-48f3-af86-6c35abe4fa08' -i -X GET \
|
81
|
+
# -H 'Content-Type: application/json' \
|
82
|
+
# -H 'Accept: application/hal+json' \
|
83
|
+
# -H 'Authorization: Bearer <Access token>'
|
81
84
|
#
|
82
|
-
# @
|
85
|
+
# @beyond_api.scopes +pymt:r+
|
86
|
+
#
|
87
|
+
# @param payment_method_id [String] the payment method UUID
|
83
88
|
#
|
84
89
|
# @return [OpenStruct]
|
85
90
|
#
|
86
91
|
# @example
|
87
|
-
# session.payment_methods.find("
|
92
|
+
# @payment_method = session.payment_methods.find("7d964402-8f67-48f3-af86-6c35abe4fa08")
|
88
93
|
#
|
89
94
|
def find(payment_method_id)
|
90
95
|
response, status = BeyondApi::Request.get(@session, "/payment-methods/#{payment_method_id}")
|
@@ -98,12 +103,12 @@ module BeyondApi
|
|
98
103
|
# $ curl 'https://api-shop.beyondshop.cloud/api/payment-methods' -i -X PUT \
|
99
104
|
# -H 'Content-Type: text/uri-list' \
|
100
105
|
# -H 'Authorization: Bearer <Access token>' \
|
101
|
-
# -d 'https://api-shop.beyondshop.cloud/api/payment-methods/
|
102
|
-
# https://api-shop.beyondshop.cloud/api/payment-methods/
|
103
|
-
# https://api-shop.beyondshop.cloud/api/payment-methods/
|
104
|
-
# https://api-shop.beyondshop.cloud/api/payment-methods/
|
106
|
+
# -d 'https://api-shop.beyondshop.cloud/api/payment-methods/dd59a52b-0661-49f9-82c3-e063ff80328f
|
107
|
+
# https://api-shop.beyondshop.cloud/api/payment-methods/66b22fb2-2184-4ea1-9143-44ae1d230d49
|
108
|
+
# https://api-shop.beyondshop.cloud/api/payment-methods/a9462eae-ed72-4e29-b853-f04537c8ab11
|
109
|
+
# https://api-shop.beyondshop.cloud/api/payment-methods/84172da4-5baa-4a99-b779-33d673bed6d1'
|
105
110
|
#
|
106
|
-
# @beyond_api.scopes +pymt:u
|
111
|
+
# @beyond_api.scopes +pymt:u+
|
107
112
|
#
|
108
113
|
# @param payment_method_ids [Array] the payment method UUIDs
|
109
114
|
#
|
@@ -111,18 +116,16 @@ module BeyondApi
|
|
111
116
|
#
|
112
117
|
# @example
|
113
118
|
# payment_method_ids = [
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
119
|
+
# "dd59a52b-0661-49f9-82c3-e063ff80328f",
|
120
|
+
# "66b22fb2-2184-4ea1-9143-44ae1d230d49",
|
121
|
+
# "a9462eae-ed72-4e29-b853-f04537c8ab11",
|
122
|
+
# "84172da4-5baa-4a99-b779-33d673bed6d1"
|
117
123
|
# ]
|
118
124
|
#
|
119
|
-
# session.payment_methods.sort(
|
125
|
+
# session.payment_methods.sort(payment_method_ids)
|
120
126
|
#
|
121
127
|
def sort(payment_method_ids)
|
122
|
-
body =
|
123
|
-
payment_method_ids.each do |payment_method|
|
124
|
-
body << "#{@session.api_url}/payment-methods/#{payment_method}"
|
125
|
-
end
|
128
|
+
body = payment_method_ids.map { |id| "#{@session.api_url}/payment-methods/#{id}" }
|
126
129
|
response, status = BeyondApi::Request.put(@session, "/payment-methods", body)
|
127
130
|
|
128
131
|
handle_response(response, status, respond_with_true: true)
|
@@ -154,7 +157,7 @@ module BeyondApi
|
|
154
157
|
# }
|
155
158
|
# }'
|
156
159
|
#
|
157
|
-
# @beyond_api.scopes +pymt:u
|
160
|
+
# @beyond_api.scopes +pymt:u+
|
158
161
|
#
|
159
162
|
# @param payment_method_id [String] the payment method UUID
|
160
163
|
# @param body [Hash] the request body
|
@@ -181,7 +184,7 @@ module BeyondApi
|
|
181
184
|
# }
|
182
185
|
# }
|
183
186
|
#
|
184
|
-
# @payment_method = session.payment_methods.update("
|
187
|
+
# @payment_method = session.payment_methods.update("dc00a5af-d21e-49f0-99f2-ef67ca6fa782", body)
|
185
188
|
#
|
186
189
|
def update(payment_method_id, body)
|
187
190
|
response, status = BeyondApi::Request.put(@session, "/payment-methods/#{payment_method_id}", body)
|
@@ -73,11 +73,9 @@ module BeyondApi
|
|
73
73
|
end
|
74
74
|
|
75
75
|
#
|
76
|
-
# A +DELETE+ request is used to delete a product
|
76
|
+
# A +DELETE+ request is used to delete a product attribute definition.
|
77
77
|
#
|
78
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/
|
79
|
-
# -H 'Content-Type: application/hal+json' \
|
80
|
-
# -H 'Accept: application/hal+json' \
|
78
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/product-attribute-definitions/color' -i -X DELETE \
|
81
79
|
# -H 'Authorization: Bearer <Access token>'
|
82
80
|
#
|
83
81
|
# @beyond_api.scopes +prad:d+
|
@@ -87,7 +85,7 @@ module BeyondApi
|
|
87
85
|
# @return [true]
|
88
86
|
#
|
89
87
|
# @example
|
90
|
-
# session.product_attribute_definitions.delete("
|
88
|
+
# session.product_attribute_definitions.delete("color")
|
91
89
|
#
|
92
90
|
def delete(product_attribute_name)
|
93
91
|
response, status = BeyondApi::Request.delete(@session, "/product-attribute-definitions/#{product_attribute_name}")
|
@@ -6,35 +6,34 @@ module BeyondApi
|
|
6
6
|
module ProductAttachments
|
7
7
|
|
8
8
|
#
|
9
|
-
# A +POST+ request is used to
|
9
|
+
# A +POST+ request is used to create an attachment and add it to a product.
|
10
10
|
#
|
11
11
|
# $ curl 'https://api-shop.beyondshop.cloud/api/products/ecb997ce-79c3-4367-9373-058089a313e3/attachments' -i -X POST \
|
12
12
|
# -H 'Content-Type: application/hal+json' \
|
13
13
|
# -H 'Accept: application/hal+json' \
|
14
14
|
# -H 'Authorization: Bearer <Access token>' \
|
15
15
|
# -d '{
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
16
|
+
# "mimeType" : "application/pdf",
|
17
|
+
# "length" : 1,
|
18
|
+
# "label" : "Handbuch",
|
19
|
+
# "dataUri" : "my_document_1.pdf?hash=8a627f655c68f56dfbbf217ab7d5563281225666"
|
20
20
|
# }'
|
21
21
|
#
|
22
22
|
# @beyond_api.scopes +prod:u+
|
23
23
|
#
|
24
24
|
# @param product_id [String] the product UUID
|
25
|
-
# @
|
26
|
-
# @option params [Integer] :page the page number
|
25
|
+
# @param body [Hash] the request body
|
27
26
|
#
|
28
27
|
# @return [OpenStruct]
|
29
28
|
#
|
30
29
|
# @example
|
31
30
|
# body = {
|
32
|
-
# "
|
31
|
+
# "mime_type" => "application/pdf",
|
33
32
|
# "length" => 1,
|
34
33
|
# "label" => "Handbuch",
|
35
|
-
# "
|
34
|
+
# "data_uri" => "my_document_1.pdf?hash=8a627f655c68f56dfbbf217ab7d5563281225666"
|
36
35
|
# }
|
37
|
-
# @attachment = session.products.add_attachment("
|
36
|
+
# @attachment = session.products.add_attachment("ecb997ce-79c3-4367-9373-058089a313e3", body)
|
38
37
|
#
|
39
38
|
def add_attachment(product_id, body)
|
40
39
|
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/attachments", body)
|
@@ -58,7 +57,7 @@ module BeyondApi
|
|
58
57
|
# @return [OpenStruct]
|
59
58
|
#
|
60
59
|
# @example
|
61
|
-
# @attachment = session.products.attachment("
|
60
|
+
# @attachment = session.products.attachment("eb11b53a-5017-4ae7-9ba1-c02c12c80b61", "36933722-f13f-4ee2-858c-0835ae0a884e")
|
62
61
|
#
|
63
62
|
def attachment(product_id, attachment_id)
|
64
63
|
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/attachments/#{attachment_id}")
|
@@ -83,9 +82,9 @@ module BeyondApi
|
|
83
82
|
# @return [OpenStruct]
|
84
83
|
#
|
85
84
|
# @example
|
86
|
-
# @attachments = session.products.attachments("fd60a63e-c4c0-496d-af49-c4ed224cca2a", size: 100, page: 0)
|
85
|
+
# @attachments = session.products.attachments("fd60a63e-c4c0-496d-af49-c4ed224cca2a", {size: 100, page: 0})
|
87
86
|
#
|
88
|
-
def attachments(product_id, params)
|
87
|
+
def attachments(product_id, params = {})
|
89
88
|
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/attachments", params)
|
90
89
|
|
91
90
|
handle_response(response, status)
|
@@ -107,7 +106,7 @@ module BeyondApi
|
|
107
106
|
# @return [true]
|
108
107
|
#
|
109
108
|
# @example
|
110
|
-
# session.products.delete_attachment("
|
109
|
+
# session.products.delete_attachment("00add006-beaa-46fe-bb73-f8ebae15082d", "9a44e585-571a-4253-9248-54a4c418c7e2")
|
111
110
|
#
|
112
111
|
def delete_attachment(product_id, attachment_id)
|
113
112
|
response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}/attachments/#{attachment_id}")
|
@@ -17,14 +17,15 @@ module BeyondApi
|
|
17
17
|
# @beyond_api.scopes +prda:u+
|
18
18
|
#
|
19
19
|
# @param product_id [String] the product UUID
|
20
|
+
# @param relative_amount [Integer] the relative amount
|
20
21
|
#
|
21
22
|
# @return [OpenStruct]
|
22
23
|
#
|
23
24
|
# @example
|
24
|
-
# @availability = session.products.adjust_stock_level(
|
25
|
+
# @availability = session.products.adjust_stock_level("685f483e-cdda-40af-8091-d5bc31249409", { relativeAmount => -1 })
|
25
26
|
#
|
26
|
-
def adjust_stock_level(product_id,
|
27
|
-
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/
|
27
|
+
def adjust_stock_level(product_id, relative_amount)
|
28
|
+
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/adjust-available-stock", { relative_amount: relative_amount })
|
28
29
|
|
29
30
|
handle_response(response, status)
|
30
31
|
end
|
@@ -67,7 +68,7 @@ module BeyondApi
|
|
67
68
|
# @return true
|
68
69
|
#
|
69
70
|
# @example
|
70
|
-
# session.products.disable_purchasability("
|
71
|
+
# session.products.disable_purchasability("6b30255e-650f-475c-b345-e7247f957689")
|
71
72
|
#
|
72
73
|
def disable_purchasability(product_id)
|
73
74
|
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/disable-purchasability")
|
@@ -90,7 +91,7 @@ module BeyondApi
|
|
90
91
|
# @return true
|
91
92
|
#
|
92
93
|
# @example
|
93
|
-
# session.products.disable_stock_management("e966cb17-4047-4b82-ade4-33e7f0978c89"
|
94
|
+
# session.products.disable_stock_management("e966cb17-4047-4b82-ade4-33e7f0978c89")
|
94
95
|
#
|
95
96
|
def disable_stock_management(product_id)
|
96
97
|
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/disable-stock-management")
|
@@ -139,8 +140,8 @@ module BeyondApi
|
|
139
140
|
#
|
140
141
|
# @example
|
141
142
|
# body = {
|
142
|
-
# "
|
143
|
-
# "
|
143
|
+
# "initial_available_stock" => 100,
|
144
|
+
# "stock_threshold" => 2
|
144
145
|
# }
|
145
146
|
# @availability = session.products.enable_stock_management("101fa968-9bb8-4dbe-b166-3add1fc1b35e", body)
|
146
147
|
#
|
@@ -162,14 +163,15 @@ module BeyondApi
|
|
162
163
|
# @beyond_api.scopes +prda:u+
|
163
164
|
#
|
164
165
|
# @param product_id [String] the product UUID
|
166
|
+
# @param stock_threshold [Integer] the stock threshold
|
165
167
|
#
|
166
168
|
# @return [OpenStruct]
|
167
169
|
#
|
168
170
|
# @example
|
169
|
-
# session.products.update_reserve_stock("f74b5f57-43cc-4176-97aa-c6eb9fdeb37c", {
|
171
|
+
# session.products.update_reserve_stock("f74b5f57-43cc-4176-97aa-c6eb9fdeb37c", { stock_threshold => 5 })
|
170
172
|
#
|
171
|
-
def update_reserve_stock(product_id,
|
172
|
-
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/update-stock-threshold",
|
173
|
+
def update_reserve_stock(product_id, stock_threshold)
|
174
|
+
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/update-stock-threshold", { stock_threshold: stock_threshold })
|
173
175
|
|
174
176
|
handle_response(response, status)
|
175
177
|
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
5
|
+
module BeyondApi
|
6
|
+
module ProductCrossSells
|
7
|
+
|
8
|
+
#
|
9
|
+
# A +POST+ request is used to create a cross-sell for a product.
|
10
|
+
#
|
11
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/43df85ec-e123-4a56-bcc3-c3c52eb23ca9/cross-sells' -i -X POST \
|
12
|
+
# -H 'Content-Type: application/json' \
|
13
|
+
# -H 'Authorization: Bearer <Access token>' \
|
14
|
+
# -d '{
|
15
|
+
# "name" : "Red wines from Spain cross-sell",
|
16
|
+
# "type" : "MANUAL",
|
17
|
+
# "queries" : [ {
|
18
|
+
# "ids" : [ "22e8b6a6-7d8e-4b08-be63-dde9bced2604", "b18e9e3c-685c-4e37-837c-9047b88fc91e" ],
|
19
|
+
# "strategy" : "all-ids-match"
|
20
|
+
# } ]
|
21
|
+
# }'
|
22
|
+
#
|
23
|
+
# @beyond_api.scopes +prcs:c+
|
24
|
+
#
|
25
|
+
# @param product_id [String] the product UUID
|
26
|
+
# @param body [Hash] the request body
|
27
|
+
#
|
28
|
+
# @return [OpenStruct]
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# body = {
|
32
|
+
# name => "Red wines from Spain cross-sell",
|
33
|
+
# type => "MANUAL",
|
34
|
+
# queries => [ {
|
35
|
+
# "ids" : [ "22e8b6a6-7d8e-4b08-be63-dde9bced2604", "b18e9e3c-685c-4e37-837c-9047b88fc91e" ],
|
36
|
+
# "strategy" : "all-ids-match"
|
37
|
+
# } ]
|
38
|
+
# }
|
39
|
+
#
|
40
|
+
# @cross_sell = session.products.create_cross_sell("43df85ec-e123-4a56-bcc3-c3c52eb23ca9", body)
|
41
|
+
#
|
42
|
+
def create_cross_sell(product_id, body)
|
43
|
+
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/cross-sells", body)
|
44
|
+
|
45
|
+
handle_response(response, status)
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# A +GET+ request is used to retrieve the cross-sell of a product.
|
50
|
+
#
|
51
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/20174c3f-1a3f-4401-91f6-c7498e897c82/cross-sells/6176b350-06ff-4c52-b3cf-ba032ea79468' -i -X GET \
|
52
|
+
# -H 'Content-Type: application/json' \
|
53
|
+
# -H 'Authorization: Bearer <Access token>'
|
54
|
+
#
|
55
|
+
# @beyond_api.scopes +prcs:r+
|
56
|
+
#
|
57
|
+
# @param product_id [String] the product UUID
|
58
|
+
# @param cross_sell_id [String] the cross-sell UUID
|
59
|
+
#
|
60
|
+
# @return [OpenStruct]
|
61
|
+
#
|
62
|
+
# @example
|
63
|
+
#
|
64
|
+
# @cross_sell = session.products.cross_sell("20174c3f-1a3f-4401-91f6-c7498e897c82", "6176b350-06ff-4c52-b3cf-ba032ea79468")
|
65
|
+
#
|
66
|
+
def cross_sell(product_id, cross_sell_id)
|
67
|
+
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/cross-sells/#{cross_sell_id}")
|
68
|
+
|
69
|
+
handle_response(response, status)
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# A +GET+ request is used to retrieve the cross-sells of a product.
|
74
|
+
#
|
75
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/a21188a2-7109-4cd1-8253-2f366d86ff5d/cross-sells' -i -X GET \
|
76
|
+
# -H 'Content-Type: application/json' \
|
77
|
+
# -H 'Authorization: Bearer <Access token>'
|
78
|
+
#
|
79
|
+
# @beyond_api.scopes +prcs:r+
|
80
|
+
#
|
81
|
+
# @param product_id [String] the product UUID
|
82
|
+
#
|
83
|
+
# @return [OpenStruct]
|
84
|
+
#
|
85
|
+
# @example
|
86
|
+
#
|
87
|
+
# @cross_sells = session.products.cross_sells("a21188a2-7109-4cd1-8253-2f366d86ff5d")
|
88
|
+
#
|
89
|
+
def cross_sells(product_id)
|
90
|
+
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/cross-sells")
|
91
|
+
|
92
|
+
handle_response(response, status)
|
93
|
+
end
|
94
|
+
|
95
|
+
#
|
96
|
+
# A +DELETE+ request is used to delete a product attribute.
|
97
|
+
#
|
98
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/b80cdb11-0e97-41e3-8559-4d426bd28ba1/cross-sells/67ecb3ef-8472-4509-9e5a-c76945e8d963' -i -X DELETE \
|
99
|
+
# -H 'Authorization: Bearer <Access token>'
|
100
|
+
#
|
101
|
+
# @beyond_api.scopes +prcs:d+
|
102
|
+
#
|
103
|
+
# @param product_id [String] the product UUID
|
104
|
+
# @param cross_sell_id [String] the cross-sell UUID
|
105
|
+
#
|
106
|
+
# @return [OpenStruct]
|
107
|
+
#
|
108
|
+
# @example
|
109
|
+
#
|
110
|
+
# session.products.cross_sell("b80cdb11-0e97-41e3-8559-4d426bd28ba1", "67ecb3ef-8472-4509-9e5a-c76945e8d963")
|
111
|
+
#
|
112
|
+
def delete_cross_sell(product_id, cross_sell_id)
|
113
|
+
response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}/cross-sells/#{cross_sell_id}")
|
114
|
+
|
115
|
+
handle_response(response, status, respond_with_true: true)
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# A +PUT+ request is used to update a cross-sell for a product.
|
120
|
+
#
|
121
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/4ed7a15a-9ef8-415f-8161-87498b1ecd4f/cross-sells/b18d96f4-dfdf-47f3-b2dc-ce1653829674' -i -X PUT \
|
122
|
+
# -H 'Content-Type: application/json' \
|
123
|
+
# -H 'Authorization: Bearer <Access token>' \
|
124
|
+
# -d '{
|
125
|
+
# "name" : "sale rose wine cross-selling",
|
126
|
+
# "type" : "SMART",
|
127
|
+
# "queries" : [ {
|
128
|
+
# "tags" : [ "Rosé Wine", "Sale" ],
|
129
|
+
# "strategy" : "any-tags-match"
|
130
|
+
# } ]
|
131
|
+
# }'
|
132
|
+
#
|
133
|
+
# @beyond_api.scopes +prcs:u+
|
134
|
+
#
|
135
|
+
# @param product_id [String] the product UUID
|
136
|
+
# @param cross_sell_id [String] the cross-sell UUID
|
137
|
+
# @param body [Hash] the request body
|
138
|
+
#
|
139
|
+
# @return [OpenStruct]
|
140
|
+
#
|
141
|
+
# @example
|
142
|
+
# body = {
|
143
|
+
# name => "sale rose wine cross-selling",
|
144
|
+
# type => "SMART",
|
145
|
+
# queries => [ {
|
146
|
+
# tags => [ "Rosé Wine", "Sale" ],
|
147
|
+
# strategy => "any-tags-match"
|
148
|
+
# } ]
|
149
|
+
# }
|
150
|
+
#
|
151
|
+
# @cross_sell = session.products.update_cross_sell("4ed7a15a-9ef8-415f-8161-87498b1ecd4f", "b18d96f4-dfdf-47f3-b2dc-ce1653829674", body)
|
152
|
+
#
|
153
|
+
def update_cross_sell(product_id, attribute_name, body)
|
154
|
+
response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/cross-sells/#{cross_sell_id}", body)
|
155
|
+
|
156
|
+
handle_response(response, status)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -12,8 +12,8 @@ module BeyondApi
|
|
12
12
|
# -H 'Content-Type: application/json' \
|
13
13
|
# -H 'Authorization: Bearer <Access token>' \
|
14
14
|
# -d '{
|
15
|
-
#
|
16
|
-
#
|
15
|
+
# "key" : "colour",
|
16
|
+
# "value" : "Yellow"
|
17
17
|
# }'
|
18
18
|
#
|
19
19
|
# @beyond_api.scopes +prat:c+
|
@@ -29,7 +29,7 @@ module BeyondApi
|
|
29
29
|
# "value" => "Yellow"
|
30
30
|
# }
|
31
31
|
#
|
32
|
-
# @custom_attribute = session.products.
|
32
|
+
# @custom_attribute = session.products.create_custom_attribute("0c0e1699-d2a4-44d0-bed9-64b2fa1a7713", body)
|
33
33
|
#
|
34
34
|
def create_custom_attribute(product_id, body)
|
35
35
|
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/attributes", body)
|
@@ -53,7 +53,7 @@ module BeyondApi
|
|
53
53
|
#
|
54
54
|
# @example
|
55
55
|
#
|
56
|
-
# @custom_attribute = session.products.custom_attribute("
|
56
|
+
# @custom_attribute = session.products.custom_attribute("d389347c-568e-4785-8216-91e4f8850c66", "key")
|
57
57
|
#
|
58
58
|
def custom_attribute(product_id, attribute_name)
|
59
59
|
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/attributes/#{attribute_name}")
|
@@ -76,7 +76,7 @@ module BeyondApi
|
|
76
76
|
#
|
77
77
|
# @example
|
78
78
|
#
|
79
|
-
# @custom_attributes = session.products.custom_attributes("
|
79
|
+
# @custom_attributes = session.products.custom_attributes("57f0ef04-9dac-462f-9dd4-606f7551cc7b")
|
80
80
|
#
|
81
81
|
def custom_attributes(product_id)
|
82
82
|
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/attributes")
|
@@ -99,7 +99,7 @@ module BeyondApi
|
|
99
99
|
#
|
100
100
|
# @example
|
101
101
|
#
|
102
|
-
# session.products.
|
102
|
+
# session.products.delete_custom_attribute("fec3b6f3-83d0-467a-abc5-d51019e57b51", "farbe")
|
103
103
|
#
|
104
104
|
def delete_custom_attribute(product_id, attribute_name)
|
105
105
|
response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}/attributes/#{attribute_name}")
|
@@ -130,7 +130,7 @@ module BeyondApi
|
|
130
130
|
# "value" : "green"
|
131
131
|
# }
|
132
132
|
#
|
133
|
-
# @custom_attribute = session.products.update_custom_attribute("
|
133
|
+
# @custom_attribute = session.products.update_custom_attribute("82ed44e9-664d-47c0-8b07-09adecfdbf20", "key", body)
|
134
134
|
#
|
135
135
|
def update_custom_attribute(product_id, attribute_name, body)
|
136
136
|
response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/attributes/#{attribute_name}", body)
|
@@ -5,7 +5,7 @@ require "beyond_api/utils"
|
|
5
5
|
module BeyondApi
|
6
6
|
module ProductImages
|
7
7
|
|
8
|
-
|
8
|
+
#
|
9
9
|
# A +POST+ request is used to create an image and add it to a product.
|
10
10
|
#
|
11
11
|
# $ curl 'https://api-shop.beyondshop.cloud/api/products/7a7d1f18-f760-46a9-b794-dbe5a88c6b44/images' -i -X POST \
|
@@ -13,8 +13,10 @@ module BeyondApi
|
|
13
13
|
# -H 'Accept: application/hal+json' \
|
14
14
|
# -H 'Authorization: Bearer <Access token>' \
|
15
15
|
# -d '{
|
16
|
-
#
|
17
|
-
#
|
16
|
+
# "dataUri" : "photostore-2.JPG?hash=8a627f655c68f56dfbbf217ab7d5563281225998",
|
17
|
+
# "width" : 600,
|
18
|
+
# "height" : 300
|
19
|
+
# }'
|
18
20
|
#
|
19
21
|
# @beyond_api.scopes +prod:u+
|
20
22
|
#
|
@@ -24,10 +26,15 @@ module BeyondApi
|
|
24
26
|
# @return [OpenStruct]
|
25
27
|
#
|
26
28
|
# @example
|
27
|
-
#
|
29
|
+
# body = {
|
30
|
+
# "data_uri" => "photostore-2.JPG?hash=8a627f655c68f56dfbbf217ab7d5563281225998",
|
31
|
+
# "width" => 600,
|
32
|
+
# "height" => 300
|
33
|
+
# }
|
34
|
+
# @image = session.products.add_image("7a7d1f18-f760-46a9-b794-dbe5a88c6b44", body)
|
28
35
|
#
|
29
|
-
def add_image(product_id,
|
30
|
-
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/images",
|
36
|
+
def add_image(product_id, body)
|
37
|
+
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/images", body)
|
31
38
|
|
32
39
|
handle_response(response, status)
|
33
40
|
end
|
@@ -73,7 +80,7 @@ module BeyondApi
|
|
73
80
|
# @return [OpenStruct]
|
74
81
|
#
|
75
82
|
# @example
|
76
|
-
# @
|
83
|
+
# @images = session.products.images("7f32696a-df56-4380-a91b-fffb97f025b4", { size: 20, page: 0 })
|
77
84
|
#
|
78
85
|
def images(product_id, params = {})
|
79
86
|
response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/images", params)
|
@@ -124,7 +131,39 @@ module BeyondApi
|
|
124
131
|
#
|
125
132
|
def set_image_as_default(product_id, image_id)
|
126
133
|
response, status = BeyondApi::Request.put(@session, "/products/#{product_id}",
|
127
|
-
"#{@session.api_url}/
|
134
|
+
"#{@session.api_url}/images/#{image_id}")
|
135
|
+
|
136
|
+
handle_response(response, status, respond_with_true: true)
|
137
|
+
end
|
138
|
+
|
139
|
+
# A +PUT+ request is used to sort the product images. This is done by passing the self-links of the images to the desired product. The request must contain URIs for all images of the given page.
|
140
|
+
#
|
141
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/3f4b2b56-c22d-4d80-b4ed-d5b33ed161eb/images' -i -X PUT \
|
142
|
+
# -H 'Content-Type: text/uri-list' \
|
143
|
+
# -H 'Accept: application/hal+json' \
|
144
|
+
# -H 'Authorization: Bearer <Access token>' \
|
145
|
+
# -d 'http://localhost/products/3f4b2b56-c22d-4d80-b4ed-d5b33ed161eb/images/c9082802-a0d0-416e-9039-02fa465a027e
|
146
|
+
# http://localhost/products/3f4b2b56-c22d-4d80-b4ed-d5b33ed161eb/images/78e9993d-8db3-45d8-8f76-6b8f2aea9c45
|
147
|
+
# http://localhost/products/3f4b2b56-c22d-4d80-b4ed-d5b33ed161eb/images/9233ee97-5dbb-4c00-a7b2-e1512c69a938'
|
148
|
+
#
|
149
|
+
# @beyond_api.scopes +prod:u+
|
150
|
+
#
|
151
|
+
# @param product_id [String] the product UUID
|
152
|
+
# @param images [Array] the image UUIDS
|
153
|
+
#
|
154
|
+
# @return true
|
155
|
+
#
|
156
|
+
# @example
|
157
|
+
# body = [
|
158
|
+
# "c9082802-a0d0-416e-9039-02fa465a027e",
|
159
|
+
# "78e9993d-8db3-45d8-8f76-6b8f2aea9c45",
|
160
|
+
# "9233ee97-5dbb-4c00-a7b2-e1512c69a938"
|
161
|
+
# ]
|
162
|
+
# session.products.sort_images("3f4b2b56-c22d-4d80-b4ed-d5b33ed161eb", body)
|
163
|
+
#
|
164
|
+
def sort_images(product_id, image_ids)
|
165
|
+
body = image_ids.map { |image_id| "#{@session.api_url}/products/#{product_id}/images/#{image_id}" }
|
166
|
+
response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/images", body)
|
128
167
|
|
129
168
|
handle_response(response, status, respond_with_true: true)
|
130
169
|
end
|