beyond_api 0.16.0.pre → 0.18.2.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +33 -0
  3. data/CHANGELOG.md +38 -1
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +30 -2
  6. data/Rakefile +4 -2
  7. data/beyond_api.gemspec +13 -9
  8. data/bin/console +2 -1
  9. data/lib/beyond_api/connection.rb +7 -4
  10. data/lib/beyond_api/error.rb +6 -6
  11. data/lib/beyond_api/ext.rb +16 -16
  12. data/lib/beyond_api/request.rb +4 -4
  13. data/lib/beyond_api/resources/carts.rb +52 -23
  14. data/lib/beyond_api/resources/categories_view.rb +16 -6
  15. data/lib/beyond_api/resources/newsletter_target.rb +10 -4
  16. data/lib/beyond_api/resources/orders.rb +152 -33
  17. data/lib/beyond_api/resources/payment_method_definitions.rb +11 -4
  18. data/lib/beyond_api/resources/product_attribute_definitions.rb +16 -4
  19. data/lib/beyond_api/resources/products/attachments.rb +0 -2
  20. data/lib/beyond_api/resources/products/availability.rb +20 -11
  21. data/lib/beyond_api/resources/products/cross_sells.rb +0 -1
  22. data/lib/beyond_api/resources/products/custom_attributes.rb +0 -1
  23. data/lib/beyond_api/resources/products/images.rb +12 -9
  24. data/lib/beyond_api/resources/products/searches.rb +2 -2
  25. data/lib/beyond_api/resources/products/variation_properties.rb +0 -1
  26. data/lib/beyond_api/resources/products/videos.rb +4 -3
  27. data/lib/beyond_api/resources/products.rb +32 -13
  28. data/lib/beyond_api/resources/products_view.rb +21 -5
  29. data/lib/beyond_api/resources/script_tags.rb +21 -5
  30. data/lib/beyond_api/resources/shipping_zones.rb +53 -12
  31. data/lib/beyond_api/resources/shop.rb +9 -2
  32. data/lib/beyond_api/resources/shops/address.rb +0 -1
  33. data/lib/beyond_api/resources/shops/attributes.rb +0 -1
  34. data/lib/beyond_api/resources/shops/images.rb +12 -9
  35. data/lib/beyond_api/resources/shops/legals.rb +14 -7
  36. data/lib/beyond_api/resources/shops/locations.rb +0 -1
  37. data/lib/beyond_api/resources/signers.rb +12 -3
  38. data/lib/beyond_api/resources/token.rb +20 -18
  39. data/lib/beyond_api/resources/users.rb +73 -15
  40. data/lib/beyond_api/resources/variations/availability.rb +17 -5
  41. data/lib/beyond_api/resources/variations/images.rb +32 -15
  42. data/lib/beyond_api/resources/variations.rb +14 -3
  43. data/lib/beyond_api/resources/webhook_subscriptions.rb +30 -8
  44. data/lib/beyond_api/session.rb +7 -1
  45. data/lib/beyond_api/utils.rb +44 -38
  46. data/lib/beyond_api/version.rb +3 -1
  47. data/lib/beyond_api.rb +6 -2
  48. data/lib/generators/beyond_api/install_generator.rb +1 -1
  49. data/lib/generators/templates/beyond_api_initializer.rb +3 -0
  50. metadata +59 -15
@@ -4,7 +4,6 @@ require "beyond_api/utils"
4
4
 
5
5
  module BeyondApi
6
6
  module ProductAvailability
7
-
8
7
  #
9
8
  # A +POST+ request is used to adjust the available stock of a product.
10
9
  #
@@ -25,7 +24,9 @@ module BeyondApi
25
24
  # @availability = session.products.adjust_stock_level("685f483e-cdda-40af-8091-d5bc31249409", -1)
26
25
  #
27
26
  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 })
27
+ response, status = BeyondApi::Request.post(@session,
28
+ "/products/#{product_id}/availability/adjust-available-stock",
29
+ { relative_amount: relative_amount })
29
30
 
