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.
- checksums.yaml +4 -4
- data/.rubocop.yml +33 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +29 -1
- data/Rakefile +4 -2
- data/beyond_api.gemspec +12 -8
- data/bin/console +2 -1
- data/lib/beyond_api/connection.rb +7 -4
- data/lib/beyond_api/error.rb +6 -6
- data/lib/beyond_api/ext.rb +16 -16
- data/lib/beyond_api/request.rb +4 -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 +12 -9
- 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 +28 -9
- 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 +6 -5
- 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 +32 -15
- 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 +44 -42
- data/lib/beyond_api/version.rb +3 -1
- data/lib/beyond_api.rb +3 -1
- data/lib/generators/beyond_api/install_generator.rb +1 -1
- metadata +52 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a98b8f593cfbaa19ab6632cf4abac105bc8b897ebf7b2b34bdbd821dc7eab98e
|
4
|
+
data.tar.gz: 9f4148cc7bb416d661090223d2073a9cffb760f94a153465bb09ea3a1bf3350e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,19 @@
|
|
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
|
+
|
1
17
|
### v0.18.0.pre
|
2
18
|
|
3
19
|
* features
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
beyond_api (0.18.
|
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,6 +74,9 @@ 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
|
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 :
|
9
|
+
task default: :spec
|
8
10
|
|
9
11
|
YARD::Rake::YardocTask.new do |t|
|
10
|
-
|
12
|
+
t.files = ["lib/**/*.rb"]
|
11
13
|
end
|
data/beyond_api.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
lib = File.expand_path("
|
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
|
|
@@ -11,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
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(
|
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",
|
24
|
-
spec.add_development_dependency "
|
25
|
-
spec.add_development_dependency "
|
26
|
-
spec.add_development_dependency "
|
27
|
-
spec.add_development_dependency "
|
28
|
-
spec.add_development_dependency "
|
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?
|
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
|
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[
|
17
|
-
faraday.headers[
|
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,
|
data/lib/beyond_api/error.rb
CHANGED
@@ -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[
|
9
|
-
@details = data[
|
10
|
-
@trace_id = data[
|
11
|
-
@error = data[
|
12
|
-
@error_description = data[
|
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[
|
16
|
+
super(data["message"] || data["error_description"])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/beyond_api/ext.rb
CHANGED
@@ -5,13 +5,13 @@ class Hash
|
|
5
5
|
result = {}
|
6
6
|
each do |key, value|
|
7
7
|
result[yield(key)] = case value
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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]
|
44
|
+
string = string.sub(/^[a-z\d]*/, &:capitalize)
|
45
45
|
else
|
46
|
-
string = string.sub(/^(?:(?=\b|[A-Z_])|\w)
|
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
|
-
|
57
|
-
|
56
|
+
when Hash, Array then elem.camelize_keys
|
57
|
+
else; elem
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
data/lib/beyond_api/request.rb
CHANGED
@@ -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[
|
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[
|
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[
|
38
|
-
request.headers[
|
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,
|
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
|