beyond_api 0.16.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 (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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6c559696ebb3e320f0eba53263a1a2e4e1f6122abbee3abb0f9dcdcae0ed51c
4
- data.tar.gz: aed55ba3c13a04013d7aa4e7c4fcdea9252f1c93623b982eac53fa8557b098d8
3
+ metadata.gz: a98b8f593cfbaa19ab6632cf4abac105bc8b897ebf7b2b34bdbd821dc7eab98e
4
+ data.tar.gz: 9f4148cc7bb416d661090223d2073a9cffb760f94a153465bb09ea3a1bf3350e
5
5
  SHA512:
6
- metadata.gz: 7791a721f9b5e8a27e574d93274249e0a7240f2bb2400de235d8d3ab89a07ac133fe15aad399b9af9b305a28e36091f61d3d1fff493bb02e2b30b720955d0947
7
- data.tar.gz: 7363458296810b56dbcf80e220a2aad5c04a27c66b1f51e4485a9667ef671368aab1e8ed354b7d8692a4248dfc7ec41fd8bb2c66dc43f2015d5492a14cb8b255
6
+ metadata.gz: 40964af10851bc145293f58da2fd8fc30b3924a0900584e469137bb8b251ca5e452bfd2d2fc6c9998b17084a8f7990f6d40a60cc333c5555824fe5ed7455a43b
7
+ data.tar.gz: 96ee1ee2b444d309027c87b0a886b2f80d3f8a71c9446bfbc5bbf0d91869dce8a2120ffe6a3424929bc20342bc43148bf553c02b8d0fdf84cc6516745d603c1f
data/.rubocop.yml ADDED
@@ -0,0 +1,33 @@
1
+ require:
2
+ - rubocop-ordered_methods
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ NewCops: enable
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
10
+
11
+ Metrics/AbcSize:
12
+ Enabled: false
13
+ Metrics/MethodLength:
14
+ Enabled: false
15
+ Metrics/BlockLength:
16
+ Enabled: false
17
+ Metrics/ClassLength:
18
+ Enabled: false
19
+ Style/Documentation:
20
+ Enabled: false
21
+ Metrics/CyclomaticComplexity:
22
+ Enabled: false
23
+ Metrics/PerceivedComplexity:
24
+ Enabled: false
25
+
26
+ Layout/LineLength:
27
+ IgnoredPatterns: ['(\A|\s)#']
28
+
29
+ Style/AsciiComments:
30
+ Enabled: false
31
+
32
+ Style/SymbolArray:
33
+ EnforcedStyle: brackets
data/CHANGELOG.md CHANGED
@@ -1,3 +1,40 @@
1
+ ### v0.18.2.pre
2
+
3
+ * bug-fixes
4
+ * Move `#products.update_reserve_stock` from `POST` to `PUT`.
5
+
6
+ * enhancements
7
+ * Update how `api_url` is set on `BeyondApi::Session`.
8
+
9
+ * features
10
+ * Install, configure and fix most of the Rubocop issues.
11
+
12
+ ### v0.18.1.pre
13
+
14
+ * bug-fixes
15
+ * Prevent logging `code` and `refresh_token` on `/api/token` calls.
16
+
17
+ ### v0.18.0.pre
18
+
19
+ * features
20
+ * Add new token retrieval/refresh methods
21
+ * `Token#authorization_code`
22
+ * `Token#refresh_token`
23
+ * `Token#client_credentials`
24
+ * Add alias methods for avoiding deprecation
25
+ * `refresh` -> `refresh_token`
26
+ * `create` -> `authorization_code`
27
+
28
+ ### v0.17.0.pre
29
+
30
+ * enhancements
31
+ * Add customizable pagination size when sending `paginated: false` parameter to `#all` requests.
32
+
33
+ ### v0.16.1.pre
34
+
35
+ * bug-fixes
36
+ * Fix method to retrieve resources without pagination
37
+
1
38
  ### v0.16.0.pre
2
39
 
3
40
  * features
@@ -21,7 +58,7 @@
21
58
 
22
59
  * features
23
60
  * Add `Products#assign_variation_attribute_as_differentiator`
24
-
61
+
25
62
  ### v0.13.0.pre
26
63
 
27
64
  * features
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in beyond_api.gemspec
data/Gemfile.lock CHANGED
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beyond_api (0.16.0.pre)
4
+ beyond_api (0.18.2.pre)
5
5
  faraday (~> 0.15)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ ast (2.4.2)
10
11
  coderay (1.1.3)
11
12
  concurrent-ruby (1.1.9)
12
13
  diff-lcs (1.4.4)
@@ -19,10 +20,16 @@ GEM
19
20
  concurrent-ruby (~> 1.0)
20
21
  method_source (1.0.0)
21
22
  multipart-post (2.1.1)
23
+ parallel (1.20.1)
24
+ parser (3.0.2.0)
25
+ ast (~> 2.4.1)
22
26
  pry (0.14.1)
23
27
  coderay (~> 1.1)
24
28
  method_source (~> 1.0)
29
+ rainbow (3.0.0)
25
30
  rake (10.5.0)
31
+ regexp_parser (2.1.1)
32
+ rexml (3.2.5)
26
33
  rspec (3.10.0)
27
34
  rspec-core (~> 3.10.0)
28
35
  rspec-expectations (~> 3.10.0)
@@ -36,6 +43,24 @@ GEM
36
43
  diff-lcs (>= 1.2.0, < 2.0)
37
44
  rspec-support (~> 3.10.0)
38
45
  rspec-support (3.10.2)
46
+ rubocop (1.20.0)
47
+ parallel (~> 1.10)
48
+ parser (>= 3.0.0.0)
49
+ rainbow (>= 2.2.2, < 4.0)
50
+ regexp_parser (>= 1.8, < 3.0)
51
+ rexml
52
+ rubocop-ast (>= 1.9.1, < 2.0)
53
+ ruby-progressbar (~> 1.7)
54
+ unicode-display_width (>= 1.4.0, < 3.0)
55
+ rubocop-ast (1.11.0)
56
+ parser (>= 3.0.1.1)
57
+ rubocop-ordered_methods (0.9)
58
+ rubocop (>= 1.0)
59
+ rubocop-rspec (2.4.0)
60
+ rubocop (~> 1.0)
61
+ rubocop-ast (>= 1.1.0)
62
+ ruby-progressbar (1.11.0)
63
+ unicode-display_width (2.0.0)
39
64
  yard (0.9.26)
40
65
 
41
66
  PLATFORMS
@@ -49,7 +74,10 @@ DEPENDENCIES
49
74
  pry
50
75
  rake (~> 10.0)
51
76
  rspec (~> 3.0)
77
+ rubocop (~> 1.20)
78
+ rubocop-ordered_methods (~> 0.9)
79
+ rubocop-rspec (~> 2.4)
52
80
  yard (~> 0.9)
53
81
 
54
82
  BUNDLED WITH
55
- 2.1.4
83
+ 2.2.26
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
  require "yard"
4
6
 
5
7
  RSpec::Core::RakeTask.new(:spec)
6
8
 
7
- task :default => :spec
9
+ task default: :spec
8
10
 
9
11
  YARD::Rake::YardocTask.new do |t|
10
- t.files = ['lib/**/*.rb']
12
+ t.files = ["lib/**/*.rb"]
11
13
  end
data/beyond_api.gemspec CHANGED
@@ -1,17 +1,18 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path("lib", __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require "beyond_api/version"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = "beyond_api"
8
9
  spec.version = BeyondApi::VERSION
9
- spec.authors = ["Unai Abrisketa", "Kathia Salazar", "German San Emeterio"]
10
+ spec.authors = ["Unai Abrisketa", "Kathia Salazar", "German San Emeterio", "Kenneth Gallego"]
10
11
 
11
12
  spec.summary = "Ruby client to access the Beyond API"
12
13
  spec.homepage = "https://github.com/ePages-de/beyond_api-ruby_client"
13
14
 
14
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
15
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
15
16
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
17
  end
17
18
  spec.bindir = "exe"
@@ -20,12 +21,15 @@ Gem::Specification.new do |spec|
20
21
 
21
22
  spec.required_ruby_version = ">= 2.5.1"
22
23
 
23
- spec.add_development_dependency "bundler", "~> 2.0"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "yard", "~> 0.9"
27
- spec.add_development_dependency "faker", "~> 2.2"
28
- spec.add_development_dependency "dotenv", "~> 2.7"
24
+ spec.add_development_dependency "bundler", "~> 2.0"
25
+ spec.add_development_dependency "dotenv", "~> 2.7"
26
+ spec.add_development_dependency "faker", "~> 2.2"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "rubocop", "~> 1.20"
30
+ spec.add_development_dependency "rubocop-ordered_methods", "~> 0.9"
31
+ spec.add_development_dependency "rubocop-rspec", "~> 2.4"
32
+ spec.add_development_dependency "yard", "~> 0.9"
29
33
 
30
34
  spec.add_dependency "faraday", "~> 0.15"
31
35
  end
data/bin/console CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "dotenv/load"
5
6
  require "beyond_api"
6
7
 
7
- unless ENV["CLIENT_ID"].nil? and ENV["CLIENT_SECRET"].nil?
8
+ unless ENV["CLIENT_ID"].nil? && ENV["CLIENT_SECRET"].nil?
8
9
  BeyondApi.setup do |config|
9
10
  config.client_id = ENV["CLIENT_ID"]
10
11
  config.client_secret = ENV["CLIENT_SECRET"]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'faraday'
3
+ require "faraday"
4
4
 
5
5
  module BeyondApi
6
6
  class Connection
@@ -13,8 +13,8 @@ module BeyondApi
13
13
  faraday.options[:timeout] = BeyondApi.configuration.timeout.to_i
14
14
  faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers,
15
15
  bodies: BeyondApi.configuration.log_bodies }
16
- faraday.headers['Accept'] = 'application/json'
17
- faraday.headers['Content-Type'] = 'application/json'
16
+ faraday.headers["Accept"] = "application/json"
17
+ faraday.headers["Content-Type"] = "application/json"
18
18
  faraday.request(:multipart)
19
19
  faraday.request(:url_encoded)
20
20
  faraday.adapter(:net_http)
@@ -26,7 +26,10 @@ module BeyondApi
26
26
  faraday.options[:open_timeout] = BeyondApi.configuration.open_timeout.to_i
27
27
  faraday.options[:timeout] = BeyondApi.configuration.timeout.to_i
28
28
  faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers,
29
- bodies: BeyondApi.configuration.log_bodies }
29
+ bodies: BeyondApi.configuration.log_bodies } do |logger|
30
+ logger.filter(/(code=)([a-zA-Z0-9]+)/, '\1[FILTERED]')
31
+ logger.filter(/(refresh_token=)([a-zA-Z0-9.\-\_]+)/, '\1[FILTERED]')
32
+ end
30
33
  faraday.headers['Accept'] = 'application/json'