30
31
  handle_response(response, status)
31
32
  end
@@ -48,7 +49,8 @@ module BeyondApi
48
49
  # @availability = session.products.availability("fb22d408-00dc-47e3-ae58-e35769bdb428")
49
50
  #
50
51
  def availability(product_id)
51
- response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/availability")
52
+ response, status = BeyondApi::Request.get(@session,
53
+ "/products/#{product_id}/availability")
52
54
 
53
55
  handle_response(response, status)
54
56
  end
@@ -71,7 +73,8 @@ module BeyondApi
71
73
  # session.products.disable_purchasability("6b30255e-650f-475c-b345-e7247f957689")
72
74
  #
73
75
  def disable_purchasability(product_id)
74
- response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/disable-purchasability")
76
+ response, status = BeyondApi::Request.post(@session,
77
+ "/products/#{product_id}/availability/disable-purchasability")
75
78
 
76
79
  handle_response(response, status, respond_with_true: true)
77
80
  end
@@ -94,7 +97,8 @@ module BeyondApi
94
97
  # session.products.disable_stock_management("e966cb17-4047-4b82-ade4-33e7f0978c89")
95
98
  #
96
99
  def disable_stock_management(product_id)
97
- response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/disable-stock-management")
100
+ response, status = BeyondApi::Request.post(@session,
101
+ "/products/#{product_id}/availability/disable-stock-management")
98
102
 
99
103
  handle_response(response, status, respond_with_true: true)
100
104
  end
@@ -117,7 +121,8 @@ module BeyondApi
117
121
  # session.products.enable_purchasability("17e3a92b-6f3b-4415-bd8f-c9c8921a5a73")
118
122
  #
119
123
  def enable_purchasability(product_id)
120
- response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/enable-purchasability")
124
+ response, status = BeyondApi::Request.post(@session,
125
+ "/products/#{product_id}/availability/enable-purchasability")
121
126
 
122
127
  handle_response(response, status, respond_with_true: true)
123
128
  end
@@ -146,15 +151,17 @@ module BeyondApi
146
151
  # @availability = session.products.enable_stock_management("101fa968-9bb8-4dbe-b166-3add1fc1b35e", body)
147
152
  #
148
153
  def enable_stock_management(product_id, body)
149
- response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/availability/enable-stock-management", body)
154
+ response, status = BeyondApi::Request.post(@session,
155
+ "/products/#{product_id}/availability/enable-stock-management",
156
+ body)
150
157
 
151
158
  handle_response(response, status)
152
159
  end
153
160
 
154
161
  #
155
- # A +POST+ request is used to update the reserve stock by changing the +stockThreshold+ value of a product or variation product (incl. all of its variations). Reserve stock refers to an inventory level that indicates that a product needs to be reordered.
162
+ # A +PUT+ request is used to update the reserve stock by changing the +stockThreshold+ value of a product or variation product (incl. all of its variations). Reserve stock refers to an inventory level that indicates that a product needs to be reordered.
156
163
  #
157
- # $ curl 'https://api-shop.beyondshop.cloud/api/products/f74b5f57-43cc-4176-97aa-c6eb9fdeb37c/availability/update-stock-threshold' -i -X POST \
164
+ # $ curl 'https://api-shop.beyondshop.cloud/api/products/f74b5f57-43cc-4176-97aa-c6eb9fdeb37c/availability/update-stock-threshold' -i -X PUT \
158
165
  # -H 'Content-Type: application/json' \
159
166
  # -H 'Accept: application/hal+json' \
160
167
  # -H 'Authorization: Bearer <Access token>' \
@@ -168,10 +175,12 @@ module BeyondApi
168
175
  # @return [OpenStruct]
169
176
  #
170
177
  # @example
171
- # session.products.update_reserve_stock("f74b5f57-43cc-4176-97aa-c6eb9fdeb37c", { stock_threshold => 5 })
178
+ # session.products.update_reserve_stock("f74b5f57-43cc-4176-97aa-c6eb9fdeb37c", 5)
172
179
  #
