beyond_api 0.16.1.pre → 0.19.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 +38 -1
- data/Gemfile +6 -0
- data/Gemfile.lock +68 -8
- data/Rakefile +4 -2
- data/beyond_api.gemspec +14 -10
- 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 +21 -4
- 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 +35 -10
- data/lib/beyond_api/resources/products/searches.rb +2 -2
- 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 +32 -13
- 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 +20 -18
- 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 +60 -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 -41
- data/lib/beyond_api/version.rb +3 -1
- data/lib/beyond_api.rb +6 -2
- data/lib/generators/beyond_api/install_generator.rb +1 -1
- data/lib/generators/templates/beyond_api_initializer.rb +3 -0
- metadata +57 -12
@@ -27,7 +27,9 @@ module BeyondApi
|
|
27
27
|
# @cart = session.carts.add_line_item("6d529573-b39e-4cd4-99fe-856432ea97f3", body)
|
28
28
|
#
|
29
29
|
def add_line_item(cart_id, body)
|
30
|
-
response, status = BeyondApi::Request.post(@session,
|
30
|
+
response, status = BeyondApi::Request.post(@session,
|
31
|
+
"/carts/#{cart_id}/line-items",
|
32
|
+
body)
|
31
33
|
|
32
34
|
handle_response(response, status)
|
33
35
|
end
|
@@ -44,7 +46,8 @@ module BeyondApi
|
|
44
46
|
# @cart = session.carts.create
|
45
47
|
#
|
46
48
|
def create
|
47
|
-
response, status = BeyondApi::Request.post(@session,
|
49
|
+
response, status = BeyondApi::Request.post(@session,
|
50
|
+
"/carts")
|
48
51
|
|
49
52
|
handle_response(response, status)
|
50
53
|
end
|
@@ -73,7 +76,9 @@ module BeyondApi
|
|
73
76
|
# @payment = session.carts.create_payment("158bdcee-178a-4b5f-88ff-1953f5ea8e09/", body)
|
74
77
|
#
|
75
78
|
def create_payment(cart_id, body)
|
76
|
-
response, status = BeyondApi::Request.post(@session,
|
79
|
+
response, status = BeyondApi::Request.post(@session,
|
80
|
+
"/carts/#{cart_id}/create-payment",
|
81
|
+
body)
|
77
82
|
|
78
83
|
handle_response(response, status)
|
79
84
|
end
|
@@ -114,7 +119,9 @@ module BeyondApi
|
|
114
119
|
# @payment = session.carts.create_payment_and_order("f6c6615b-a9f6-420e-be1d-46339ddc5fda", body)
|
115
120
|
#
|
116
121
|
def create_payment_and_order(cart_id, body)
|
117
|
-
response, status = BeyondApi::Request.post(@session,
|
122
|
+
response, status = BeyondApi::Request.post(@session,
|
123
|
+
"/carts/#{cart_id}/create-payment-and-order",
|
124
|
+
body)
|
118
125
|
|
119
126
|
handle_response(response, status)
|
120
127
|
end
|
@@ -149,7 +156,9 @@ module BeyondApi
|
|
149
156
|
# @order = session.carts.create_order("986247da-b78f-422c-a273-917804896974", body)
|
150
157
|
#
|
151
158
|
def create_order(cart_id, body)
|
152
|
-
response, status = BeyondApi::Request.post(@session,
|
159
|
+
response, status = BeyondApi::Request.post(@session,
|
160
|
+
"/carts/#{cart_id}/order",
|
161
|
+
body)
|
153
162
|
|
154
163
|
handle_response(response, status)
|
155
164
|
end
|
@@ -167,7 +176,8 @@ module BeyondApi
|
|
167
176
|
# session.carts.delete("1a58f22f-481a-4993-9947-62c1c2857f87")
|
168
177
|
#
|
169
178
|
def delete(cart_id)
|
170
|
-
response, status = BeyondApi::Request.delete(@session,
|
179
|
+
response, status = BeyondApi::Request.delete(@session,
|
180
|
+
"/carts/#{cart_id}")
|
171
181
|
|
172
182
|
handle_response(response, status, respond_with_true: true)
|
173
183
|
end
|
@@ -186,7 +196,8 @@ module BeyondApi
|
|
186
196
|
# @cart = session.carts.delete_line_item("3fb55475-f6d2-471a-90ac-ccee7896b9f7", "51c86195-d2b9-4073-9a14-7ddd5a76b6a7")
|
187
197
|
#
|
188
198
|
def delete_line_item(cart_id, line_item_id)
|
189
|
-
response, status = BeyondApi::Request.delete(@session,
|
199
|
+
response, status = BeyondApi::Request.delete(@session,
|
200
|
+
"/carts/#{cart_id}/line-items/#{line_item_id}")
|
190
201
|
|
191
202
|
handle_response(response, status, respond_with_true: true)
|
192
203
|
end
|
@@ -205,7 +216,8 @@ module BeyondApi
|
|
205
216
|
# session.carts.delete_shipping_address("2fa7dc36-8305-4628-b961-f2c3f7dda47d")
|
206
217
|
#
|
207
218
|
def delete_shipping_address(cart_id)
|
208
|
-
response, status = BeyondApi::Request.delete(@session,
|
219
|
+
response, status = BeyondApi::Request.delete(@session,
|
220
|
+
"/carts/#{cart_id}/shipping-address")
|
209
221
|
|
210
222
|
handle_response(response, status, respond_with_true: true)
|
211
223
|
end
|
@@ -225,7 +237,8 @@ module BeyondApi
|
|
225
237
|
# @cart = session.carts.find("26857145-aeab-4210-9191-3906573a14ae")
|
226
238
|
#
|
227
239
|
def find(cart_id)
|
228
|
-
response, status = BeyondApi::Request.get(@session,
|
240
|
+
response, status = BeyondApi::Request.get(@session,
|
241
|
+
"/carts/#{cart_id}")
|
229
242
|
|
230
243
|
handle_response(response, status)
|
231
244
|
end
|
@@ -244,7 +257,8 @@ module BeyondApi
|
|
244
257
|
# @payment_method = session.carts.payment_method("26857145-aeab-4210-9191-3906573a14ae")
|
245
258
|
#
|
246
259
|
def payment_method(cart_id)
|
247
|
-
response, status = BeyondApi::Request.get(@session,
|
260
|
+
response, status = BeyondApi::Request.get(@session,
|
261
|
+
"/carts/#{cart_id}/payment-methods/current")
|
248
262
|
|
249
263
|
handle_response(response, status)
|
250
264
|
end
|
@@ -266,7 +280,8 @@ module BeyondApi
|
|
266
280
|
# @payment_methods = session.carts.payment_methods("45f9009d-4d2f-43b1-9cd2-ea29ff0d46d6")
|
267
281
|
#
|
268
282
|
def payment_methods(cart_id)
|
269
|
-
response, status = BeyondApi::Request.get(@session,
|
283
|
+
response, status = BeyondApi::Request.get(@session,
|
284
|
+
"/carts/#{cart_id}/payment-methods")
|
270
285
|
|
271
286
|
handle_response(response, status)
|
272
287
|
end
|
@@ -294,7 +309,9 @@ module BeyondApi
|
|
294
309
|
# @cart = session.carts.replace_line_item("f73629e5-fecf-4474-9b04-6b2fcd4663c4", "2c9c0f38-0b9e-4fa7-bcbe-960098ff63aa", body)
|
295
310
|
#
|
296
311
|
def replace_line_item(cart_id, line_item_id, body)
|
297
|
-
response, status = BeyondApi::Request.put(@session,
|
312
|
+
response, status = BeyondApi::Request.put(@session,
|
313
|
+
"/carts/#{cart_id}/line-items/#{line_item_id}",
|
314
|
+
body)
|
298
315
|
|
299
316
|
handle_response(response, status)
|
300
317
|
end
|
@@ -315,13 +332,15 @@ module BeyondApi
|
|
315
332
|
# body = [ {
|
316
333
|
# "_type" => "PRODUCT",
|
317
334
|
# "_ref" => "0612362d-9856-4b40-94c6-a36abec0cf8c",
|
318
|
-
# "quantity" => 1
|
335
|
+
# "quantity" => 1
|
319
336
|
# } ]
|
320
337
|
#
|
321
338
|
# @cart = session.carts.replace_line_items("c1436110-e283-49b3-a748-0321efec6d35", body)
|
322
339
|
#
|
323
340
|
def replace_line_items(cart_id, body)
|
324
|
-
response, status = BeyondApi::Request.put(@session,
|
341
|
+
response, status = BeyondApi::Request.put(@session,
|
342
|
+
"/carts/#{cart_id}/line-items",
|
343
|
+
body)
|
325
344
|
|
326
345
|
handle_response(response, status)
|
327
346
|
end
|
@@ -371,7 +390,9 @@ module BeyondApi
|
|
371
390
|
# @cart = session.carts.set_billing_address("01da6aa7-8aa2-4383-a496-6611a14afbc9", body)
|
372
391
|
#
|
373
392
|
def set_billing_address(cart_id, body)
|
374
|
-
response, status = BeyondApi::Request.put(@session,
|
393
|
+
response, status = BeyondApi::Request.put(@session,
|
394
|
+
"/carts/#{cart_id}/billing-address",
|
395
|
+
body)
|
375
396
|
|
376
397
|
handle_response(response, status)
|
377
398
|
end
|
@@ -393,8 +414,9 @@ module BeyondApi
|
|
393
414
|
# @cart = session.carts.set_payment_method("750c8a68-ef58-4955-b05f-29e35fa19687", "6498f339-7fe6-43d4-8e2a-6da68d7cdfe3")
|
394
415
|
#
|
395
416
|
def set_payment_method(cart_id, payment_method_id)
|
396
|
-
response, status = BeyondApi::Request.put(@session,
|
397
|
-
|
417
|
+
response, status = BeyondApi::Request.put(@session,
|
418
|
+
"/carts/#{cart_id}/payment-methods/current",
|
419
|
+
"#{@session.api_url}/payment-methods/#{payment_method_id}")
|
398
420
|
|
399
421
|
handle_response(response, status)
|
400
422
|
end
|
@@ -414,7 +436,8 @@ module BeyondApi
|
|
414
436
|
# @cart = session.carts.set_payment_method_to_default("d1efcb74-ab96-43c5-b404-9c1f927dc3d2")
|
415
437
|
#
|
416
438
|
def set_payment_method_to_default(cart_id)
|
417
|
-
response, status = BeyondApi::Request.put(@session,
|
439
|
+
response, status = BeyondApi::Request.put(@session,
|
440
|
+
"/carts/#{cart_id}/payment-methods/default")
|
418
441
|
|
419
442
|
handle_response(response, status)
|
420
443
|
end
|
@@ -464,7 +487,9 @@ module BeyondApi
|
|
464
487
|
# @cart = session.carts.set_shipping_address("01da6aa7-8aa2-4383-a496-6611a14afbc9", body)
|
465
488
|
#
|
466
489
|
def set_shipping_address(cart_id, body)
|
467
|
-
response, status = BeyondApi::Request.put(@session,
|
490
|
+
response, status = BeyondApi::Request.put(@session,
|
491
|
+
"/carts/#{cart_id}/shipping-address",
|
492
|
+
body)
|
468
493
|
|
469
494
|
handle_response(response, status)
|
470
495
|
end
|
@@ -487,7 +512,8 @@ module BeyondApi
|
|
487
512
|
# @cart = session.carts.set_shipping_method("a4e7922a-f895-4a7d-8cb1-6ecf74d7ceba", "59e26c99-ef1d-4ee8-a79f-d078cd6dfe24", "f3d3ce8d-eeab-44b6-81bb-67a4f1d7a57f")
|
488
513
|
#
|
489
514
|
def set_shipping_method(cart_id, shipping_zone_id, shipping_method_id)
|
490
|
-
response, status = BeyondApi::Request.put(@session,
|
515
|
+
response, status = BeyondApi::Request.put(@session,
|
516
|
+
"/carts/#{cart_id}/shipping-methods/current",
|
491
517
|
"#{session.api_url}/shipping-zones/#{shipping_zone_id}/shipping-methods/#{shipping_method_id}")
|
492
518
|
|
493
519
|
handle_response(response, status)
|
@@ -509,7 +535,8 @@ module BeyondApi
|
|
509
535
|
# @cart = session.carts.set_shipping_method_to_default("c31c5d06-4460-4f89-9e09-47f9956dea98")
|
510
536
|
#
|
511
537
|
def set_shipping_method_to_default(cart_id)
|
512
|
-
response, status = BeyondApi::Request.put(@session,
|
538
|
+
response, status = BeyondApi::Request.put(@session,
|
539
|
+
"/carts/#{cart_id}/shipping-methods/default")
|
513
540
|
|
514
541
|
handle_response(response, status)
|
515
542
|
end
|
@@ -529,7 +556,8 @@ module BeyondApi
|
|
529
556
|
# @shipping_method = session.carts.shipping_method("9093a339-66fd-4cc1-9dcf-d23003c38b41")
|
530
557
|
#
|
531
558
|
def shipping_method(cart_id)
|
532
|
-
response, status = BeyondApi::Request.get(@session,
|
559
|
+
response, status = BeyondApi::Request.get(@session,
|
560
|
+
"/carts/#{cart_id}")
|
533
561
|
|
534
562
|
handle_response(response, status)
|
535
563
|
end
|
@@ -548,7 +576,8 @@ module BeyondApi
|
|
548
576
|
# @cart = session.carts.shipping_methods("05a547a0-80dc-4a8c-b9b6-aa028b6ef7d8")
|
549
577
|
#
|
550
578
|
def shipping_methods(cart_id)
|
551
|
-
response, status = BeyondApi::Request.get(@session,
|
579
|
+
response, status = BeyondApi::Request.get(@session,
|
580
|
+
"/carts/#{cart_id}")
|
552
581
|
|
553
582
|
handle_response(response, status)
|
554
583
|
end
|
@@ -42,7 +42,8 @@ module BeyondApi
|
|
42
42
|
# @category = session.categories_view.find("23bb1430-6e82-40e4-9a92-4cb404da74a8")
|
43
43
|
#
|
44
44
|
def find(category_id)
|
45
|
-
response, status = BeyondApi::Request.get(@session,
|
45
|
+
response, status = BeyondApi::Request.get(@session,
|
46
|
+
"/product-view/categories/#{category_id}")
|
46
47
|
|
47
48
|
handle_response(response, status)
|
48
49
|
end
|
@@ -64,7 +65,9 @@ module BeyondApi
|
|
64
65
|
# @products = session.categories_view.products("681beef2-cd3e-4ce3-8034-4d07c1184447", { size: 100, page: 0 })
|
65
66
|
#
|
66
67
|
def products(category_id, params = {})
|
67
|
-
response, status = BeyondApi::Request.get(@session,
|
68
|
+
response, status = BeyondApi::Request.get(@session,
|
69
|
+
"/product-view/categories/#{category_id}/products",
|
70
|
+
params)
|
68
71
|
|
69
72
|
handle_response(response, status)
|
70
73
|
end
|
@@ -84,7 +87,9 @@ module BeyondApi
|
|
84
87
|
# @category = session.categories_view.search_by_label("power-bar")
|
85
88
|
#
|
86
89
|
def search_by_label(label)
|
87
|
-
response, status = BeyondApi::Request.get(@session,
|
90
|
+
response, status = BeyondApi::Request.get(@session,
|
91
|
+
"/product-view/categories/search/find-by-label",
|
92
|
+
{ label: label })
|
88
93
|
|
89
94
|
handle_response(response, status)
|
90
95
|
end
|
@@ -104,7 +109,9 @@ module BeyondApi
|
|
104
109
|
# @category = session.categories_view.search_by_product_id("ba68427f-603c-4741-9185-3b379f7769b5")
|
105
110
|
#
|
106
111
|
def search_by_product_id(product_id, params = {})
|
107
|
-
response, status = BeyondApi::Request.get(@session,
|
112
|
+
response, status = BeyondApi::Request.get(@session,
|
113
|
+
"/product-view/categories/search/find-by-product",
|
114
|
+
params.merge(product_id: product_id))
|
108
115
|
|
109
116
|
handle_response(response, status)
|
110
117
|
end
|
@@ -144,9 +151,12 @@ module BeyondApi
|
|
144
151
|
# @categories = session.categories_view.search_by_product(body, { size: 100, page: 0 })
|
145
152
|
#
|
146
153
|
def search_by_product(body, params = {})
|
147
|
-
response, status = BeyondApi::Request.post(@session,
|
154
|
+
response, status = BeyondApi::Request.post(@session,
|
155
|
+
"/product-view/categories/search/find-by-product",
|
156
|
+
body,
|
157
|
+
params)
|
148
158
|
|
149
|
-
handle_response(response, status
|
159
|
+
handle_response(response, status)
|
150
160
|
end
|
151
161
|
end
|
152
162
|
end
|
@@ -28,7 +28,9 @@ module BeyondApi
|
|
28
28
|
# session.newsletter_target.create({ submit_url: "https://example.org/cgi-bin/subscribe.php" })
|
29
29
|
#
|
30
30
|
def create(submit_url)
|
31
|
-
response, status = BeyondApi::Request.post(@session,
|
31
|
+
response, status = BeyondApi::Request.post(@session,
|
32
|
+
"/newsletter-target",
|
33
|
+
{ submit_url: submit_url })
|
32
34
|
|
33
35
|
handle_response(response, status)
|
34
36
|
end
|
@@ -47,7 +49,8 @@ module BeyondApi
|
|
47
49
|
# session.newsletter_target.delete
|
48
50
|
#
|
49
51
|
def delete
|
50
|
-
response, status = BeyondApi::Request.delete(@session,
|
52
|
+
response, status = BeyondApi::Request.delete(@session,
|
53
|
+
"/newsletter-target")
|
51
54
|
|
52
55
|
handle_response(response, status, respond_with_true: true)
|
53
56
|
end
|
@@ -63,7 +66,8 @@ module BeyondApi
|
|
63
66
|
# @newsletter_target = session.newsletter_target.find
|
64
67
|
#
|
65
68
|
def find
|
66
|
-
response, status = BeyondApi::Request.get(@session,
|
69
|
+
response, status = BeyondApi::Request.get(@session,
|
70
|
+
"/newsletter-target")
|
67
71
|
|
68
72
|
handle_response(response, status)
|
69
73
|
end
|
@@ -89,7 +93,9 @@ module BeyondApi
|
|
89
93
|
# session.newsletter_target.update({ submit_url: "https://example.org/cgi-bin/subscribe.php" })
|
90
94
|
#
|
91
95
|
def update(submit_url)
|
92
|
-
response, status = BeyondApi::Request.put(@session,
|
96
|
+
response, status = BeyondApi::Request.put(@session,
|
97
|
+
"/newsletter-target",
|
98
|
+
{ submit_url: submit_url })
|
93
99
|
|
94
100
|
handle_response(response, status)
|
95
101
|
end
|