beyond_api 0.12.1.pre → 0.13.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +1 -1
- data/lib/beyond_api.rb +13 -13
- data/lib/beyond_api/connection.rb +7 -0
- data/lib/beyond_api/logger.rb +13 -0
- data/lib/beyond_api/resources/payment_method_definitions.rb +175 -0
- data/lib/beyond_api/session.rb +5 -0
- data/lib/beyond_api/version.rb +1 -1
- data/lib/generators/templates/beyond_api_initializer.rb +15 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be322cd30437303093e481de07cd8e3b8809c381d835b778ca03eccf66f7326f
|
4
|
+
data.tar.gz: 432767a471613ab986f3ca19c5c8c002673711bea0c71ec0c8048fbf4f8cc50e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8a52e79a30aa30c85388b0d0d034fd49e35ce4896eef7ae0b51316aa7a3c1081ef3b9b564b1ec798be8af4af44d04b6bcefc226579b44138a98d1b463e23a65
|
7
|
+
data.tar.gz: 98be15b4608be4c35f0e9511cde6f824a2dfd97a292c92e62a24f2980750464a62952e4d84852c367df3258a7bc8036434162252e40993b089fa8fa72ca11dec
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
### v0.13.0.pre
|
2
|
+
|
3
|
+
* features
|
4
|
+
* Add payment method definitions methods
|
5
|
+
* `PaymentMethodDefinitions#all`
|
6
|
+
* `PaymentMethodDefinitions#create`
|
7
|
+
* `PaymentMethodDefinitions#delete`
|
8
|
+
* `PaymentMethodDefinitions#find`
|
9
|
+
* `PaymentMethodDefinitions#update`
|
10
|
+
* Add possibility to log request `headers` and `bodies`
|
11
|
+
|
1
12
|
### v0.12.1.pre
|
2
13
|
|
3
14
|
* bug-fixes
|
@@ -14,7 +25,7 @@
|
|
14
25
|
* `Locations#update`
|
15
26
|
|
16
27
|
* enhancements
|
17
|
-
* Use `autoload` instead of `require`
|
28
|
+
* Use `autoload` instead of `require`
|
18
29
|
|
19
30
|
### v0.11.1.pre
|
20
31
|
|
data/Gemfile.lock
CHANGED
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,
|
@@ -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
|
data/lib/beyond_api/session.rb
CHANGED
@@ -10,6 +10,7 @@ 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"
|
13
14
|
autoload :PaymentMethods, "beyond_api/resources/payment_methods"
|
14
15
|
autoload :ProductAttributeDefinitions, "beyond_api/resources/product_attribute_definitions"
|
15
16
|
autoload :ProductsView, "beyond_api/resources/products_view"
|
@@ -65,6 +66,10 @@ module BeyondApi
|
|
65
66
|
BeyondApi::Orders.new(self)
|
66
67
|
end
|
67
68
|
|
69
|
+
def payment_method_definitions
|
70
|
+
BeyondApi::PaymentMethodDefinitions.new(self)
|
71
|
+
end
|
72
|
+
|
68
73
|
def payment_methods
|
69
74
|
BeyondApi::PaymentMethods.new(self)
|
70
75
|
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.13.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: 2020-
|
13
|
+
date: 2020-10-19 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,6 +146,7 @@ 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
|
149
151
|
- lib/beyond_api/resources/product_attribute_definitions.rb
|
150
152
|
- lib/beyond_api/resources/products.rb
|
@@ -195,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
197
|
- !ruby/object:Gem::Version
|
196
198
|
version: 1.3.1
|
197
199
|
requirements: []
|
198
|
-
rubygems_version: 3.
|
200
|
+
rubygems_version: 3.1.2
|
199
201
|
signing_key:
|
200
202
|
specification_version: 4
|
201
203
|
summary: Ruby client to access the Beyond API
|