31
34
  faraday.adapter(:net_http)
32
35
  faraday.basic_auth(BeyondApi.configuration.client_id,
@@ -5,15 +5,15 @@ module BeyondApi
5
5
  attr_reader :error_id, :details, :trace_id, :full_message, :status_code, :error, :error_description
6
6
 
7
7
  def initialize(data, status_code = nil)
8
- @error_id = data['errorId']
9
- @details = data['details']
10
- @trace_id = data['traceId']
11
- @error = data['error']
12
- @error_description = data['error_description']
8
+ @error_id = data["errorId"]
9
+ @details = data["details"]
10
+ @trace_id = data["traceId"]
11
+ @error = data["error"]
12
+ @error_description = data["error_description"]
13
13
  @full_message = data
14
14
  @status_code = status_code
15
15
 
16
- super(data['message'] || data['error_description'])
16
+ super(data["message"] || data["error_description"])
17
17
  end
18
18
  end
19
19
  end
@@ -5,13 +5,13 @@ class Hash
5
5
  result = {}
6
6
  each do |key, value|
7
7
  result[yield(key)] = case value
8
- when Hash
9
- value.deep_transform_keys(&block)
10
- when Array
11
- value.camelize_keys
12
- else
13
- value
14
- end
8
+ when Hash
9
+ value.deep_transform_keys(&block)
10
+ when Array
11
+ value.camelize_keys
12
+ else
13
+ value
14
+ end
15
15
  end
16
16
  result
17
17
  end
@@ -31,19 +31,19 @@ class String
31
31
  end
32
32
 
33
33
  def underscore
34
- self.gsub(/::/, '/').
35
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
36
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
37
- tr("-", "_").
38
- downcase
34
+ gsub(/::/, "/")
35
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
36
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
37
+ .tr("-", "_")
38
+ .downcase
39
39
  end
40
40
 
41
41
  def camelize(uppercase_first_letter = true)
42
42
  string = self
43
43
  if uppercase_first_letter
44
- string = string.sub(/^[a-z\d]*/) { |match| match.capitalize }
44
+ string = string.sub(/^[a-z\d]*/, &:capitalize)
45
45
  else
46
- string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { |match| match.downcase }
46
+ string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/, &:downcase)
47
47
  end