173
180
  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 })
181
+ response, status = BeyondApi::Request.put(@session,
182
+ "/products/#{product_id}/availability/update-stock-threshold",
183
+ { stock_threshold: stock_threshold })
175
184
 
176
185
  handle_response(response, status)
177
186
  end
@@ -4,7 +4,6 @@ require "beyond_api/utils"
4
4
 
5
5
  module BeyondApi
6
6
  module ProductCrossSells
7
-
8
7
  #
9
8
  # A +POST+ request is used to create a cross-sell for a product.
10
9
  #
@@ -4,7 +4,6 @@ require "beyond_api/utils"
4
4
 
5
5
  module BeyondApi
6
6
  module ProductCustomAttributes
7
-
8
7
  #
9
8
  # A +POST+ request is used to create a product attribute, which defines the value of a certain {product attribute definition}[http://docs.beyondshop.cloud/#resources-product-attribute-definitions] for a specific {product}[http://docs.beyondshop.cloud/#resources-products].
10
9
  #
@@ -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
  #
@@ -187,16 +186,20 @@ module BeyondApi
187
186
  #
188
187
  def upload_image(product_id, image_path, image_name)
189
188
  content_type = case File.extname(image_path)
190
- when ".png"
191
- "image/png"
192
- when ".jpg", ".jpeg"
193
- "image/jpeg"
194
- when ".gif"
195
- "image/gif"
196
- end
189
+ when ".png"
190
+ "image/png"
191
+ when ".jpg", ".jpeg"
192
+ "image/jpeg"
193
+ when ".gif"
194
+ "image/gif"
195
+ end
197
196
  image_binary = File.binread(image_path)
198
197
 
199
- response, status = BeyondApi::Request.upload(@session, "/products/#{product_id}/images", image_binary, content_type, { file_name: image_name })
198
+ response, status = BeyondApi::Request.upload(@session,
199
+ "/products/#{product_id}/images",
200
+ image_binary,
201
+ content_type,
202
+ { file_name: image_name })
200
203
 
201
204
  handle_response(response, status, respond_with_true: true)
202
205
  end
@@ -4,7 +4,6 @@ require "beyond_api/utils"
4
4
 
5
5
  module BeyondApi
6
6
  module ProductSearches
7
-
8
7
  #
9
8
  # A +GET+ request is used to search for a product by SKU.
10
9
  #
@@ -44,7 +43,8 @@ module BeyondApi
44
43
  # @tags = session.product.search_tags_starting_by("aw")
45
44
  #
46
45
  def search_tags_starting_by(starts_with, params = {})
47
- response, status = BeyondApi::Request.get(@session, "/products/search/tags", params.merge(starts_with: starts_with))
46
+ response, status = BeyondApi::Request.get(@session, "/products/search/tags",
47
+ params.merge(starts_with: starts_with))
48
48
 
49
49
  handle_response(response, status)
50
50
  end
@@ -4,7 +4,6 @@ require "beyond_api/utils"
4
4
 
5
5
  module BeyondApi
6
6
  module ProductVariationProperties
7
-
8
7
  #
9
8
  # A +PATCH+ request is used to update the variation properties of a variation product.
10
9
  #
@@ -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, "/products/#{product_id}/videos", params)
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
- handle_all_request("/products", :products, params)
46
+ path = "/products"
47
+
48
+ handle_all_request(path, :products, params)
47
49
  end
48
50
 
49
51
  #
@@ -98,8 +100,8 @@ module BeyondApi
98
100
  # }
99
101
  # },
100
102
  # "shippingPeriod" : {
101
- # "minDays" : 2,
102
- # "maxDays" : 4,
103
+ # "min" : 2,
104
+ # "max" : 4,
103
105
  # "displayUnit" : "WEEKS"
104
106
  # }
105
107
  # }'
@@ -157,8 +159,8 @@ module BeyondApi
157
159
  # }
