beyond_api 0.18.0.pre → 0.21.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.template +3 -0
- data/.rubocop.yml +35 -0
- data/CHANGELOG.md +34 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +68 -8
- data/Rakefile +4 -2
- data/beyond_api.gemspec +13 -9
- data/bin/console +2 -1
- data/lib/beyond_api/connection.rb +17 -6
- data/lib/beyond_api/error.rb +6 -6
- data/lib/beyond_api/ext.rb +16 -16
- data/lib/beyond_api/request.rb +25 -6
- data/lib/beyond_api/resources/carts.rb +52 -23
- data/lib/beyond_api/resources/categories_view.rb +16 -6
- data/lib/beyond_api/resources/newsletter_target.rb +10 -4
- data/lib/beyond_api/resources/orders.rb +152 -33
- data/lib/beyond_api/resources/payment_method_definitions.rb +11 -4
- data/lib/beyond_api/resources/product_attribute_definitions.rb +16 -4
- data/lib/beyond_api/resources/products/attachments.rb +0 -2
- data/lib/beyond_api/resources/products/availability.rb +20 -11
- data/lib/beyond_api/resources/products/cross_sells.rb +0 -1
- data/lib/beyond_api/resources/products/custom_attributes.rb +0 -1
- data/lib/beyond_api/resources/products/images.rb +36 -11
- data/lib/beyond_api/resources/products/searches.rb +62 -1
- data/lib/beyond_api/resources/products/variation_properties.rb +0 -1
- data/lib/beyond_api/resources/products/videos.rb +4 -3
- data/lib/beyond_api/resources/products.rb +28 -9
- data/lib/beyond_api/resources/products_view.rb +21 -5
- data/lib/beyond_api/resources/script_tags.rb +21 -5
- data/lib/beyond_api/resources/shipping_zones.rb +53 -12
- data/lib/beyond_api/resources/shop.rb +9 -2
- data/lib/beyond_api/resources/shops/address.rb +0 -1
- data/lib/beyond_api/resources/shops/attributes.rb +0 -1
- data/lib/beyond_api/resources/shops/images.rb +12 -9
- data/lib/beyond_api/resources/shops/legals.rb +14 -7
- data/lib/beyond_api/resources/shops/locations.rb +0 -1
- data/lib/beyond_api/resources/signers.rb +12 -3
- data/lib/beyond_api/resources/token.rb +6 -5
- data/lib/beyond_api/resources/users.rb +73 -15
- data/lib/beyond_api/resources/variations/availability.rb +17 -5
- data/lib/beyond_api/resources/variations/images.rb +92 -18
- data/lib/beyond_api/resources/variations.rb +14 -3
- data/lib/beyond_api/resources/webhook_subscriptions.rb +30 -8
- data/lib/beyond_api/session.rb +7 -1
- data/lib/beyond_api/utils.rb +55 -42
- data/lib/beyond_api/version.rb +3 -1
- data/lib/beyond_api.rb +3 -1
- data/lib/generators/beyond_api/install_generator.rb +1 -1
- metadata +61 -17
@@ -4,7 +4,6 @@ require "beyond_api/utils"
|
|
4
4
|
|
5
5
|
module BeyondApi
|
6
6
|
module ProductImages
|
7
|
-
|
8
7
|
#
|
9
8
|
# A +POST+ request is used to create an image and add it to a product.
|
10
9
|
#
|
@@ -163,7 +162,7 @@ module BeyondApi
|
|
163
162
|
#
|
164
163
|
def sort_images(product_id, image_ids)
|
165
164
|
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)
|
165
|
+
response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/images", body.join("\n"), {}, 'text/uri-list')
|
167
166
|
|
168
167
|
handle_response(response, status, respond_with_true: true)
|
169
168
|
end
|
@@ -186,19 +185,45 @@ module BeyondApi
|
|
186
185
|
# session.products.upload_image("4125b993-49fc-47c8-b9b3-76d8871e4e06", "/home/epages/file.png", "file.png")
|
187
186
|
#
|
188
187
|
def upload_image(product_id, image_path, image_name)
|
189
|
-
content_type =
|
190
|
-
when ".png"
|
191
|
-
"image/png"
|
192
|
-
when ".jpg", ".jpeg"
|
193
|
-
"image/jpeg"
|
194
|
-
when ".gif"
|
195
|
-
"image/gif"
|
196
|
-
end
|
188
|
+
content_type = file_content_type(image_path)
|
197
189
|
image_binary = File.binread(image_path)
|
198
190
|
|
199
|
-
response, status = BeyondApi::Request.upload(@session,
|
191
|
+
response, status = BeyondApi::Request.upload(@session,
|
192
|
+
"/products/#{product_id}/images",
|
193
|
+
image_binary,
|
194
|
+
content_type,
|
195
|
+
{ file_name: image_name })
|
200
196
|
|
201
197
|
handle_response(response, status, respond_with_true: true)
|
202
198
|
end
|
199
|
+
|
200
|
+
# A +POST+ request is used to upload up to 10 images and add them to a product. The body of the request must contain the content of the images.
|
201
|
+
#
|
202
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/4125b993-49fc-47c8-b9b3-76d8871e4e06/images?fileName=file.png&fileName=file2.png' -i -X POST \
|
203
|
+
# -H 'Content-Type: multipart/form-data' \
|
204
|
+
# -H 'Authorization: Bearer <Access token>' \
|
205
|
+
# -F 'image=@/home/epages/file.png' \
|
206
|
+
# -F 'image=@/home/epages/file2.png'
|
207
|
+
#
|
208
|
+
# @beyond_api.scopes +prod:u+
|
209
|
+
#
|
210
|
+
# @param product_id [String] the product UUID
|
211
|
+
# @param images_path [Array] the images path
|
212
|
+
# @param images_name [Array] the images name
|
213
|
+
#
|
214
|
+
# @return true
|
215
|
+
#
|
216
|
+
# @example
|
217
|
+
# session.products.upload_multiple_images("4125b993-49fc-47c8-b9b3-76d8871e4e06",
|
218
|
+
# ["/home/epages/file.png", "/home/epages/file2.png"], ["file.png", "file2.png"])
|
219
|
+
#
|
220
|
+
def upload_multiple_images(product_id, images_path, images_name)
|
221
|
+
response, status = BeyondApi::Request.upload_by_form(@session,
|
222
|
+
"/products/#{product_id}/images",
|
223
|
+
images_path,
|
224
|
+
file_name: images_name)
|
225
|
+
|
226
|
+
handle_response(response, status)
|
227
|
+
end
|
203
228
|
end
|
204
229
|
end
|
@@ -4,6 +4,66 @@ require "beyond_api/utils"
|
|
4
4
|
|
5
5
|
module BeyondApi
|
6
6
|
module ProductSearches
|
7
|
+
#
|
8
|
+
# A +POST+ request is used to search for products by a search term. Optionally, you can also filter the search results.
|
9
|
+
#
|
10
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/search' -i -X POST \
|
11
|
+
# -H 'Content-Type: application/hal+json;charset=UTF-8' \
|
12
|
+
# -H 'Accept: application/hal+json' \
|
13
|
+
# -H 'Authorization: Bearer <Access token>'
|
14
|
+
# -d '{
|
15
|
+
# "search" : {
|
16
|
+
# "term" : "Tony Highfinger, Poloshirt, Men",
|
17
|
+
# "category" : "NAME"
|
18
|
+
# },
|
19
|
+
# "filters" : [ {
|
20
|
+
# "key" : "status",
|
21
|
+
# "values" : [ "PUBLISHED" ]
|
22
|
+
# } ],
|
23
|
+
# "paging" : {
|
24
|
+
# "page" : 0,
|
25
|
+
# "pageSize" : 20,
|
26
|
+
# "sort" : {
|
27
|
+
# "property" : "name",
|
28
|
+
# "direction" : "ASC"
|
29
|
+
# }
|
30
|
+
# }
|
31
|
+
# }'
|
32
|
+
#
|
33
|
+
# @beyond_api.scopes +prod:r+
|
34
|
+
#
|
35
|
+
# @param body [String] the request body
|
36
|
+
#
|
37
|
+
# @return [OpenStruct]
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# body = {
|
41
|
+
# search: {
|
42
|
+
# term: "Tony Highfinger, Poloshirt, Men",
|
43
|
+
# category: "NAME"
|
44
|
+
# },
|
45
|
+
# filters: [ {
|
46
|
+
# key: "status",
|
47
|
+
# values: [ "PUBLISHED" ]
|
48
|
+
# } ],
|
49
|
+
# paging: {
|
50
|
+
# page: 0,
|
51
|
+
# page_size: 20,
|
52
|
+
# sort: {
|
53
|
+
# property: "name",
|
54
|
+
# direction: "ASC"
|
55
|
+
# }
|
56
|
+
# }
|
57
|
+
# }
|
58
|
+
# @products = session.product.search(body)
|
59
|
+
#
|
60
|
+
def search(body)
|
61
|
+
response, status = BeyondApi::Request.post(@session,
|
62
|
+
"/products/search",
|
63
|
+
body)
|
64
|
+
|
65
|
+
handle_response(response, status)
|
66
|
+
end
|
7
67
|
|
8
68
|
#
|
9
69
|
# A +GET+ request is used to search for a product by SKU.
|
@@ -44,7 +104,8 @@ module BeyondApi
|
|
44
104
|
# @tags = session.product.search_tags_starting_by("aw")
|
45
105
|
#
|
46
106
|
def search_tags_starting_by(starts_with, params = {})
|
47
|
-
response, status = BeyondApi::Request.get(@session, "/products/search/tags",
|
107
|
+
response, status = BeyondApi::Request.get(@session, "/products/search/tags",
|
108
|
+
params.merge(starts_with: starts_with))
|
48
109
|
|
49
110
|
handle_response(response, status)
|
50
111
|
end
|
@@ -4,7 +4,6 @@ require "beyond_api/utils"
|
|
4
4
|
|
5
5
|
module BeyondApi
|
6
6
|
module ProductVideos
|
7
|
-
|
8
7
|
#
|
9
8
|
# A +POST+ request is used to create a video and add it to a product.
|
10
9
|
#
|
@@ -137,8 +136,10 @@ module BeyondApi
|
|
137
136
|
# @example
|
138
137
|
# @videos = session.products.videos("04c6ad65-465d-405e-a428-f73349104b65", size: 100, page: 0)
|
139
138
|
#
|
140
|
-
def videos(product_id, params =
|
141
|
-
response, status = BeyondApi::Request.get(@session,
|
139
|
+
def videos(product_id, params = {})
|
140
|
+
response, status = BeyondApi::Request.get(@session,
|
141
|
+
"/products/#{product_id}/videos",
|
142
|
+
params)
|
142
143
|
|
143
144
|
handle_response(response, status)
|
144
145
|
end
|
@@ -43,7 +43,9 @@ module BeyondApi
|
|
43
43
|
# @products = session.products.all(size: 100, page: 0)
|
44
44
|
#
|
45
45
|
def all(params = {})
|
46
|
-
|
46
|
+
path = "/products"
|
47
|
+
|
48
|
+
handle_all_request(path, :products, params)
|
47
49
|
end
|
48
50
|
|
49
51
|
#
|
@@ -166,7 +168,11 @@ module BeyondApi
|
|
166
168
|
# @product = session.products.create(body)
|
167
169
|
#
|
168
170
|
def create(body)
|
169
|
-
|
171
|
+
path = "/products"
|
172
|
+
|
173
|
+
response, status = BeyondApi::Request.post(@session,
|
174
|
+
path,
|
175
|
+
body)
|
170
176
|
|
171
177
|
handle_response(response, status)
|
172
178
|
end
|
@@ -188,7 +194,10 @@ module BeyondApi
|
|
188
194
|
# session.products.delete("c06c61af-f99a-4698-90fa-8c3199ca732f")
|
189
195
|
#
|
190
196
|
def delete(product_id)
|
191
|
-
|
197
|
+
path = "/products/#{product_id}"
|
198
|
+
|
199
|
+
response, status = BeyondApi::Request.delete(@session,
|
200
|
+
path)
|
192
201
|
|
193
202
|
handle_response(response, status, respond_with_true: true)
|
194
203
|
end
|
@@ -211,7 +220,10 @@ module BeyondApi
|
|
211
220
|
# @product = session.products.find("75ebcb57-aefb-4963-8225-060c528e070d")
|
212
221
|
#
|
213
222
|
def find(product_id)
|
214
|
-
|
223
|
+
path = "/products/#{product_id}"
|
224
|
+
|
225
|
+
response, status = BeyondApi::Request.get(@session,
|
226
|
+
path)
|
215
227
|
|
216
228
|
handle_response(response, status)
|
217
229
|
end
|
@@ -247,7 +259,11 @@ module BeyondApi
|
|
247
259
|
# @product = session.products.update("b69e3f47-03b8-40d2-843c-ae89a3d9bcdd", body)
|
248
260
|
#
|
249
261
|
def update(product_id, body)
|
250
|
-
|
262
|
+
path = "/products/#{product_id}"
|
263
|
+
|
264
|
+
response, status = BeyondApi::Request.patch(@session,
|
265
|
+
path,
|
266
|
+
body)
|
251
267
|
|
252
268
|
handle_response(response, status)
|
253
269
|
end
|
@@ -271,13 +287,16 @@ module BeyondApi
|
|
271
287
|
# session.products.assign_variation_images_differentiator("f205294b-17dc-4f75-8b5e-5df72abb96df", "491fedf4-37a9-4bcf-98b8-cff2f82879b7")
|
272
288
|
#
|
273
289
|
def assign_variation_attribute_as_differentiator(product_id, variation_attribute_id)
|
274
|
-
|
290
|
+
path = "/products/#{product_id}/variation-attributes/#{variation_attribute_id}/make-differentiator"
|
291
|
+
|
292
|
+
response, status = BeyondApi::Request.post(@session,
|
293
|
+
path)
|
275
294
|
|
276
295
|
handle_response(response, status, respond_with_true: true)
|
277
296
|
end
|
278
297
|
|
279
|
-
|
280
|
-
|
281
|
-
|
298
|
+
alias create_variation create
|
299
|
+
alias find_variation find
|
300
|
+
alias update_variation update
|
282
301
|
end
|
283
302
|
end
|
@@ -23,7 +23,9 @@ module BeyondApi
|
|
23
23
|
# @products = session.products_view.all(page: 0, size: 100)
|
24
24
|
#
|
25
25
|
def all(params = {})
|
26
|
-
|
26
|
+
path = "/product-view/products"
|
27
|
+
|
28
|
+
handle_all_request(path, :products, params)
|
27
29
|
end
|
28
30
|
|
29
31
|
#
|
@@ -39,7 +41,10 @@ module BeyondApi
|
|
39
41
|
# @tags = session.products_view.available_tags
|
40
42
|
#
|
41
43
|
def available_tags
|
42
|
-
|
44
|
+
path = "/product-view/products/search/find-available-tags"
|
45
|
+
|
46
|
+
response, status = BeyondApi::Request.get(@session,
|
47
|
+
path)
|
43
48
|
|
44
49
|
handle_response(response, status)
|
45
50
|
end
|
@@ -60,7 +65,10 @@ module BeyondApi
|
|
60
65
|
# @product = session.products_view.find("f75f8fb2-5a48-4d94-aad6-3d3692c06472")
|
61
66
|
#
|
62
67
|
def find(product_id)
|
63
|
-
|
68
|
+
path = "/product-view/products/#{product_id}"
|
69
|
+
|
70
|
+
response, status = BeyondApi::Request.get(@session,
|
71
|
+
path)
|
64
72
|
|
65
73
|
handle_response(response, status)
|
66
74
|
end
|
@@ -82,7 +90,11 @@ module BeyondApi
|
|
82
90
|
# @products = session.products_view.search_by_tag("number0", {page: 0, size: 100})
|
83
91
|
#
|
84
92
|
def search_by_tag(tag, params = {})
|
85
|
-
|
93
|
+
path = "/product-view/products/search/find-by-tags"
|
94
|
+
|
95
|
+
response, status = BeyondApi::Request.get(@session,
|
96
|
+
path,
|
97
|
+
params.merge(tag: tag))
|
86
98
|
|
87
99
|
handle_response(response, status)
|
88
100
|
end
|
@@ -104,7 +116,11 @@ module BeyondApi
|
|
104
116
|
# @products = session.products_view.search_by_term("search snippet", {page: 0, size: 100})
|
105
117
|
#
|
106
118
|
def search_by_term(term, params = {})
|
107
|
-
|
119
|
+
path = "/product-view/products/search/find-by-term"
|
120
|
+
|
121
|
+
response, status = BeyondApi::Request.get(@session,
|
122
|
+
path,
|
123
|
+
params.merge(query: term))
|
108
124
|
|
109
125
|
handle_response(response, status)
|
110
126
|
end
|
@@ -22,7 +22,9 @@ module BeyondApi
|
|
22
22
|
# @script_tags = session.script_tags.all(size: 20, page: 0)
|
23
23
|
#
|
24
24
|
def all(params = {})
|
25
|
-
|
25
|
+
path = "/script-tags"
|
26
|
+
|
27
|
+
handle_all_request(path, :script_tags, params)
|
26
28
|
end
|
27
29
|
|
28
30
|
#
|
@@ -39,7 +41,10 @@ module BeyondApi
|
|
39
41
|
# @script_tag = session.script_tags.find("df170ab1-13ae-4955-8b51-2478246acf59")
|
40
42
|
#
|
41
43
|
def find(script_tag_id)
|
42
|
-
|
44
|
+
path = "/script-tags/#{script_tag_id}"
|
45
|
+
|
46
|
+
response, status = BeyondApi::Request.get(@session,
|
47
|
+
path)
|
43
48
|
|
44
49
|
handle_response(response, status)
|
45
50
|
end
|
@@ -65,7 +70,11 @@ module BeyondApi
|
|
65
70
|
# @script_tag = session.script_tags.create("https://example.org/js/fancy-script.js")
|
66
71
|
#
|
67
72
|
def create(script_tag_url)
|
68
|
-
|
73
|
+
path = "/script-tags"
|
74
|
+
|
75
|
+
response, status = BeyondApi::Request.post(@session,
|
76
|
+
path,
|
77
|
+
{ script_url: script_tag_url })
|
69
78
|
|
70
79
|
handle_response(response, status)
|
71
80
|
end
|
@@ -86,7 +95,10 @@ module BeyondApi
|
|
86
95
|
# session.script_tags.delete("4a9f7776-d74d-4311-8ddb-121bd5407520")
|
87
96
|
#
|
88
97
|
def delete(script_tag_id)
|
89
|
-
|
98
|
+
path = "/script-tags/#{script_tag_id}"
|
99
|
+
|
100
|
+
response, status = BeyondApi::Request.delete(@session,
|
101
|
+
path)
|
90
102
|
|
91
103
|
handle_response(response, status, respond_with_true: true)
|
92
104
|
end
|
@@ -113,7 +125,11 @@ module BeyondApi
|
|
113
125
|
# @script_tag = session.script_tags.create("https://example.org/scripts/someOtherScript.js")
|
114
126
|
#
|
115
127
|
def update(script_tag_id, script_tag_url)
|
116
|
-
|
128
|
+
path = "/script-tags/#{script_tag_id}"
|
129
|
+
|
130
|
+
response, status = BeyondApi::Request.put(@session,
|
131
|
+
path,
|
132
|
+
{ script_url: script_tag_url })
|
117
133
|
|
118
134
|
handle_response(response, status)
|
119
135
|
end
|
@@ -24,7 +24,9 @@ module BeyondApi
|
|
24
24
|
# @shipping_zones = session.shipping_zones.all(size: 20, page: 0)
|
25
25
|
#
|
26
26
|
def all(params = {})
|
27
|
-
|
27
|
+
path = "/shipping-zones"
|
28
|
+
|
29
|
+
handle_all_request(path, :shipping_zones, params)
|
28
30
|
end
|
29
31
|
|
30
32
|
#
|
@@ -52,7 +54,11 @@ module BeyondApi
|
|
52
54
|
# @shipping_zone = session.shipping_zones.create(body)
|
53
55
|
#
|
54
56
|
def create(body)
|
55
|
-
|
57
|
+
path = "/shipping-zones"
|
58
|
+
|
59
|
+
response, status = BeyondApi::Request.post(@session,
|
60
|
+
path,
|
61
|
+
body)
|
56
62
|
|
57
63
|
handle_response(response, status)
|
58
64
|
end
|
@@ -105,7 +111,11 @@ module BeyondApi
|
|
105
111
|
# @shipping_zone = session.shipping_zones.create_shipping_method("905e981c-1489-45af-9138-0a7dc1f0b085", body)
|
106
112
|
#
|
107
113
|
def create_shipping_method(shipping_zone_id, body)
|
108
|
-
|
114
|
+
path = "/shipping-zones/#{shipping_zone_id}/shipping-methods"
|
115
|
+
|
116
|
+
response, status = BeyondApi::Request.post(@session,
|
117
|
+
path,
|
118
|
+
body)
|
109
119
|
|
110
120
|
handle_response(response, status)
|
111
121
|
end
|
@@ -126,7 +136,10 @@ module BeyondApi
|
|
126
136
|
# session.shipping_zones.delete("c871b402-b6d9-4c6d-b76c-440f61175805")
|
127
137
|
#
|
128
138
|
def delete(shipping_zone_id)
|
129
|
-
|
139
|
+
path = "/shipping-zones/#{shipping_zone_id}"
|
140
|
+
|
141
|
+
response, status = BeyondApi::Request.delete(@session,
|
142
|
+
path)
|
130
143
|
|
131
144
|
handle_response(response, status, respond_with_true: true)
|
132
145
|
end
|
@@ -148,7 +161,10 @@ module BeyondApi
|
|
148
161
|
# session.shipping_zones.delete_shipping_method("61c14c3c-ce26-4524-9713-f2ede7ff22fa", "d2eee203-a1c6-4035-8e7a-74bb77cfde47")
|
149
162
|
#
|
150
163
|
def delete_shipping_method(shipping_zone_id, shipping_method_id)
|
151
|
-
|
164
|
+
path = "/shipping-zones/#{shipping_zone_id}/shipping_methods/#{shipping_method_id}"
|
165
|
+
|
166
|
+
response, status = BeyondApi::Request.delete(@session,
|
167
|
+
path)
|
152
168
|
|
153
169
|
handle_response(response, status, respond_with_true: true)
|
154
170
|
end
|
@@ -170,7 +186,10 @@ module BeyondApi
|
|
170
186
|
# @shipping_zone = session.shipping_zones.find("27914098-c1f6-46aa-9e78-c7ac873e25b3")
|
171
187
|
#
|
172
188
|
def find(shipping_zone_id)
|
173
|
-
|
189
|
+
path = "/shipping-zones/#{shipping_zone_id}"
|
190
|
+
|
191
|
+
response, status = BeyondApi::Request.get(@session,
|
192
|
+
path)
|
174
193
|
|
175
194
|
handle_response(response, status)
|
176
195
|
end
|
@@ -187,7 +206,10 @@ module BeyondApi
|
|
187
206
|
# @serviceable_countries = session.shipping_zones.find_serviceable_countries
|
188
207
|
#
|
189
208
|
def find_serviceable_countries
|
190
|
-
|
209
|
+
path = "/shipping-zones/search/find-all-serviceable-countries"
|
210
|
+
|
211
|
+
response, status = BeyondApi::Request.get(@session,
|
212
|
+
path)
|
191
213
|
|
192
214
|
handle_response(response, status)
|
193
215
|
end
|
@@ -209,7 +231,10 @@ module BeyondApi
|
|
209
231
|
# @shipping_method = session.shipping_zones.shipping_method("61780dd6-0150-4fcf-953c-d10c52bab4ab", "13bd1fc9-706c-4774-923a-484a41aaab89")
|
210
232
|
#
|
211
233
|
def shipping_method(shipping_zone_id, shipping_method_id)
|
212
|
-
|
234
|
+
path = "/shipping-zones/#{shipping_zone_id}/shipping-methods/#{shipping_method_id}"
|
235
|
+
|
236
|
+
response, status = BeyondApi::Request.get(@session,
|
237
|
+
path)
|
213
238
|
|
214
239
|
handle_response(response, status)
|
215
240
|
end
|
@@ -233,7 +258,11 @@ module BeyondApi
|
|
233
258
|
# @shipping_methods = session.shipping_zones.shipping_methods("8cc24465-3573-4eca-8323-b076bb724080", { size: 20, page: 0 })
|
234
259
|
#
|
235
260
|
def shipping_methods(shipping_zone_id, params = {})
|
236
|
-
|
261
|
+
path = "/shipping-zones/#{shipping_zone_id}/shipping-methods"
|
262
|
+
|
263
|
+
response, status = BeyondApi::Request.get(@session,
|
264
|
+
path,
|
265
|
+
params)
|
237
266
|
|
238
267
|
handle_response(response, status)
|
239
268
|
end
|
@@ -260,8 +289,13 @@ module BeyondApi
|
|
260
289
|
# session.shipping_zones.sort(shipping_zone_ids)
|
261
290
|
#
|
262
291
|
def sort(shipping_zone_ids)
|
292
|
+
path = "/shipping-zones"
|
293
|
+
|
263
294
|
body = shipping_zone_ids.map { |id| "#{session.api_url}/shipping-zones/#{id}" }
|
264
|
-
|
295
|
+
|
296
|
+
response, status = BeyondApi::Request.put(@session,
|
297
|
+
path,
|
298
|
+
body)
|
265
299
|
|
266
300
|
handle_response(response, status, respond_with_true: true)
|
267
301
|
end
|
@@ -284,7 +318,10 @@ module BeyondApi
|
|
284
318
|
# session.shipping_zones.sort_shipping_methods(shipping_zone_id)
|
285
319
|
#
|
286
320
|
def sort_shipping_methods(shipping_zone_id)
|
287
|
-
|
321
|
+
path = "/shipping-zones/#{shipping_zone_id}/shipping-methods"
|
322
|
+
|
323
|
+
response, status = BeyondApi::Request.put(@session,
|
324
|
+
path)
|
288
325
|
|
289
326
|
handle_response(response, status)
|
290
327
|
end
|
@@ -315,7 +352,11 @@ module BeyondApi
|
|
315
352
|
# @shipping_zone = session.shipping_zones.update("727b3cbf-01b1-442a-bd5c-94c51901f090", body)
|
316
353
|
#
|
317
354
|
def update(shipping_zone_id, body)
|
318
|
-
|
355
|
+
path = "/shipping-zones/#{shipping_zone_id}"
|
356
|
+
|
357
|
+
response, status = BeyondApi::Request.put(@session,
|
358
|
+
path,
|
359
|
+
body)
|
319
360
|
|
320
361
|
handle_response(response, status)
|
321
362
|
end
|
@@ -29,7 +29,10 @@ module BeyondApi
|
|
29
29
|
# session.shop.current
|
30
30
|
#
|
31
31
|
def current
|
32
|
-
|
32
|
+
path = "/shop"
|
33
|
+
|
34
|
+
response, status = BeyondApi::Request.get(@session,
|
35
|
+
path)
|
33
36
|
|
34
37
|
handle_response(response, status)
|
35
38
|
end
|
@@ -81,7 +84,11 @@ module BeyondApi
|
|
81
84
|
# session.shop.update(body)
|
82
85
|
#
|
83
86
|
def update(body)
|
84
|
-
|
87
|
+
path = "/shop"
|
88
|
+
|
89
|
+
response, status = BeyondApi::Request.patch(@session,
|
90
|
+
path,
|
91
|
+
body)
|
85
92
|
|
86
93
|
handle_response(response, status)
|
87
94
|
end
|
@@ -4,7 +4,6 @@ require "beyond_api/utils"
|
|
4
4
|
|
5
5
|
module BeyondApi
|
6
6
|
module ShopImages
|
7
|
-
|
8
7
|
#
|
9
8
|
# A +POST+ request is used to create a shop image.
|
10
9
|
#
|
@@ -138,16 +137,20 @@ module BeyondApi
|
|
138
137
|
#
|
139
138
|
def upload_image(image_path, image_name, label)
|
140
139
|
content_type = case File.extname(image_path)
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
140
|
+
when ".png"
|
141
|
+
"image/png"
|
142
|
+
when ".jpg", ".jpeg"
|
143
|
+
"image/jpeg"
|
144
|
+
when ".gif"
|
145
|
+
"image/gif"
|
146
|
+
end
|
148
147
|
image_binary = File.binread(image_path)
|
149
148
|
|
150
|
-
response, status = BeyondApi::Request.upload(@session,
|
149
|
+
response, status = BeyondApi::Request.upload(@session,
|
150
|
+
"/shop/images",
|
151
|
+
image_binary,
|
152
|
+
content_type,
|
153
|
+
{ file_name: image_name, label: label })
|
151
154
|
|
152
155
|
handle_response(response, status, respond_with_true: true)
|
153
156
|
end
|
@@ -4,7 +4,6 @@ require "beyond_api/utils"
|
|
4
4
|
|
5
5
|
module BeyondApi
|
6
6
|
module ShopLegals
|
7
|
-
|
8
7
|
#
|
9
8
|
# A +GET+ request is used to retrieve a specific part of the legal content information.
|
10
9
|
#
|
@@ -20,7 +19,8 @@ module BeyondApi
|
|
20
19
|
# @legal_content = session.shop.legal_content("right-of-withdrawal")
|
21
20
|
#
|
22
21
|
def legal_content(legal_content_type)
|
23
|
-
response, status = BeyondApi::Request.get(@session,
|
22
|
+
response, status = BeyondApi::Request.get(@session,
|
23
|
+
"/legal-content/#{legal_content_type}")
|
24
24
|
|
25
25
|
handle_response(response, status)
|
26
26
|
end
|
@@ -41,7 +41,9 @@ module BeyondApi
|
|
41
41
|
# @legal_content = session.shop.legal_contents(size: 5, page: 1)
|
42
42
|
#
|
43
43
|
def legal_contents(params = {})
|
44
|
-
response, status = BeyondApi::Request.get(@session,
|
44
|
+
response, status = BeyondApi::Request.get(@session,
|
45
|
+
"/legal-content",
|
46
|
+
params)
|
45
47
|
|
46
48
|
handle_response(response, status)
|
47
49
|
end
|
@@ -60,12 +62,13 @@ module BeyondApi
|
|
60
62
|
# @legal_details = session.shop.legal_details
|
61
63
|
#
|
62
64
|
def legal_details
|
63
|
-
response, status = BeyondApi::Request.get(@session,
|
65
|
+
response, status = BeyondApi::Request.get(@session,
|
66
|
+
"/shop/legal")
|
64
67
|
|
65
68
|
handle_response(response, status)
|
66
69
|
end
|
67
70
|
|
68
|
-
#
|
71
|
+
#
|
69
72
|
# A +PUT+ request is used to update the content of a specific part of the legal content information. Changes on the properties type and mandatory will be ignored.
|
70
73
|
#
|
71
74
|
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content/legal-notice' -i -X PUT \
|
@@ -86,7 +89,9 @@ module BeyondApi
|
|
86
89
|
# session.shop.update_legal_content(body)
|
87
90
|
#
|
88
91
|
def update_legal_content(body)
|
89
|
-
response, status = BeyondApi::Request.put(@session,
|
92
|
+
response, status = BeyondApi::Request.put(@session,
|
93
|
+
"/legal-content/legal-notice",
|
94
|
+
body)
|
90
95
|
|
91
96
|
handle_response(response, status)
|
92
97
|
end
|
@@ -116,7 +121,9 @@ module BeyondApi
|
|
116
121
|
# session.shop.update_legal_details(body)
|
117
122
|
#
|
118
123
|
def update_legal_details(body)
|
119
|
-
response, status = BeyondApi::Request.patch(@session,
|
124
|
+
response, status = BeyondApi::Request.patch(@session,
|
125
|
+
"/shop/legal",
|
126
|
+
body)
|
120
127
|
|
121
128
|
handle_response(response, status)
|
122
129
|
end
|