48
48
  string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub("/", "::")
49
49
  end
@@ -53,8 +53,8 @@ class Array
53
53
  def camelize_keys
54
54
  map do |elem|
55
55
  case elem
56
- when Hash, Array; elem.camelize_keys
57
- else; elem
56
+ when Hash, Array then elem.camelize_keys
57
+ else; elem
58
58
  end
59
59
  end
60
60
  end
@@ -9,7 +9,7 @@ module BeyondApi
9
9
  define_method(method) do |session, path, params = {}|
10
10
  response = BeyondApi::Connection.default.send(method) do |request|
11
11
  request.url(session.api_url + path)
12
- request.headers['Authorization'] = "Bearer #{ session.access_token }" unless session.access_token.nil?
12
+ request.headers["Authorization"] = "Bearer #{session.access_token}" unless session.access_token.nil?
13
13
  request.params = params.to_h.camelize_keys
14
14
  end
15
15
 
@@ -21,7 +21,7 @@ module BeyondApi
21
21
  define_method(method) do |session, path, body = {}, params = {}|
22
22
  response = BeyondApi::Connection.default.send(method) do |request|
23
23
  request.url(session.api_url + path)
24
- request.headers['Authorization'] = "Bearer #{ session.access_token }" unless session.access_token.nil?
24
+ request.headers["Authorization"] = "Bearer #{session.access_token}" unless session.access_token.nil?
25
25
  request.params = params.to_h.camelize_keys
