beyond_api 0.18.0.pre → 0.18.2.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +33 -0
  3. data/CHANGELOG.md +16 -0
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +29 -1
  6. data/Rakefile +4 -2
  7. data/beyond_api.gemspec +12 -8
  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 +28 -9
  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 +6 -5
  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 -42
  46. data/lib/beyond_api/version.rb +3 -1
  47. data/lib/beyond_api.rb +3 -1
  48. data/lib/generators/beyond_api/install_generator.rb +1 -1
  49. metadata +52 -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
  #
@@ -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
@@ -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, "/legal-content/#{legal_content_type}")
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, "/legal-content", params)
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, "/shop/legal")
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, "/legal-content/legal-notice")
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, "/shop/legal")
124
+ response, status = BeyondApi::Request.patch(@session,
125
+ "/shop/legal",
126
+ body)
120
127
 
121
128
  handle_response(response, status)
122
129
  end
@@ -4,7 +4,6 @@ require "beyond_api/utils"
4
4
 
5
5
  module BeyondApi
6
6
  module ShopLocations
7
-
8
7
  #
9
8
  # A +GET+ request is used to retrieve a list of all locations for the current shop.
10
9
  #
@@ -19,7 +19,10 @@ module BeyondApi
19
19
  # @signers = session.signers.all
20
20
  #
21
21
  def all
22
- response, status = BeyondApi::Request.get(@session, "/signers")
22
+ path = "/signers"
23
+
24
+ response, status = BeyondApi::Request.get(@session,
25
+ path)
23
26
 
24
27
  handle_response(response, status)
25
28
  end
@@ -37,7 +40,10 @@ module BeyondApi
37
40
  # @signer = session.signers.create
38
41
  #
39
42
  def create
40
- response, status = BeyondApi::Request.post(@session, "/signers")
43
+ path = "/signers"
44
+
45
+ response, status = BeyondApi::Request.post(@session,
46
+ path)
41
47
 
42
48
  handle_response(response, status)
43
49
  end
@@ -55,7 +61,10 @@ module BeyondApi
55
61
  # session.signers.delete("6bb72afd-340e-439a-9990-eef2e0883e1e")
56
62
  #
57
63
  def delete(signer_id)
58
- response, status = BeyondApi::Request.delete(@session, "/signers/#{signer_id}")
64
+ path = "/signers/#{signer_id}"
65
+
66
+ response, status = BeyondApi::Request.delete(@session,
67
+ path)
59
68
 
60
69
  handle_response(response, status, respond_with_true: true)
61
70
  end
@@ -13,8 +13,8 @@ module BeyondApi
13
13
  def initialize(session)
14
14
  @session = session
15
15
 
16
- raise InvalidSessionError.new("Invalid session") unless session.is_a? BeyondApi::Session
17
- raise InvalidSessionError.new("Session api_url cannot be nil") if session.api_url.nil?
16
+ raise InvalidSessionError, "Invalid session" unless session.is_a? BeyondApi::Session
17
+ raise InvalidSessionError, "Session api_url cannot be nil" if session.api_url.nil?
18
18
  end
19
19
 
20
20
  def authorization_code(code)
@@ -29,15 +29,16 @@ module BeyondApi
29
29
  handle_token_call("client_credentials")
30
30
  end
31
31
 
32
- alias_method :refresh, :refresh_token
33
- alias_method :create, :authorization_code
32
+ alias refresh refresh_token
33
+ alias create authorization_code
34
34
 
35
35
  private
36
36
 
37
37
  def handle_token_call(grant_type, params = {})
38
+ path = "#{@session.api_url}/oauth/token"
38
39
  params.merge!(grant_type: grant_type)
39
40
 
40
- response, status = BeyondApi::Request.token(@session.api_url + "/oauth/token",
41
+ response, status = BeyondApi::Request.token(path,
41
42
  params)
42
43
 
43
44
  handle_response(response, status)