beyond_api 0.11.1.pre → 0.15.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -0
- data/Gemfile.lock +25 -25
- data/lib/beyond_api.rb +13 -13
- data/lib/beyond_api/connection.rb +7 -0
- data/lib/beyond_api/ext.rb +8 -1
- data/lib/beyond_api/logger.rb +13 -0
- data/lib/beyond_api/resources/payment_method_definitions.rb +175 -0
- data/lib/beyond_api/resources/pickup_options.rb +84 -0
- data/lib/beyond_api/resources/products.rb +16 -18
- data/lib/beyond_api/resources/shop.rb +11 -438
- data/lib/beyond_api/resources/shops/address.rb +54 -0
- data/lib/beyond_api/resources/shops/attributes.rb +137 -0
- data/lib/beyond_api/resources/shops/images.rb +155 -0
- data/lib/beyond_api/resources/shops/legals.rb +124 -0
- data/lib/beyond_api/resources/shops/locations.rb +252 -0
- data/lib/beyond_api/resources/variations.rb +3 -2
- data/lib/beyond_api/session.rb +32 -22
- data/lib/beyond_api/version.rb +1 -1
- data/lib/generators/templates/beyond_api_initializer.rb +15 -0
- metadata +11 -3
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "beyond_api/utils"
|
4
|
-
require "beyond_api/resources/products/attachments"
|
5
|
-
require "beyond_api/resources/products/availability"
|
6
|
-
require "beyond_api/resources/products/cross_sells"
|
7
|
-
require "beyond_api/resources/products/custom_attributes"
|
8
|
-
require "beyond_api/resources/products/images"
|
9
|
-
require "beyond_api/resources/products/searches"
|
10
|
-
require "beyond_api/resources/products/variation_properties"
|
11
|
-
require "beyond_api/resources/products/videos"
|
12
4
|
|
13
5
|
module BeyondApi
|
6
|
+
autoload :ProductAttachments, "beyond_api/resources/products/attachments"
|
7
|
+
autoload :ProductAvailability, "beyond_api/resources/products/availability"
|
8
|
+
autoload :ProductCrossSells, "beyond_api/resources/products/cross_sells"
|
9
|
+
autoload :ProductCustomAttributes, "beyond_api/resources/products/custom_attributes"
|
10
|
+
autoload :ProductImages, "beyond_api/resources/products/images"
|
11
|
+
autoload :ProductSearches, "beyond_api/resources/products/searches"
|
12
|
+
autoload :ProductVariationProperties, "beyond_api/resources/products/variation_properties"
|
13
|
+
autoload :ProductVideos, "beyond_api/resources/products/videos"
|
14
|
+
|
14
15
|
class Products < Base
|
15
16
|
include BeyondApi::ProductAttachments
|
16
17
|
include BeyondApi::ProductAvailability
|
@@ -252,28 +253,25 @@ module BeyondApi
|
|
252
253
|
end
|
253
254
|
|
254
255
|
#
|
255
|
-
# A +
|
256
|
+
# A +POST+ request is used to assign a variation attribute as the variation images differentiator for a variation product.
|
256
257
|
#
|
257
258
|
# @beyond_api.scopes +prod:u+
|
258
259
|
#
|
259
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/products/
|
260
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/f205294b-17dc-4f75-8b5e-5df72abb96df/variation-attributes/491fedf4-37a9-4bcf-98b8-cff2f82879b7/make-differentiator' -i -X POST \
|
260
261
|
# -H 'Content-Type: application/hal+json' \
|
261
262
|
# -H 'Accept: application/hal+json' \
|
262
|
-
# -H 'Authorization: Bearer <Access token>'
|
263
|
-
# -d '{
|
264
|
-
# "differentiator" : "size"
|
265
|
-
# }'
|
263
|
+
# -H 'Authorization: Bearer <Access token>'
|
266
264
|
#
|
267
265
|
# @param product_id [String] the product UUID
|
268
|
-
# @param
|
266
|
+
# @param variation_attribute_id [String] the variation attribute UUID
|
269
267
|
#
|
270
268
|
# @return [true]
|
271
269
|
#
|
272
270
|
# @example
|
273
|
-
# session.products.assign_variation_images_differentiator("
|
271
|
+
# session.products.assign_variation_images_differentiator("f205294b-17dc-4f75-8b5e-5df72abb96df", "491fedf4-37a9-4bcf-98b8-cff2f82879b7")
|
274
272
|
#
|
275
|
-
def
|
276
|
-
response, status = BeyondApi::Request.
|
273
|
+
def assign_variation_attribute_as_differentiator(product_id, variation_attribute_id)
|
274
|
+
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/variation-attributes/#{variation_attribute_id}/make-differentiator")
|
277
275
|
|
278
276
|
handle_response(response, status, respond_with_true: true)
|
279
277
|
end
|
@@ -3,133 +3,20 @@
|
|
3
3
|
require "beyond_api/utils"
|
4
4
|
|
5
5
|
module BeyondApi
|
6
|
+
autoload :ShopAddress, "beyond_api/resources/shops/address"
|
7
|
+
autoload :ShopAttributes, "beyond_api/resources/shops/attributes"
|
8
|
+
autoload :ShopImages, "beyond_api/resources/shops/images"
|
9
|
+
autoload :ShopLegals, "beyond_api/resources/shops/legals"
|
10
|
+
autoload :ShopLocations, "beyond_api/resources/shops/locations"
|
11
|
+
|
6
12
|
class Shop < Base
|
13
|
+
include BeyondApi::ShopAddress
|
14
|
+
include BeyondApi::ShopAttributes
|
15
|
+
include BeyondApi::ShopImages
|
16
|
+
include BeyondApi::ShopLegals
|
17
|
+
include BeyondApi::ShopLocations
|
7
18
|
include BeyondApi::Utils
|
8
19
|
|
9
|
-
#
|
10
|
-
# A +GET+ request is used to retrieve the details of a shop’s address.
|
11
|
-
#
|
12
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/address' -i -X GET
|
13
|
-
#
|
14
|
-
# @return [OpenStruct]
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
# session.shop.address
|
18
|
-
#
|
19
|
-
def address
|
20
|
-
response, status = BeyondApi::Request.get(@session, "/shop/address")
|
21
|
-
|
22
|
-
handle_response(response, status)
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# A +GET+ request is used to retrieve a particular shop attribute by its name.
|
27
|
-
#
|
28
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X GET \
|
29
|
-
# -H 'Authorization: Bearer <Access token>'
|
30
|
-
#
|
31
|
-
# @beyond_api.scopes +shat:r+
|
32
|
-
#
|
33
|
-
# @param attribute_name [String] the attribute name
|
34
|
-
#
|
35
|
-
# @return [OpenStruct]
|
36
|
-
#
|
37
|
-
# @example
|
38
|
-
# @shop_attribute = session.shop.attribute("second-unknown-attribute-name")
|
39
|
-
#
|
40
|
-
def attribute(attribute_name)
|
41
|
-
response, status = BeyondApi::Request.get(@session, "/shop/attributes/#{attribute_name}")
|
42
|
-
|
43
|
-
handle_response(response, status)
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# A +GET+ request is used to retrieve a list of all shop attributes.
|
48
|
-
#
|
49
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes' -i -X GET \
|
50
|
-
# -H 'Authorization: Bearer <Access token>'
|
51
|
-
#
|
52
|
-
# @beyond_api.scopes +shat:r+
|
53
|
-
#
|
54
|
-
# @option params [Integer] :size the page size
|
55
|
-
# @option params [Integer] :page the page number
|
56
|
-
#
|
57
|
-
# @return [OpenStruct]
|
58
|
-
#
|
59
|
-
# @example
|
60
|
-
# @shop_attributes = session.shop.attributes(size: 5, page: 1)
|
61
|
-
#
|
62
|
-
def attributes(params = {})
|
63
|
-
response, status = BeyondApi::Request.get(@session, "/shop/attributes", params)
|
64
|
-
|
65
|
-
handle_response(response, status)
|
66
|
-
end
|
67
|
-
|
68
|
-
#
|
69
|
-
# A +POST+ request is used to create a shop attribute.
|
70
|
-
#
|
71
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes' -i -X POST \
|
72
|
-
# -H 'Content-Type: application/json' \
|
73
|
-
# -H 'Authorization: Bearer <Access token>' \
|
74
|
-
# -d '{
|
75
|
-
# "name" : "second-unknown-attribute-name",
|
76
|
-
# "value" : "correct-value",
|
77
|
-
# "public" : false
|
78
|
-
# }'
|
79
|
-
#
|
80
|
-
# @beyond_api.scopes +shat:c+
|
81
|
-
#
|
82
|
-
# @param body [Hash] the request body
|
83
|
-
#
|
84
|
-
# @return [OpenStruct]
|
85
|
-
#
|
86
|
-
# @example
|
87
|
-
# body = {
|
88
|
-
# "name" => "second-unknown-attribute-name",
|
89
|
-
# "value" => "correct-value",
|
90
|
-
# "public" => false
|
91
|
-
# }
|
92
|
-
#
|
93
|
-
# session.shop.create_attribute(body)
|
94
|
-
#
|
95
|
-
def create_attribute(body)
|
96
|
-
response, status = BeyondApi::Request.post(@session, "/shop/attributes", body)
|
97
|
-
|
98
|
-
handle_response(response, status)
|
99
|
-
end
|
100
|
-
|
101
|
-
#
|
102
|
-
# A +POST+ request is used to create a shop image.
|
103
|
-
#
|
104
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images' -i -X POST \
|
105
|
-
# -H 'Content-Type: application/json' \
|
106
|
-
# -H 'Accept: application/hal+json' \
|
107
|
-
# -H 'Authorization: Bearer <Access token>' \
|
108
|
-
# -d '{
|
109
|
-
# "dataUri" : "file.png?hash=212-2323-4343",
|
110
|
-
# "label" : "logo"
|
111
|
-
# }'
|
112
|
-
#
|
113
|
-
# @beyond_api.scopes +shim:c+
|
114
|
-
#
|
115
|
-
# @param body [Hash] the request body
|
116
|
-
#
|
117
|
-
# @return true
|
118
|
-
#
|
119
|
-
# @example
|
120
|
-
# body = {
|
121
|
-
# "data_uri" => "file.png?hash=212-2323-4343",
|
122
|
-
# "label" => "logo"
|
123
|
-
# }
|
124
|
-
#
|
125
|
-
# session.shop.create_image(body)
|
126
|
-
#
|
127
|
-
def create_image(body)
|
128
|
-
response, status = BeyondApi::Request.post(@session, "/shop/images", body)
|
129
|
-
|
130
|
-
handle_response(response, status, respond_with_true: true)
|
131
|
-
end
|
132
|
-
|
133
20
|
#
|
134
21
|
# A +GET+ request is used to retrieve the details of a shop.
|
135
22
|
#
|
@@ -147,168 +34,6 @@ module BeyondApi
|
|
147
34
|
handle_response(response, status)
|
148
35
|
end
|
149
36
|
|
150
|
-
#
|
151
|
-
# A +DELETE+ request is used to delete an shop attribute.
|
152
|
-
#
|
153
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X DELETE \
|
154
|
-
# -H 'Authorization: Bearer <Access token>'
|
155
|
-
#
|
156
|
-
# @beyond_api.scopes +shat:d+
|
157
|
-
#
|
158
|
-
# @param attribute_name [String] the attribute name
|
159
|
-
#
|
160
|
-
# @return true
|
161
|
-
#
|
162
|
-
# @example
|
163
|
-
# session.shop.delete_attribute("second-unknown-attribute-name")
|
164
|
-
#
|
165
|
-
def delete_attribute(attribute_name)
|
166
|
-
response, status = BeyondApi::Request.delete(@session, "/shop/attributes/#{attribute_name}")
|
167
|
-
|
168
|
-
handle_response(response, status, respond_with_true: true)
|
169
|
-
end
|
170
|
-
|
171
|
-
#
|
172
|
-
# A +DELETE+ request is used to delete a shop image.
|
173
|
-
#
|
174
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images/6a7646dc-7f26-4730-a98f-52f9b63978fb' -i -X DELETE \
|
175
|
-
# -H 'Content-Type: application/json' \
|
176
|
-
# -H 'Accept: application/hal+json' \
|
177
|
-
# -H 'Authorization: Bearer <Access token>'
|
178
|
-
#
|
179
|
-
# @beyond_api.scopes +shim:d+
|
180
|
-
#
|
181
|
-
# @param image_id [String] the image UUID
|
182
|
-
#
|
183
|
-
# @return true
|
184
|
-
#
|
185
|
-
# @example
|
186
|
-
# session.shop.delete_image("6a7646dc-7f26-4730-a98f-52f9b63978fb")
|
187
|
-
#
|
188
|
-
def delete_image(image_id)
|
189
|
-
response, status = BeyondApi::Request.delete(@session, "/shop/images/#{image_id}")
|
190
|
-
|
191
|
-
handle_response(response, status, respond_with_true: true)
|
192
|
-
end
|
193
|
-
|
194
|
-
#
|
195
|
-
# A +GET+ request is used to retrieve a single shop image.
|
196
|
-
#
|
197
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images/2feee7ac-f1cb-4faf-9488-f3ce07394141' -i -X GET \
|
198
|
-
# -H 'Accept: application/hal+json'
|
199
|
-
#
|
200
|
-
# @param image_id [String] the image UUID
|
201
|
-
#
|
202
|
-
# @return [OpenStruct]
|
203
|
-
#
|
204
|
-
# @example
|
205
|
-
# @image = session.shop.image("2feee7ac-f1cb-4faf-9488-f3ce07394141")
|
206
|
-
#
|
207
|
-
def image(image_id)
|
208
|
-
response, status = BeyondApi::Request.get(@session, "/shop/images/#{image_id}")
|
209
|
-
|
210
|
-
handle_response(response, status)
|
211
|
-
end
|
212
|
-
|
213
|
-
#
|
214
|
-
# A +GET+ request is used to retrieve the images of a shop.
|
215
|
-
#
|
216
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images' -i -X GET \
|
217
|
-
# -H 'Accept: application/hal+json'
|
218
|
-
#
|
219
|
-
# @option params [Integer] :size the page size
|
220
|
-
# @option params [Integer] :page the page number
|
221
|
-
#
|
222
|
-
# @return [OpenStruct]
|
223
|
-
#
|
224
|
-
# @example
|
225
|
-
# @images = session.shop.images(size: 5, page: 1)
|
226
|
-
#
|
227
|
-
def images(params = {})
|
228
|
-
response, status = BeyondApi::Request.get(@session, "/shop/images", params)
|
229
|
-
|
230
|
-
handle_response(response, status)
|
231
|
-
end
|
232
|
-
|
233
|
-
#
|
234
|
-
# A +GET+ request is used to retrieve a specific part of the legal content information.
|
235
|
-
#
|
236
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content/right-of-withdrawal' -i -X GET \
|
237
|
-
# -H 'Content-Type: application/json' \
|
238
|
-
# -H 'Accept: application/json'
|
239
|
-
#
|
240
|
-
# @param legal_content_type [String] the legal content type
|
241
|
-
#
|
242
|
-
# @return [OpenStruct]
|
243
|
-
#
|
244
|
-
# @example
|
245
|
-
# @legal_content = session.shop.legal_content("right-of-withdrawal")
|
246
|
-
#
|
247
|
-
def legal_content(legal_content_type)
|
248
|
-
response, status = BeyondApi::Request.get(@session, "/legal-content/#{legal_content_type}")
|
249
|
-
|
250
|
-
handle_response(response, status)
|
251
|
-
end
|
252
|
-
|
253
|
-
#
|
254
|
-
# A +GET+ request is used to retrieve the legal content of a shop.
|
255
|
-
#
|
256
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content' -i -X GET \
|
257
|
-
# -H 'Content-Type: application/json' \
|
258
|
-
# -H 'Accept: application/json'
|
259
|
-
#
|
260
|
-
# @option params [Integer] :size the page size
|
261
|
-
# @option params [Integer] :page the page number
|
262
|
-
#
|
263
|
-
# @return [OpenStruct]
|
264
|
-
#
|
265
|
-
# @example
|
266
|
-
# @legal_content = session.shop.legal_contents(size: 5, page: 1)
|
267
|
-
#
|
268
|
-
def legal_contents(params = {})
|
269
|
-
response, status = BeyondApi::Request.get(@session, "/legal-content", params)
|
270
|
-
|
271
|
-
handle_response(response, status)
|
272
|
-
end
|
273
|
-
|
274
|
-
#
|
275
|
-
# A +GET+ request is used to retrieve the details of the legal resource.
|
276
|
-
#
|
277
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/legal' -i -X GET \
|
278
|
-
# -H 'Authorization: Bearer <Access token>'
|
279
|
-
#
|
280
|
-
# @beyond_api.scopes +legl:r+
|
281
|
-
#
|
282
|
-
# @return [OpenStruct]
|
283
|
-
#
|
284
|
-
# @example
|
285
|
-
# @legal_details = session.shop.legal_details
|
286
|
-
#
|
287
|
-
def legal_details
|
288
|
-
response, status = BeyondApi::Request.get(@session, "/shop/legal")
|
289
|
-
|
290
|
-
handle_response(response, status)
|
291
|
-
end
|
292
|
-
|
293
|
-
#
|
294
|
-
# A +GET+ request is issued to search for shop images by label.
|
295
|
-
#
|
296
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/images/search/find-by-label?label=logo' -i -X GET \
|
297
|
-
# -H 'Accept: application/hal+json'
|
298
|
-
#
|
299
|
-
# @param label [String] the image label
|
300
|
-
#
|
301
|
-
# @return [OpenStruct]
|
302
|
-
#
|
303
|
-
# @example
|
304
|
-
# session.shop.search_images_by_label("logo")
|
305
|
-
#
|
306
|
-
def search_images_by_label(label)
|
307
|
-
response, status = BeyondApi::Request.get(@session, "/shop/images/search/find-by-label", { label: label })
|
308
|
-
|
309
|
-
handle_response(response, status)
|
310
|
-
end
|
311
|
-
|
312
37
|
#
|
313
38
|
# A +PATCH+ request is used to change attributes of a shop.
|
314
39
|
#
|
@@ -360,157 +85,5 @@ module BeyondApi
|
|
360
85
|
|
361
86
|
handle_response(response, status)
|
362
87
|
end
|
363
|
-
|
364
|
-
#
|
365
|
-
# A +PATCH+ request is used to patch a shop’s address partially with json content type.
|
366
|
-
#
|
367
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/address' -i -X PATCH \
|
368
|
-
# -H 'Content-Type: application/json' \
|
369
|
-
# -H 'Accept: application/hal+json' \
|
370
|
-
# -H 'Authorization: Bearer <Access token>' \
|
371
|
-
# -d '{
|
372
|
-
# "city" : "Barcelona"
|
373
|
-
# }'
|
374
|
-
#
|
375
|
-
# @beyond_api.scopes +shad:u+
|
376
|
-
#
|
377
|
-
# @param body [Hash] the request body
|
378
|
-
#
|
379
|
-
# @return [OpenStruct]
|
380
|
-
#
|
381
|
-
# @example
|
382
|
-
# body = {
|
383
|
-
# "city" => "Barcelona"
|
384
|
-
# }
|
385
|
-
#
|
386
|
-
# session.shop.update_address(body)
|
387
|
-
#
|
388
|
-
def update_address(body)
|
389
|
-
response, status = BeyondApi::Request.patch(@session, "/shop/address", body)
|
390
|
-
|
391
|
-
handle_response(response, status)
|
392
|
-
end
|
393
|
-
|
394
|
-
#
|
395
|
-
# A +PUT+ request is used to update a shop attribute. This operation is idempotent and will create a new shop attribute if required.
|
396
|
-
#
|
397
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/attributes/second-unknown-attribute-name' -i -X PUT \
|
398
|
-
# -H 'Content-Type: application/json' \
|
399
|
-
# -H 'Authorization: Bearer <Access token>' \
|
400
|
-
# -d '{
|
401
|
-
# "value" : "new-value",
|
402
|
-
# "public" : false
|
403
|
-
# }'
|
404
|
-
#
|
405
|
-
# @beyond_api.scopes +shat:u+
|
406
|
-
#
|
407
|
-
# @param attribute_name [String] the attribute name
|
408
|
-
# @param body [Hash] the request body
|
409
|
-
#
|
410
|
-
# @return [OpenStruct]
|
411
|
-
#
|
412
|
-
# @example
|
413
|
-
# body = {
|
414
|
-
# "value" => "new-value",
|
415
|
-
# "public" => false
|
416
|
-
# }
|
417
|
-
#
|
418
|
-
# session.shop.update_attribute("second-unknown-attribute-name", body)
|
419
|
-
#
|
420
|
-
def update_attribute(attribute_name, body)
|
421
|
-
response, status = BeyondApi::Request.put(@session, "/shop/attributes/#{attribute_name}", body)
|
422
|
-
|
423
|
-
handle_response(response, status)
|
424
|
-
end
|
425
|
-
|
426
|
-
#
|
427
|
-
# 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.
|
428
|
-
#
|
429
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content/legal-notice' -i -X PUT \
|
430
|
-
# -H 'Content-Type: application/json' \
|
431
|
-
# -H 'Accept: application/json' \
|
432
|
-
# -H 'Authorization: Bearer <Access token>' \
|
433
|
-
# -d '{
|
434
|
-
# "content" : "new legal content"
|
435
|
-
# }'
|
436
|
-
#
|
437
|
-
# @beyond_api.scopes +lcnt:u+
|
438
|
-
#
|
439
|
-
# @param body [Hash] the request body
|
440
|
-
#
|
441
|
-
# @return [OpenStruct]
|
442
|
-
#
|
443
|
-
# @example
|
444
|
-
# session.shop.update_legal_content(body)
|
445
|
-
#
|
446
|
-
def update_legal_content(body)
|
447
|
-
response, status = BeyondApi::Request.put(@session, "/legal-content/legal-notice")
|
448
|
-
|
449
|
-
handle_response(response, status)
|
450
|
-
end
|
451
|
-
|
452
|
-
#
|
453
|
-
# A +PATCH+ request is used to update a legal resource partially with json content type.
|
454
|
-
#
|
455
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/shop/legal' -i -X PATCH \
|
456
|
-
# -H 'Content-Type: application/json' \
|
457
|
-
# -H 'Accept: application/hal+json' \
|
458
|
-
# -H 'Authorization: Bearer <Access token>' \
|
459
|
-
# -d '{
|
460
|
-
# "vatId" : "GB 111111111"
|
461
|
-
# }'
|
462
|
-
#
|
463
|
-
# @beyond_api.scopes +legl:u+
|
464
|
-
#
|
465
|
-
# @param body [Hash] the request body
|
466
|
-
#
|
467
|
-
# @return [OpenStruct]
|
468
|
-
#
|
469
|
-
# @example
|
470
|
-
# body = {
|
471
|
-
# "vat_id" => "GB 111111111"
|
472
|
-
# }
|
473
|
-
#
|
474
|
-
# session.shop.update_legal_details(body)
|
475
|
-
#
|
476
|
-
def update_legal_details(body)
|
477
|
-
response, status = BeyondApi::Request.patch(@session, "/shop/legal")
|
478
|
-
|
479
|
-
handle_response(response, status)
|
480
|
-
end
|
481
|
-
|
482
|
-
#
|
483
|
-
# A +POST+ request is used to upload a shop image. The body of the request must contain the content of the image.
|
484
|
-
#
|
485
|
-
# $ curl --data-binary '@/home/epages/sample.png' 'https://api-shop.beyondshop.cloud/api/shop/images?fileName=sample.png&label=invoice logo' -X POST \
|
486
|
-
# -H 'Content-Type: image/png' \
|
487
|
-
# -H 'Authorization: Bearer <Access token>'
|
488
|
-
#
|
489
|
-
# @beyond_api.scopes +shim:c+
|
490
|
-
#
|
491
|
-
# @param image_path [String] the image path
|
492
|
-
# @param image_name [String] the image name
|
493
|
-
# @param label [String] the image label
|
494
|
-
#
|
495
|
-
# @return true
|
496
|
-
#
|
497
|
-
# @example
|
498
|
-
# session.shop.upload_image("/home/epages/sample.png", "sample.png", "invoice logo")
|
499
|
-
#
|
500
|
-
def upload_image(image_path, image_name, label)
|
501
|
-
content_type = case File.extname(image_path)
|
502
|
-
when ".png"
|
503
|
-
"image/png"
|
504
|
-
when ".jpg", ".jpeg"
|
505
|
-
"image/jpeg"
|
506
|
-
when ".gif"
|
507
|
-
"image/gif"
|
508
|
-
end
|
509
|
-
image_binary = File.binread(image_path)
|
510
|
-
|
511
|
-
response, status = BeyondApi::Request.upload(@session, "/shop/images", image_binary, content_type, { file_name: image_name, label: label })
|
512
|
-
|
513
|
-
handle_response(response, status, respond_with_true: true)
|
514
|
-
end
|
515
88
|
end
|
516
89
|
end
|