26
26
  request.body = body.camelize_keys.to_json
27
27
  end
@@ -34,8 +34,8 @@ module BeyondApi
34
34
  def self.upload(session, path, file_binary, content_type, params)
35
35
  response = BeyondApi::Connection.default.post do |request|
36
36
  request.url(session.api_url + path)
37
- request.headers['Authorization'] = "Bearer #{ session.access_token }" unless session.access_token.nil?
38
- request.headers['Content-Type'] = content_type
37
+ request.headers["Authorization"] = "Bearer #{session.access_token}" unless session.access_token.nil?
38
+ request.headers["Content-Type"] = content_type
39
39
  request.params = params.to_h.camelize_keys
40
40
  request.body = file_binary
41
41
  end
@@ -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, "/carts/#{cart_id}/line-items", body)
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, "/carts")
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, "/carts/#{cart_id}/create-payment", body)
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, "/carts/#{cart_id}/create-payment-and-order", body)
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, "/carts/#{cart_id}/order", body)
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, "/carts/#{cart_id}")
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, "/carts/#{cart_id}/line-items/#{line_item_id}")
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, "/carts/#{cart_id}/shipping-address")
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, "/carts/#{cart_id}")
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, "/carts/#{cart_id}/payment-methods/current")
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, "/carts/#{cart_id}/payment-methods")
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, "/carts/#{cart_id}/line-items/#{line_item_id}", body)
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, "/carts/#{cart_id}/line-items", body)
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, "/carts/#{cart_id}/billing-address", body)
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, "/carts/#{cart_id}/payment-methods/current",
397
- "#{@session.api_url}/payment-methods/#{payment_method_id}")
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, "/carts/#{cart_id}/payment-methods/default")
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, "/carts/#{cart_id}/shipping-address", body)
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, "/carts/#{cart_id}/shipping-methods/current",
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, "/carts/#{cart_id}/shipping-methods/default")
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, "/carts/#{cart_id}")
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, "/carts/#{cart_id}")
579
+ response, status = BeyondApi::Request.get(@session,
580
+ "/carts/#{cart_id}")
552
581
 
553
582
  handle_response(response, status)
554
583
  end