158
160
  # },
159
161
  # "shippingPeriod": {
160
- # "minDays": 2,
161
- # "maxDays": 4,
162
+ # "min": 2,
163
+ # "max": 4,
162
164
  # "displayUnit": "WEEKS"
163
165
  # }
164
166
  # }
@@ -166,7 +168,11 @@ module BeyondApi
166
168
  # @product = session.products.create(body)
167
169
  #
168
170
  def create(body)
169
- response, status = BeyondApi::Request.post(@session, "/products", body)
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
- response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}")
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
- response, status = BeyondApi::Request.get(@session, "/products/#{product_id}")
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
- response, status = BeyondApi::Request.patch(@session, "/products/#{product_id}", body)
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
- response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/variation-attributes/#{variation_attribute_id}/make-differentiator")
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
- alias_method :create_variation, :create
280
- alias_method :find_variation, :find
281
- alias_method :update_variation, :update
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
- handle_all_request("/product-view/products", :products, params)
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
- response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-available-tags")
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
- response, status = BeyondApi::Request.get(@session, "/product-view/products/#{product_id}")
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
- response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-by-tags", params.merge(tag: tag))
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
- response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-by-term", params.merge(query: term))
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
- handle_all_request("/script-tags", :script_tags, params)
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
- response, status = BeyondApi::Request.get(@session, "/script-tags/#{script_tag_id}")
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
- response, status = BeyondApi::Request.post(@session, "/script-tags", { script_url: script_tag_url })
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
- response, status = BeyondApi::Request.delete(@session, "/script-tags/#{script_tag_id}")
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
- response, status = BeyondApi::Request.put(@session, "/script-tags/#{script_tag_id}", { script_url: script_tag_url })
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
- handle_all_request("/shipping-zones", :shipping_zones, params)
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
- response, status = BeyondApi::Request.post(@session, "/shipping-zones", body)
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
- response, status = BeyondApi::Request.post(@session, "/shipping-zones/#{shipping_zone_id}/shipping-methods", body)
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
- response, status = BeyondApi::Request.delete(@session, "/shipping-zones/#{shipping_zone_id}")
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
- response, status = BeyondApi::Request.delete(@session, "/shipping-zones/#{shipping_zone_id}/shipping_methods/#{shipping_method_id}")
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
- response, status = BeyondApi::Request.get(@session, "/shipping-zones/#{shipping_zone_id}")
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
- response, status = BeyondApi::Request.get(@session, "/shipping-zones/search/find-all-serviceable-countries")
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
- response, status = BeyondApi::Request.get(@session, "/shipping-zones/#{shipping_zone_id}/shipping-methods/#{shipping_method_id}")
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
- response, status = BeyondApi::Request.get(@session, "/shipping-zones/#{shipping_zone_id}/shipping-methods", params)
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
- response, status = BeyondApi::Request.put(@session, "/shipping-zones", body)
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
- response, status = BeyondApi::Request.put(@session, "/shipping-zones/#{shipping_zone_id}/shipping-methods")
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
- response, status = BeyondApi::Request.put(@session, "/shipping-zones/#{shipping_zone_id}", body)
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
- response, status = BeyondApi::Request.get(@session, "/shop")
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
- response, status = BeyondApi::Request.patch(@session, "/shop", body)
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 ShopAddress
7
-
8
7
  #
9
8
  # A +GET+ request is used to retrieve the details of a shop’s address.
10
9
  #
@@ -4,7 +4,6 @@ require "beyond_api/utils"
4
4
 
5
5
  module BeyondApi
6
6
  module ShopAttributes
7
-
8
7
  #
9
8
  # A +GET+ request is used to retrieve a particular shop attribute by its name.
10
9
  #
@@ -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
- when ".png"
142
- "image/png"
143
- when ".jpg", ".jpeg"
144
- "image/jpeg"
145
- when ".gif"
146
- "image/gif"
147
- end
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, "/shop/images", image_binary, content_type, { file_name: image_name, label: label })
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