beyond_api 0.12.0.pre → 0.16.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -1
- data/Gemfile.lock +25 -25
- data/lib/beyond_api.rb +13 -13
- data/lib/beyond_api/connection.rb +7 -0
- data/lib/beyond_api/ext.rb +8 -1
- data/lib/beyond_api/logger.rb +13 -0
- data/lib/beyond_api/resources/payment_method_definitions.rb +175 -0
- data/lib/beyond_api/resources/pickup_options.rb +216 -0
- data/lib/beyond_api/resources/products.rb +7 -10
- data/lib/beyond_api/resources/variations.rb +2 -2
- data/lib/beyond_api/session.rb +10 -0
- data/lib/beyond_api/version.rb +1 -1
- data/lib/generators/templates/beyond_api_initializer.rb +15 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6c559696ebb3e320f0eba53263a1a2e4e1f6122abbee3abb0f9dcdcae0ed51c
|
4
|
+
data.tar.gz: aed55ba3c13a04013d7aa4e7c4fcdea9252f1c93623b982eac53fa8557b098d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7791a721f9b5e8a27e574d93274249e0a7240f2bb2400de235d8d3ab89a07ac133fe15aad399b9af9b305a28e36091f61d3d1fff493bb02e2b30b720955d0947
|
7
|
+
data.tar.gz: 7363458296810b56dbcf80e220a2aad5c04a27c66b1f51e4485a9667ef671368aab1e8ed354b7d8692a4248dfc7ec41fd8bb2c66dc43f2015d5492a14cb8b255
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
### v0.16.0.pre
|
2
|
+
|
3
|
+
* features
|
4
|
+
* Add pickup options methods
|
5
|
+
* `PickupOptions#delete`
|
6
|
+
* `PickupOptions#find`
|
7
|
+
* `PickupOptions#sort`
|
8
|
+
* `PickupOptions#update`
|
9
|
+
|
10
|
+
### v0.15.0.pre
|
11
|
+
|
12
|
+
* features
|
13
|
+
* Add pickup options methods
|
14
|
+
* `PickupOptions#all`
|
15
|
+
* `PickupOptions#create`
|
16
|
+
|
17
|
+
### v0.14.0.pre
|
18
|
+
|
19
|
+
* deprecations
|
20
|
+
* Remove `Products#assign_variation_images_differentiator`
|
21
|
+
|
22
|
+
* features
|
23
|
+
* Add `Products#assign_variation_attribute_as_differentiator`
|
24
|
+
|
25
|
+
### v0.13.0.pre
|
26
|
+
|
27
|
+
* features
|
28
|
+
* Add payment method definitions methods
|
29
|
+
* `PaymentMethodDefinitions#all`
|
30
|
+
* `PaymentMethodDefinitions#create`
|
31
|
+
* `PaymentMethodDefinitions#delete`
|
32
|
+
* `PaymentMethodDefinitions#find`
|
33
|
+
* `PaymentMethodDefinitions#update`
|
34
|
+
* Add possibility to log request `headers` and `bodies`
|
35
|
+
|
36
|
+
### v0.12.1.pre
|
37
|
+
|
38
|
+
* bug-fixes
|
39
|
+
* Fix camelize function for hashes containing arrays
|
40
|
+
|
1
41
|
### v0.12.0.pre
|
2
42
|
|
3
43
|
* features
|
@@ -9,7 +49,7 @@
|
|
9
49
|
* `Locations#update`
|
10
50
|
|
11
51
|
* enhancements
|
12
|
-
* Use `autoload` instead of `require`
|
52
|
+
* Use `autoload` instead of `require`
|
13
53
|
|
14
54
|
### v0.11.1.pre
|
15
55
|
|
data/Gemfile.lock
CHANGED
@@ -1,42 +1,42 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
beyond_api (0.
|
4
|
+
beyond_api (0.16.0.pre)
|
5
5
|
faraday (~> 0.15)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
coderay (1.1.
|
11
|
-
concurrent-ruby (1.1.
|
12
|
-
diff-lcs (1.
|
13
|
-
dotenv (2.7.
|
14
|
-
faker (2.
|
15
|
-
i18n (
|
16
|
-
faraday (0.17.
|
10
|
+
coderay (1.1.3)
|
11
|
+
concurrent-ruby (1.1.9)
|
12
|
+
diff-lcs (1.4.4)
|
13
|
+
dotenv (2.7.6)
|
14
|
+
faker (2.18.0)
|
15
|
+
i18n (>= 1.6, < 2)
|
16
|
+
faraday (0.17.4)
|
17
17
|
multipart-post (>= 1.2, < 3)
|
18
|
-
i18n (1.
|
18
|
+
i18n (1.8.10)
|
19
19
|
concurrent-ruby (~> 1.0)
|
20
|
-
method_source (0.
|
20
|
+
method_source (1.0.0)
|
21
21
|
multipart-post (2.1.1)
|
22
|
-
pry (0.
|
23
|
-
coderay (~> 1.1
|
24
|
-
method_source (~>
|
22
|
+
pry (0.14.1)
|
23
|
+
coderay (~> 1.1)
|
24
|
+
method_source (~> 1.0)
|
25
25
|
rake (10.5.0)
|
26
|
-
rspec (3.
|
27
|
-
rspec-core (~> 3.
|
28
|
-
rspec-expectations (~> 3.
|
29
|
-
rspec-mocks (~> 3.
|
30
|
-
rspec-core (3.
|
31
|
-
rspec-support (~> 3.
|
32
|
-
rspec-expectations (3.
|
26
|
+
rspec (3.10.0)
|
27
|
+
rspec-core (~> 3.10.0)
|
28
|
+
rspec-expectations (~> 3.10.0)
|
29
|
+
rspec-mocks (~> 3.10.0)
|
30
|
+
rspec-core (3.10.1)
|
31
|
+
rspec-support (~> 3.10.0)
|
32
|
+
rspec-expectations (3.10.1)
|
33
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-mocks (3.
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-mocks (3.10.2)
|
36
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-support (3.
|
39
|
-
yard (0.9.
|
37
|
+
rspec-support (~> 3.10.0)
|
38
|
+
rspec-support (3.10.2)
|
39
|
+
yard (0.9.26)
|
40
40
|
|
41
41
|
PLATFORMS
|
42
42
|
ruby
|
data/lib/beyond_api.rb
CHANGED
@@ -1,23 +1,18 @@
|
|
1
1
|
require "beyond_api/version"
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "beyond_api/request"
|
5
|
-
require "beyond_api/session"
|
6
|
-
require "beyond_api/error"
|
3
|
+
require "logger"
|
7
4
|
|
8
5
|
require "beyond_api/ext"
|
9
6
|
require "beyond_api/utils"
|
10
7
|
|
11
|
-
require "logger"
|
12
|
-
|
13
8
|
module BeyondApi
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
autoload :Connection, "beyond_api/connection"
|
10
|
+
autoload :Error, "beyond_api/error"
|
11
|
+
autoload :Logger, "beyond_api/logger"
|
12
|
+
autoload :Request, "beyond_api/request"
|
13
|
+
autoload :Session, "beyond_api/session"
|
17
14
|
|
18
|
-
|
19
|
-
@@logger = logger
|
20
|
-
end
|
15
|
+
extend BeyondApi::Logger
|
21
16
|
|
22
17
|
class << self
|
23
18
|
attr_accessor :configuration
|
@@ -31,7 +26,8 @@ module BeyondApi
|
|
31
26
|
|
32
27
|
class Configuration
|
33
28
|
attr_accessor :client_id, :client_secret, :open_timeout, :timeout, :remove_response_links,
|
34
|
-
:remove_response_key_underscores, :object_struct_responses, :raise_error_requests
|
29
|
+
:remove_response_key_underscores, :object_struct_responses, :raise_error_requests,
|
30
|
+
:log_headers, :log_bodies, :log_level
|
35
31
|
|
36
32
|
def initialize
|
37
33
|
@client_id = nil
|
@@ -42,6 +38,10 @@ module BeyondApi
|
|
42
38
|
@remove_response_key_underscores = false
|
43
39
|
@object_struct_responses = false
|
44
40
|
@raise_error_requests = false
|
41
|
+
|
42
|
+
@log_level = :info
|
43
|
+
@log_headers = false
|
44
|
+
@log_bodies = false
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -4,10 +4,15 @@ require 'faraday'
|
|
4
4
|
|
5
5
|
module BeyondApi
|
6
6
|
class Connection
|
7
|
+
LOGGER = ::BeyondApi.logger
|
8
|
+
LOGGER.level = Kernel.const_get("::Logger::#{BeyondApi.configuration.log_level.to_s.upcase}")
|
9
|
+
|
7
10
|
def self.default
|
8
11
|
Faraday.new(ssl: { verify: true }) do |faraday|
|
9
12
|
faraday.options[:open_timeout] = BeyondApi.configuration.open_timeout.to_i
|
10
13
|
faraday.options[:timeout] = BeyondApi.configuration.timeout.to_i
|
14
|
+
faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers,
|
15
|
+
bodies: BeyondApi.configuration.log_bodies }
|
11
16
|
faraday.headers['Accept'] = 'application/json'
|
12
17
|
faraday.headers['Content-Type'] = 'application/json'
|
13
18
|
faraday.request(:multipart)
|
@@ -20,6 +25,8 @@ module BeyondApi
|
|
20
25
|
Faraday.new(ssl: { verify: true }) do |faraday|
|
21
26
|
faraday.options[:open_timeout] = BeyondApi.configuration.open_timeout.to_i
|
22
27
|
faraday.options[:timeout] = BeyondApi.configuration.timeout.to_i
|
28
|
+
faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers,
|
29
|
+
bodies: BeyondApi.configuration.log_bodies }
|
23
30
|
faraday.headers['Accept'] = 'application/json'
|
24
31
|
faraday.adapter(:net_http)
|
25
32
|
faraday.basic_auth(BeyondApi.configuration.client_id,
|
data/lib/beyond_api/ext.rb
CHANGED
@@ -4,7 +4,14 @@ class Hash
|
|
4
4
|
def deep_transform_keys(&block)
|
5
5
|
result = {}
|
6
6
|
each do |key, value|
|
7
|
-
result[yield(key)] =
|
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
15
|
end
|
9
16
|
result
|
10
17
|
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
5
|
+
module BeyondApi
|
6
|
+
class PaymentMethodDefinitions < Base
|
7
|
+
include BeyondApi::Utils
|
8
|
+
|
9
|
+
#
|
10
|
+
# A +POST+ request is used to create a payment method definition on system level.
|
11
|
+
#
|
12
|
+
# $ curl 'https://system.beyondshop.cloud/api/payment-method-definitions' -i -X POST \
|
13
|
+
# -H 'Content-Type: application/json' \
|
14
|
+
# -H 'Accept: application/hal+json' \
|
15
|
+
# -H 'Authorization: Bearer <Access token>' \
|
16
|
+
# -d '{
|
17
|
+
# "name": "credit-card",
|
18
|
+
# "referralUriTemplate": "https://example.com/merchants",
|
19
|
+
# "statusUriTemplate": "https://example.com/merchants/{shopId}/status",
|
20
|
+
# "disconnectUriTemplate": "https://example.com/merchants/{shopId}/disconnect",
|
21
|
+
# "createPaymentUriTemplate": "https://example.com/payments",
|
22
|
+
# "capturePaymentUriTemplate": "https://example.com/payments/{paymentId}/capture",
|
23
|
+
# "refundPaymentUriTemplate": "https://example.com/payments/{paymentId}/refund",
|
24
|
+
# "sandbox": "true",
|
25
|
+
# "workflow": "PAYMENT_ON_BUY",
|
26
|
+
# "captureWorkflow": "CAPTURE_ON_ORDER",
|
27
|
+
# "refund": "NO_REFUND",
|
28
|
+
# "logos": [{
|
29
|
+
# "setName" : "official",
|
30
|
+
# "variant" : "STOREFRONT",
|
31
|
+
# "uri" : "https://example.com/static/storefront.png"
|
32
|
+
# }],
|
33
|
+
# "officialName": {"de-DE" : "Ermögliche deinen Kunden, mit Kreditkarte zu bezahlen.",
|
34
|
+
# "en-US" : "Allow your customers to pay by credit card."
|
35
|
+
# },
|
36
|
+
# "officialDescription": {
|
37
|
+
# "de-DE" : "Ermögliche deinen Kunden, mit Kreditkarte zu bezahlen.",
|
38
|
+
# "en-US" : "Allow your customers to pay by credit card."
|
39
|
+
# },
|
40
|
+
# "defaultName": {
|
41
|
+
# "de-DE" : "Kreditkarte",
|
42
|
+
# "en-US" : "Credit card"
|
43
|
+
# },
|
44
|
+
# "defaultDescription": {"de-DE" : "Bezahlen Sie mit Kreditkarte.","en-US" : "Pay by credit card."}}'
|
45
|
+
#
|
46
|
+
# @beyond_api.scopes +paym:m+
|
47
|
+
#
|
48
|
+
# @param body [Hash] the request body
|
49
|
+
#
|
50
|
+
# @return [OpenStruct]
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# @payment_method_definitions = session.payment_method_definitions.create(body)
|
54
|
+
#
|
55
|
+
def create(body)
|
56
|
+
response, status = BeyondApi::Request.post(@session, "/payment-method-definitions", body)
|
57
|
+
|
58
|
+
handle_response(response, status)
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# A +GET+ request is used to list all payment method definitions on system level.
|
63
|
+
#
|
64
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/payment-method-definitions' -i -X GET \
|
65
|
+
# -H 'Accept: application/hal+json' \
|
66
|
+
# -H 'Authorization: Bearer <Access token>'
|
67
|
+
#
|
68
|
+
# @beyond_api.scopes +paym:m+
|
69
|
+
#
|
70
|
+
# @option params [Boolean] :paginated
|
71
|
+
# @option params [Integer] :size the page size
|
72
|
+
# @option params [Integer] :page the page number
|
73
|
+
#
|
74
|
+
# @return [OpenStruct]
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# @payment_method_definitions = session.payment_method_definitions.all(size: 100, page: 0)
|
78
|
+
#
|
79
|
+
def all(params = {})
|
80
|
+
handle_all_request("/payment-method-definitions", :payment_method_definitions, params)
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# A +GET+ request is used to deactivate a payment method.
|
85
|
+
#
|
86
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/payment-method-definitions/credit-card' -i -X GET \
|
87
|
+
# -H 'Accept: application/hal+json' \
|
88
|
+
# -H 'Authorization: Bearer <Access token>'
|
89
|
+
#
|
90
|
+
# @beyond_api.scopes +pymt:u+
|
91
|
+
#
|
92
|
+
# @param payment_method_definition_id [String] the payment method definition UUID
|
93
|
+
#
|
94
|
+
# @return [OpenStruct]
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# @payment_method_definition = session.payment_methods.find("credit-card")
|
98
|
+
#
|
99
|
+
def find(payment_method_definition_id)
|
100
|
+
response, status = BeyondApi::Request.get(@session, "/payment-method-definitions/#{payment_method_definition_id}")
|
101
|
+
|
102
|
+
handle_response(response, status)
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# A +PUT+ request is used to update a payment method definition on system level.
|
107
|
+
#
|
108
|
+
# $ curl 'https://system.beyondshop.cloud/api/payment-method-definitions/credit-card' -i -X PUT \
|
109
|
+
# -H 'Content-Type: application/json' \
|
110
|
+
# -H 'Accept: application/hal+json' \
|
111
|
+
# -H 'Authorization: Bearer <Access token>' \
|
112
|
+
# -d '{
|
113
|
+
# "name": "credit-card-updated",
|
114
|
+
# "referralUriTemplate": "https://example.com/merchants",
|
115
|
+
# "statusUriTemplate": "https://example.com/merchants/{shopId}/status",
|
116
|
+
# "disconnectUriTemplate": "https://example.com/merchants/{shopId}/disconnect",
|
117
|
+
# "createPaymentUriTemplate": "https://example.com/payments",
|
118
|
+
# "capturePaymentUriTemplate": "https://example.com/payments/{paymentId}/capture",
|
119
|
+
# "refundPaymentUriTemplate": "https://example.com/payments/{paymentId}/refund",
|
120
|
+
# "workflow": "PAYMENT_ON_SELECTION",
|
121
|
+
# "captureWorkflow": "CAPTURE_ON_DEMAND",
|
122
|
+
# "refund": "NO_REFUND",
|
123
|
+
# "logos": [{
|
124
|
+
# "setName" : "official",
|
125
|
+
# "variant" : "STOREFRONT",
|
126
|
+
# "uri" : "https://example.com/static/storefront.png"
|
127
|
+
# }],
|
128
|
+
# "officialName": {"de-DE" : "Ermögliche deinen Kunden, mit Kreditkarte zu bezahlen.",
|
129
|
+
# "en-US" : "Allow your customers to pay by credit card."
|
130
|
+
# },
|
131
|
+
# "officialDescription": {
|
132
|
+
# "de-DE" : "Ermögliche deinen Kunden, mit Kreditkarte zu bezahlen.",
|
133
|
+
# "en-US" : "Allow your customers to pay by credit card."
|
134
|
+
# },
|
135
|
+
# "defaultName": {
|
136
|
+
# "de-DE" : "Kreditkarte",
|
137
|
+
# "en-US" : "Credit card"
|
138
|
+
# },
|
139
|
+
# "defaultDescription": {"de-DE" : "Bezahlen Sie mit Kreditkarte.","en-US" : "Pay by credit card."}}'
|
140
|
+
#
|
141
|
+
# @beyond_api.scopes +paym:m+
|
142
|
+
#
|
143
|
+
# @param payment_method_definition_id [String] the payment method definition UUID
|
144
|
+
# @param body [Hash] the request body
|
145
|
+
#
|
146
|
+
# @return [OpenStruct]
|
147
|
+
#
|
148
|
+
# @example
|
149
|
+
# @payment_method_definition = session.payment_method_definitions.update("credit_card", body)
|
150
|
+
#
|
151
|
+
def update(payment_method_definition_id, body)
|
152
|
+
response, status = BeyondApi::Request.put(@session, "/payment-method-definitions/#{payment_method_definition_id}")
|
153
|
+
|
154
|
+
handle_response(response, status)
|
155
|
+
end
|
156
|
+
|
157
|
+
#
|
158
|
+
# A +DELETE+ request is used to delete a payment method definition on system level.
|
159
|
+
#
|
160
|
+
# $ curl 'https://system.beyondshop.cloud/api/payment-method-definitions/credit-card' -i -X DELETE \
|
161
|
+
# -H 'Accept: application/hal+json' \
|
162
|
+
# -H 'Authorization: Bearer <Access token>'
|
163
|
+
#
|
164
|
+
# @return true
|
165
|
+
#
|
166
|
+
# @example
|
167
|
+
# session.payment_method_definitions.delete("credit-card")
|
168
|
+
#
|
169
|
+
def delete(payment_method_definition_id)
|
170
|
+
response, status = BeyondApi::Request.delete(@session, "/payment-method-definitions/#{payment_method_definition_id}", body)
|
171
|
+
|
172
|
+
handle_response(response, status, respond_with_true: true)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
5
|
+
module BeyondApi
|
6
|
+
class PickupOptions < Base
|
7
|
+
include BeyondApi::Utils
|
8
|
+
|
9
|
+
#
|
10
|
+
# A +GET+ request is used to list all pickup options of the shop in a paged way.
|
11
|
+
#
|
12
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X GET \
|
13
|
+
# -H 'Accept: application/hal+json' \
|
14
|
+
# -H 'Authorization: Bearer <Access token>'
|
15
|
+
#
|
16
|
+
# @option params [Boolean] :paginated
|
17
|
+
# @option params [Integer] :size the page size
|
18
|
+
# @option params [Integer] :page the page number
|
19
|
+
#
|
20
|
+
# @return [OpenStruct]
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# @pickup_options = session.pickup_options.all(size: 100, page: 0)
|
24
|
+
#
|
25
|
+
def all(params = {})
|
26
|
+
handle_all_request("/pickup-options", :pickup_options, params)
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# A +POST+ request is used to create a pickup option.
|
31
|
+
#
|
32
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X POST \
|
33
|
+
# -H 'Content-Type: application/json' \
|
34
|
+
# -H 'Authorization: Bearer <Access token>' \
|
35
|
+
# -d '{
|
36
|
+
# "name" : "My little Cornershop - St.Ives",
|
37
|
+
# "description" : "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
|
38
|
+
# "taxClass" : "REGULAR",
|
39
|
+
# "freePickupValue" : {
|
40
|
+
# "currency" : "EUR",
|
41
|
+
# "amount" : 50
|
42
|
+
# },
|
43
|
+
# "fixedPrice" : {
|
44
|
+
# "taxModel" : "GROSS",
|
45
|
+
# "currency" : "EUR",
|
46
|
+
# "amount" : 1
|
47
|
+
# },
|
48
|
+
# "phoneNumberRequired" : true,
|
49
|
+
# "locationId" : "cb554eb6-2768-4491-afd2-6bcd0aec0937"
|
50
|
+
# }'
|
51
|
+
#
|
52
|
+
# @beyond_api.scopes +shpz:c+
|
53
|
+
#
|
54
|
+
# @param body [Hash] the request body
|
55
|
+
#
|
56
|
+
# @return [OpenStruct]
|
57
|
+
#
|
58
|
+
# @example
|
59
|
+
# body = {
|
60
|
+
# name: "My little Cornershop - St.Ives",
|
61
|
+
# description: "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
|
62
|
+
# tax_class: "REGULAR",
|
63
|
+
# free_pickup_value: {
|
64
|
+
# currency: "EUR",
|
65
|
+
# amount: 50
|
66
|
+
# },
|
67
|
+
# fixed_price: {
|
68
|
+
# tax_model: "GROSS",
|
69
|
+
# currency: "EUR",
|
70
|
+
# amount: 1
|
71
|
+
# },
|
72
|
+
# phone_number_required: true,
|
73
|
+
# location_id: "cb554eb6-2768-4491-afd2-6bcd0aec0937"
|
74
|
+
# }
|
75
|
+
#
|
76
|
+
# @pickup_option = session.pickup_options.create(body)
|
77
|
+
#
|
78
|
+
def create(body)
|
79
|
+
response, status = BeyondApi::Request.post(@session, "/pickup-options", body)
|
80
|
+
|
81
|
+
handle_response(response, status)
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# A +DELETE+ request is used to delete a pickup option.
|
86
|
+
#
|
87
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/pickup-options/d253a31b-3892-4196-ae16-c5d8d6b05791' -i -X DELETE
|
88
|
+
#
|
89
|
+
# @beyond_api.scopes +shpz:d+
|
90
|
+
#
|
91
|
+
# @param pickup_option_id [String] the pickup option UUID
|
92
|
+
#
|
93
|
+
# @return true
|
94
|
+
#
|
95
|
+
# @example
|
96
|
+
# session.pickup_options.delete("d253a31b-3892-4196-ae16-c5d8d6b05791")
|
97
|
+
#
|
98
|
+
def delete(pickup_option_id)
|
99
|
+
response, status = BeyondApi::Request.delete(@session, "/pickup-options/#{pickup_option_id}")
|
100
|
+
|
101
|
+
handle_response(response, status, respond_with_true: true)
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
# A +GET+ request is used to retrieve the details of a pickup option.
|
106
|
+
#
|
107
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/pickup-options/76302c10-761f-43c1-9d18-52ad16bd52e8' -i -X GET \
|
108
|
+
# -H 'Content-Type: application/json' \
|
109
|
+
# -H 'Accept: application/hal+json' \
|
110
|
+
# -H 'Authorization: Bearer <Access token>'
|
111
|
+
#
|
112
|
+
# @beyond_api.scopes +shpz:r+
|
113
|
+
#
|
114
|
+
# @param pickup_option_id [String] the pickup option UUID
|
115
|
+
#
|
116
|
+
# @return [OpenStruct]
|
117
|
+
#
|
118
|
+
# @example
|
119
|
+
# @pickup_option = session.pickup_options.find("76302c10-761f-43c1-9d18-52ad16bd52e8")
|
120
|
+
#
|
121
|
+
def find(pickup_option_id)
|
122
|
+
response, status = BeyondApi::Request.get(@session, "/pickup-options/#{pickup_option_id}")
|
123
|
+
|
124
|
+
handle_response(response, status)
|
125
|
+
end
|
126
|
+
|
127
|
+
#
|
128
|
+
# A +PUT+ request is used to sort the pickup options. This is done by passing the self-links of the pickup options in the desired order. The request must contain URIs for all pickup options of the given page.
|
129
|
+
#
|
130
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X PUT \
|
131
|
+
# -H 'Content-Type: text/uri-list' \
|
132
|
+
# -H 'Authorization: Bearer <Access token>' \
|
133
|
+
# -d 'https://api-shop.beyondshop.cloud/api/pickup-options/bff3673f-91c1-4e09-a8ab-562a3a553fac
|
134
|
+
# https://api-shop.beyondshop.cloud/api/pickup-options/7b4d36fc-ac0f-44a3-8655-f2bd05c2a42d
|
135
|
+
# https://api-shop.beyondshop.cloud/api/pickup-options/630b63ee-c7d8-4953-9b7c-c874fd795154'
|
136
|
+
#
|
137
|
+
# @beyond_api.scopes +shpz:u+
|
138
|
+
#
|
139
|
+
# @param pickup_option_ids [Array] the pickup option UUIDs
|
140
|
+
#
|
141
|
+
# @return [OpenStruct]
|
142
|
+
#
|
143
|
+
# @example
|
144
|
+
# pickup_option_ids = [
|
145
|
+
# "bff3673f-91c1-4e09-a8ab-562a3a553fac",
|
146
|
+
# "7b4d36fc-ac0f-44a3-8655-f2bd05c2a42d",
|
147
|
+
# "630b63ee-c7d8-4953-9b7c-c874fd795154"
|
148
|
+
# ]
|
149
|
+
#
|
150
|
+
# session.pickup_options.sort(pickup_option_ids)
|
151
|
+
#
|
152
|
+
def sort(pickup_option_ids)
|
153
|
+
body = pickup_option_ids.map { |id| "#{@session.api_url}/pickup-options/#{id}" }
|
154
|
+
response, status = BeyondApi::Request.put(@session, "/pickup-options", body)
|
155
|
+
|
156
|
+
handle_response(response, status, respond_with_true: true)
|
157
|
+
end
|
158
|
+
|
159
|
+
#
|
160
|
+
# A +PUT+ request is used to update a pickup option.
|
161
|
+
#
|
162
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/pickup-options/5765b837-db5b-49a9-a659-68d00376e42a' -i -X PUT \
|
163
|
+
# -H 'Content-Type: application/json' \
|
164
|
+
# -H 'Accept: application/hal+json' \
|
165
|
+
# -H 'Authorization: Bearer <Access token>' \
|
166
|
+
# -d '{
|
167
|
+
# "name" : "New name",
|
168
|
+
# "description" : "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
|
169
|
+
# "taxClass" : "REGULAR",
|
170
|
+
# "freePickupValue" : {
|
171
|
+
# "currency" : "EUR",
|
172
|
+
# "amount" : 50
|
173
|
+
# },
|
174
|
+
# "fixedPrice" : {
|
175
|
+
# "taxModel" : "GROSS",
|
176
|
+
# "currency" : "EUR",
|
177
|
+
# "amount" : 1
|
178
|
+
# },
|
179
|
+
# "phoneNumberRequired" : true,
|
180
|
+
# "locationId" : "c9179393-abcc-450a-8cf4-875b39647ab6"
|
181
|
+
# }'
|
182
|
+
#
|
183
|
+
# @beyond_api.scopes +shpz:u+
|
184
|
+
#
|
185
|
+
# @param pickup_option_id [String] the pickup option UUID
|
186
|
+
# @param body [Hash] the request body
|
187
|
+
#
|
188
|
+
# @return [OpenStruct]
|
189
|
+
#
|
190
|
+
# @example
|
191
|
+
# body = {
|
192
|
+
# name: "New name",
|
193
|
+
# description: "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
|
194
|
+
# tax_class: "REGULAR",
|
195
|
+
# free_pickup_value: {
|
196
|
+
# currency: "EUR",
|
197
|
+
# amount: 50
|
198
|
+
# },
|
199
|
+
# fixed_price: {
|
200
|
+
# tax_model: "GROSS",
|
201
|
+
# currency: "EUR",
|
202
|
+
# amount: 1
|
203
|
+
# },
|
204
|
+
# phone_number_required: true,
|
205
|
+
# location_id: "c9179393-abcc-450a-8cf4-875b39647ab6"
|
206
|
+
# }
|
207
|
+
#
|
208
|
+
# @pickup_option = session.pickup_options.update("5765b837-db5b-49a9-a659-68d00376e42a", body)
|
209
|
+
#
|
210
|
+
def update(pickup_option_id, body)
|
211
|
+
response, status = BeyondApi::Request.put(@session, "/pickup-options/#{pickup_option_id}", body)
|
212
|
+
|
213
|
+
handle_response(response, status)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
@@ -253,28 +253,25 @@ module BeyondApi
|
|
253
253
|
end
|
254
254
|
|
255
255
|
#
|
256
|
-
# A +
|
256
|
+
# A +POST+ request is used to assign a variation attribute as the variation images differentiator for a variation product.
|
257
257
|
#
|
258
258
|
# @beyond_api.scopes +prod:u+
|
259
259
|
#
|
260
|
-
# $ curl 'https://api-shop.beyondshop.cloud/api/products/
|
260
|
+
# $ curl 'https://api-shop.beyondshop.cloud/api/products/f205294b-17dc-4f75-8b5e-5df72abb96df/variation-attributes/491fedf4-37a9-4bcf-98b8-cff2f82879b7/make-differentiator' -i -X POST \
|
261
261
|
# -H 'Content-Type: application/hal+json' \
|
262
262
|
# -H 'Accept: application/hal+json' \
|
263
|
-
# -H 'Authorization: Bearer <Access token>'
|
264
|
-
# -d '{
|
265
|
-
# "differentiator" : "size"
|
266
|
-
# }'
|
263
|
+
# -H 'Authorization: Bearer <Access token>'
|
267
264
|
#
|
268
265
|
# @param product_id [String] the product UUID
|
269
|
-
# @param
|
266
|
+
# @param variation_attribute_id [String] the variation attribute UUID
|
270
267
|
#
|
271
268
|
# @return [true]
|
272
269
|
#
|
273
270
|
# @example
|
274
|
-
# session.products.assign_variation_images_differentiator("
|
271
|
+
# session.products.assign_variation_images_differentiator("f205294b-17dc-4f75-8b5e-5df72abb96df", "491fedf4-37a9-4bcf-98b8-cff2f82879b7")
|
275
272
|
#
|
276
|
-
def
|
277
|
-
response, status = BeyondApi::Request.
|
273
|
+
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")
|
278
275
|
|
279
276
|
handle_response(response, status, respond_with_true: true)
|
280
277
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
require "beyond_api/utils"
|
4
4
|
|
5
5
|
module BeyondApi
|
6
|
-
autoload :
|
7
|
-
autoload :
|
6
|
+
autoload :VariationImages, "beyond_api/resources/variations/images"
|
7
|
+
autoload :VariationAvailability, "beyond_api/resources/variations/availability"
|
8
8
|
|
9
9
|
class Variations < Base
|
10
10
|
include BeyondApi::VariationImages
|
data/lib/beyond_api/session.rb
CHANGED
@@ -10,6 +10,8 @@ module BeyondApi
|
|
10
10
|
autoload :NewsletterTarget, "beyond_api/resources/newsletter_target"
|
11
11
|
autoload :OrderSettings, "beyond_api/resources/order_settings"
|
12
12
|
autoload :Orders, "beyond_api/resources/orders"
|
13
|
+
autoload :PaymentMethodDefinitions, "beyond_api/resources/payment_method_definitions"
|
14
|
+
autoload :PickupOptions, "beyond_api/resources/pickup_options"
|
13
15
|
autoload :PaymentMethods, "beyond_api/resources/payment_methods"
|
14
16
|
autoload :ProductAttributeDefinitions, "beyond_api/resources/product_attribute_definitions"
|
15
17
|
autoload :ProductsView, "beyond_api/resources/products_view"
|
@@ -65,10 +67,18 @@ module BeyondApi
|
|
65
67
|
BeyondApi::Orders.new(self)
|
66
68
|
end
|
67
69
|
|
70
|
+
def payment_method_definitions
|
71
|
+
BeyondApi::PaymentMethodDefinitions.new(self)
|
72
|
+
end
|
73
|
+
|
68
74
|
def payment_methods
|
69
75
|
BeyondApi::PaymentMethods.new(self)
|
70
76
|
end
|
71
77
|
|
78
|
+
def pickup_options
|
79
|
+
BeyondApi::PickupOptions.new(self)
|
80
|
+
end
|
81
|
+
|
72
82
|
def product_attribute_definitions
|
73
83
|
BeyondApi::ProductAttributeDefinitions.new(self)
|
74
84
|
end
|
data/lib/beyond_api/version.rb
CHANGED
@@ -12,6 +12,21 @@ BeyondApi.setup do |config|
|
|
12
12
|
# Configure the request timeout in seconds. Default is 5 seconds.
|
13
13
|
# config.timeout = 5.seconds
|
14
14
|
|
15
|
+
# ==> Log configuration
|
16
|
+
|
17
|
+
# Configure the log level. Must be one of :debug, :info, :warn, :error,
|
18
|
+
# :fatal or :unknown. Default is :info.
|
19
|
+
#
|
20
|
+
# config.log_level = :info
|
21
|
+
|
22
|
+
# Configure is response headers should be logged. Default is false.
|
23
|
+
#
|
24
|
+
# config.log_headers = false
|
25
|
+
|
26
|
+
# Configure is response bodies should be logged. Default is false.
|
27
|
+
#
|
28
|
+
# config.log_bodies = false
|
29
|
+
|
15
30
|
# ==> Response configuration
|
16
31
|
# Configure if :_links should be removed from response. Default is false and
|
17
32
|
# :_links are gonna be part of the response.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beyond_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unai Abrisketa
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-06-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/beyond_api/connection.rb
|
136
136
|
- lib/beyond_api/error.rb
|
137
137
|
- lib/beyond_api/ext.rb
|
138
|
+
- lib/beyond_api/logger.rb
|
138
139
|
- lib/beyond_api/request.rb
|
139
140
|
- lib/beyond_api/resources/base.rb
|
140
141
|
- lib/beyond_api/resources/carts.rb
|
@@ -145,7 +146,9 @@ files:
|
|
145
146
|
- lib/beyond_api/resources/newsletter_target.rb
|
146
147
|
- lib/beyond_api/resources/order_settings.rb
|
147
148
|
- lib/beyond_api/resources/orders.rb
|
149
|
+
- lib/beyond_api/resources/payment_method_definitions.rb
|
148
150
|
- lib/beyond_api/resources/payment_methods.rb
|
151
|
+
- lib/beyond_api/resources/pickup_options.rb
|
149
152
|
- lib/beyond_api/resources/product_attribute_definitions.rb
|
150
153
|
- lib/beyond_api/resources/products.rb
|
151
154
|
- lib/beyond_api/resources/products/attachments.rb
|
@@ -195,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
198
|
- !ruby/object:Gem::Version
|
196
199
|
version: 1.3.1
|
197
200
|
requirements: []
|
198
|
-
rubygems_version: 3.
|
201
|
+
rubygems_version: 3.0.3
|
199
202
|
signing_key:
|
200
203
|
specification_version: 4
|
201
204
|
summary: Ruby client to access the Beyond API
|