minato_ruby_api_client 0.2.1 → 0.2.3
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 +23 -23
- data/Dockerfile +1 -1
- data/Gemfile +17 -17
- data/Gemfile.lock +402 -398
- data/README.md +54 -54
- data/Rakefile +10 -10
- data/compose.yml +11 -11
- data/lib/minato_ruby_api_client/api_client.rb +398 -389
- data/lib/minato_ruby_api_client/api_error.rb +16 -16
- data/lib/minato_ruby_api_client/configuration.rb +247 -247
- data/lib/minato_ruby_api_client/version.rb +3 -3
- data/lib/minato_ruby_api_client.rb +24 -24
- data/minato_ruby_api_client.gemspec +35 -35
- data/spec/api_client_spec.rb +42 -0
- data/spec/configuration_spec.rb +204 -204
- data/spec/minato_ruby_api_client_spec.rb +17 -17
- data/spec/spec_helper.rb +105 -105
- metadata +7 -40
- data/coverage/.last_run.json +0 -5
- data/coverage/.resultset.json +0 -1248
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_both.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
- data/coverage/assets/0.12.3/application.css +0 -1
- data/coverage/assets/0.12.3/application.js +0 -7
- data/coverage/assets/0.12.3/colorbox/border.png +0 -0
- data/coverage/assets/0.12.3/colorbox/controls.png +0 -0
- data/coverage/assets/0.12.3/colorbox/loading.gif +0 -0
- data/coverage/assets/0.12.3/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.12.3/favicon_green.png +0 -0
- data/coverage/assets/0.12.3/favicon_red.png +0 -0
- data/coverage/assets/0.12.3/favicon_yellow.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/assets/0.12.3/loading.gif +0 -0
- data/coverage/assets/0.12.3/magnify.png +0 -0
- data/coverage/index.html +0 -13728
@@ -1,16 +1,16 @@
|
|
1
|
-
require 'minato_error_handler'
|
2
|
-
|
3
|
-
module MinatoRubyApiClient
|
4
|
-
class ApiError < MinatoErrorHandler::Errors::ExternalError
|
5
|
-
attr_reader :status_code
|
6
|
-
|
7
|
-
def initialize(res: nil, req: nil, status_code: 500)
|
8
|
-
super(req: req, res: res)
|
9
|
-
@status_code = status_code
|
10
|
-
end
|
11
|
-
|
12
|
-
def message
|
13
|
-
"An error occurred while communicating with the API."
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
require 'minato_error_handler'
|
2
|
+
|
3
|
+
module MinatoRubyApiClient
|
4
|
+
class ApiError < MinatoErrorHandler::Errors::ExternalError
|
5
|
+
attr_reader :status_code
|
6
|
+
|
7
|
+
def initialize(res: nil, req: nil, status_code: 500)
|
8
|
+
super(req: req, res: res)
|
9
|
+
@status_code = status_code
|
10
|
+
end
|
11
|
+
|
12
|
+
def message
|
13
|
+
"An error occurred while communicating with the API."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,247 +1,247 @@
|
|
1
|
-
module MinatoRubyApiClient
|
2
|
-
class Configuration
|
3
|
-
# Defines url scheme
|
4
|
-
attr_accessor :scheme
|
5
|
-
|
6
|
-
# Defines url host
|
7
|
-
attr_accessor :host
|
8
|
-
|
9
|
-
# Defines url base path
|
10
|
-
attr_accessor :base_path
|
11
|
-
|
12
|
-
# Defines user agent
|
13
|
-
attr_accessor :user_agent
|
14
|
-
|
15
|
-
# Defines API keys used with API Key authentications.
|
16
|
-
#
|
17
|
-
# @return [Hash] key: parameter name, value: parameter value (API key)
|
18
|
-
#
|
19
|
-
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
20
|
-
# config.api_key['api_key'] = 'xxx'
|
21
|
-
attr_accessor :api_key
|
22
|
-
|
23
|
-
# Defines API key prefixes used with API Key authentications.
|
24
|
-
#
|
25
|
-
# @return [Hash] key: parameter name, value: API key prefix
|
26
|
-
#
|
27
|
-
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
28
|
-
# config.api_key_prefix['api_key'] = 'Token'
|
29
|
-
attr_accessor :api_key_prefix
|
30
|
-
|
31
|
-
# Defines the username used with HTTP basic authentication.
|
32
|
-
#
|
33
|
-
# @return [String]
|
34
|
-
attr_accessor :username
|
35
|
-
|
36
|
-
# Defines the password used with HTTP basic authentication.
|
37
|
-
#
|
38
|
-
# @return [String]
|
39
|
-
attr_accessor :password
|
40
|
-
|
41
|
-
# Defines the access token (Bearer) used with OAuth2.
|
42
|
-
attr_accessor :access_token
|
43
|
-
|
44
|
-
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
45
|
-
# details will be logged with `logger.debug` (see the `logger` attribute).
|
46
|
-
# Default to false.
|
47
|
-
#
|
48
|
-
# @return [true, false]
|
49
|
-
attr_accessor :debugging
|
50
|
-
|
51
|
-
# Defines the logger used for debugging.
|
52
|
-
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
53
|
-
#
|
54
|
-
# @return [#debug]
|
55
|
-
attr_accessor :logger
|
56
|
-
|
57
|
-
# Defines the temporary folder to store downloaded files
|
58
|
-
# (for API endpoints that have file response).
|
59
|
-
# Default to use `Tempfile`.
|
60
|
-
#
|
61
|
-
# @return [String]
|
62
|
-
attr_accessor :temp_folder_path
|
63
|
-
|
64
|
-
# The time limit for HTTP request in seconds.
|
65
|
-
# Default to 0 (never times out).
|
66
|
-
attr_accessor :timeout
|
67
|
-
|
68
|
-
# Set this to false to skip client side validation in the operation.
|
69
|
-
# Default to true.
|
70
|
-
# @return [true, false]
|
71
|
-
attr_accessor :client_side_validation
|
72
|
-
|
73
|
-
### TLS/SSL setting
|
74
|
-
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
75
|
-
# Default to true.
|
76
|
-
#
|
77
|
-
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
78
|
-
#
|
79
|
-
# @return [true, false]
|
80
|
-
attr_accessor :ssl_verify
|
81
|
-
|
82
|
-
### TLS/SSL setting
|
83
|
-
# Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
|
84
|
-
#
|
85
|
-
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
86
|
-
#
|
87
|
-
attr_accessor :ssl_verify_mode
|
88
|
-
|
89
|
-
### TLS/SSL setting
|
90
|
-
# Set this to customize the certificate file to verify the peer.
|
91
|
-
#
|
92
|
-
# @return [String] the path to the certificate file
|
93
|
-
attr_accessor :ssl_ca_file
|
94
|
-
|
95
|
-
### TLS/SSL setting
|
96
|
-
# Client certificate file (for client certificate)
|
97
|
-
attr_accessor :ssl_client_cert
|
98
|
-
|
99
|
-
### TLS/SSL setting
|
100
|
-
# Client private key file (for client certificate)
|
101
|
-
attr_accessor :ssl_client_key
|
102
|
-
|
103
|
-
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
104
|
-
# Default to nil.
|
105
|
-
#
|
106
|
-
# @see The params_encoding option of Ethon. Related source code:
|
107
|
-
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
108
|
-
attr_accessor :params_encoding
|
109
|
-
|
110
|
-
def initialize
|
111
|
-
@scheme = 'https'
|
112
|
-
@host = ''
|
113
|
-
@base_path = ''
|
114
|
-
@user_agent = ''
|
115
|
-
@subscription_key = ''
|
116
|
-
@api_key = {}
|
117
|
-
@api_key_prefix = {}
|
118
|
-
@client_side_validation = true
|
119
|
-
@ssl_verify = true
|
120
|
-
@ssl_verify_mode = nil
|
121
|
-
@ssl_ca_file = nil
|
122
|
-
@ssl_client_cert = nil
|
123
|
-
@ssl_client_key = nil
|
124
|
-
@middlewares = []
|
125
|
-
@request_middlewares = []
|
126
|
-
@response_middlewares = []
|
127
|
-
@timeout = 60
|
128
|
-
@debugging = false
|
129
|
-
@logger = Object.const_defined?(:Rails) ? Rails.logger : Logger.new(STDOUT)
|
130
|
-
|
131
|
-
yield(self) if block_given?
|
132
|
-
end
|
133
|
-
|
134
|
-
# The default Configuration object.
|
135
|
-
def self.default
|
136
|
-
@@default ||= Configuration.new
|
137
|
-
end
|
138
|
-
|
139
|
-
def configure
|
140
|
-
yield(self) if block_given?
|
141
|
-
end
|
142
|
-
|
143
|
-
def scheme=(scheme)
|
144
|
-
# remove :// from scheme
|
145
|
-
@scheme = scheme.sub(/:\/\//, '')
|
146
|
-
end
|
147
|
-
|
148
|
-
def host=(host)
|
149
|
-
# remove http(s):// and anything after a slash
|
150
|
-
@host = host.sub(/https?:\/\//, '').split('/').first
|
151
|
-
end
|
152
|
-
|
153
|
-
def base_path=(base_path)
|
154
|
-
# Add leading and trailing slashes to base_path
|
155
|
-
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
156
|
-
@base_path = '' if @base_path == '/'
|
157
|
-
end
|
158
|
-
|
159
|
-
# Returns base URL
|
160
|
-
def base_url
|
161
|
-
"#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
162
|
-
end
|
163
|
-
|
164
|
-
def debugging
|
165
|
-
return @debugging if @debugging == true
|
166
|
-
ENV['MINATO_RUBY_API_CLIENT_DEBUG'] == 'true'
|
167
|
-
end
|
168
|
-
|
169
|
-
# Gets API key (with prefix if set).
|
170
|
-
# @param [String] param_name the parameter name of API key auth
|
171
|
-
def api_key_with_prefix(param_name, param_alias = nil)
|
172
|
-
key = @api_key[param_name]
|
173
|
-
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
|
174
|
-
if @api_key_prefix[param_name]
|
175
|
-
"#{@api_key_prefix[param_name]} #{key}"
|
176
|
-
else
|
177
|
-
key
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
# Gets Basic Auth token string
|
182
|
-
def basic_auth_token
|
183
|
-
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
184
|
-
end
|
185
|
-
|
186
|
-
# Returns Auth Settings hash for api client.
|
187
|
-
def auth_settings
|
188
|
-
auth_settings = {
|
189
|
-
'bearer_auth' =>
|
190
|
-
{
|
191
|
-
type: 'bearer',
|
192
|
-
in: 'header',
|
193
|
-
key: 'Authorization',
|
194
|
-
value: "Bearer #{access_token}"
|
195
|
-
},
|
196
|
-
'basic_auth' =>
|
197
|
-
{
|
198
|
-
type: 'basic',
|
199
|
-
in: 'header',
|
200
|
-
key: 'Authorization',
|
201
|
-
value: basic_auth_token
|
202
|
-
},
|
203
|
-
}
|
204
|
-
|
205
|
-
api_key.each do |k, v|
|
206
|
-
auth_settings['apikey'] = {
|
207
|
-
type: 'apikey',
|
208
|
-
in: 'header',
|
209
|
-
key: k,
|
210
|
-
value: api_key_with_prefix(k)
|
211
|
-
}
|
212
|
-
end
|
213
|
-
|
214
|
-
auth_settings
|
215
|
-
end
|
216
|
-
|
217
|
-
# Adds middleware to the stack
|
218
|
-
def use(*middleware)
|
219
|
-
@middlewares << middleware
|
220
|
-
end
|
221
|
-
|
222
|
-
# Adds request middleware to the stack
|
223
|
-
def request(*middleware)
|
224
|
-
@request_middlewares << middleware
|
225
|
-
end
|
226
|
-
|
227
|
-
# Adds response middleware to the stack
|
228
|
-
def response(*middleware)
|
229
|
-
@response_middlewares << middleware
|
230
|
-
end
|
231
|
-
|
232
|
-
# Set up middleware on the connection
|
233
|
-
def configure_middleware(connection)
|
234
|
-
@middlewares.each do |middleware|
|
235
|
-
connection.use(*middleware)
|
236
|
-
end
|
237
|
-
|
238
|
-
@request_middlewares.each do |middleware|
|
239
|
-
connection.request(*middleware)
|
240
|
-
end
|
241
|
-
|
242
|
-
@response_middlewares.each do |middleware|
|
243
|
-
connection.response(*middleware)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
1
|
+
module MinatoRubyApiClient
|
2
|
+
class Configuration
|
3
|
+
# Defines url scheme
|
4
|
+
attr_accessor :scheme
|
5
|
+
|
6
|
+
# Defines url host
|
7
|
+
attr_accessor :host
|
8
|
+
|
9
|
+
# Defines url base path
|
10
|
+
attr_accessor :base_path
|
11
|
+
|
12
|
+
# Defines user agent
|
13
|
+
attr_accessor :user_agent
|
14
|
+
|
15
|
+
# Defines API keys used with API Key authentications.
|
16
|
+
#
|
17
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
18
|
+
#
|
19
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
20
|
+
# config.api_key['api_key'] = 'xxx'
|
21
|
+
attr_accessor :api_key
|
22
|
+
|
23
|
+
# Defines API key prefixes used with API Key authentications.
|
24
|
+
#
|
25
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
26
|
+
#
|
27
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
28
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
29
|
+
attr_accessor :api_key_prefix
|
30
|
+
|
31
|
+
# Defines the username used with HTTP basic authentication.
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
attr_accessor :username
|
35
|
+
|
36
|
+
# Defines the password used with HTTP basic authentication.
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
attr_accessor :password
|
40
|
+
|
41
|
+
# Defines the access token (Bearer) used with OAuth2.
|
42
|
+
attr_accessor :access_token
|
43
|
+
|
44
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
45
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
46
|
+
# Default to false.
|
47
|
+
#
|
48
|
+
# @return [true, false]
|
49
|
+
attr_accessor :debugging
|
50
|
+
|
51
|
+
# Defines the logger used for debugging.
|
52
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
53
|
+
#
|
54
|
+
# @return [#debug]
|
55
|
+
attr_accessor :logger
|
56
|
+
|
57
|
+
# Defines the temporary folder to store downloaded files
|
58
|
+
# (for API endpoints that have file response).
|
59
|
+
# Default to use `Tempfile`.
|
60
|
+
#
|
61
|
+
# @return [String]
|
62
|
+
attr_accessor :temp_folder_path
|
63
|
+
|
64
|
+
# The time limit for HTTP request in seconds.
|
65
|
+
# Default to 0 (never times out).
|
66
|
+
attr_accessor :timeout
|
67
|
+
|
68
|
+
# Set this to false to skip client side validation in the operation.
|
69
|
+
# Default to true.
|
70
|
+
# @return [true, false]
|
71
|
+
attr_accessor :client_side_validation
|
72
|
+
|
73
|
+
### TLS/SSL setting
|
74
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
75
|
+
# Default to true.
|
76
|
+
#
|
77
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
78
|
+
#
|
79
|
+
# @return [true, false]
|
80
|
+
attr_accessor :ssl_verify
|
81
|
+
|
82
|
+
### TLS/SSL setting
|
83
|
+
# Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
|
84
|
+
#
|
85
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
86
|
+
#
|
87
|
+
attr_accessor :ssl_verify_mode
|
88
|
+
|
89
|
+
### TLS/SSL setting
|
90
|
+
# Set this to customize the certificate file to verify the peer.
|
91
|
+
#
|
92
|
+
# @return [String] the path to the certificate file
|
93
|
+
attr_accessor :ssl_ca_file
|
94
|
+
|
95
|
+
### TLS/SSL setting
|
96
|
+
# Client certificate file (for client certificate)
|
97
|
+
attr_accessor :ssl_client_cert
|
98
|
+
|
99
|
+
### TLS/SSL setting
|
100
|
+
# Client private key file (for client certificate)
|
101
|
+
attr_accessor :ssl_client_key
|
102
|
+
|
103
|
+
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
104
|
+
# Default to nil.
|
105
|
+
#
|
106
|
+
# @see The params_encoding option of Ethon. Related source code:
|
107
|
+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
108
|
+
attr_accessor :params_encoding
|
109
|
+
|
110
|
+
def initialize
|
111
|
+
@scheme = 'https'
|
112
|
+
@host = ''
|
113
|
+
@base_path = ''
|
114
|
+
@user_agent = ''
|
115
|
+
@subscription_key = ''
|
116
|
+
@api_key = {}
|
117
|
+
@api_key_prefix = {}
|
118
|
+
@client_side_validation = true
|
119
|
+
@ssl_verify = true
|
120
|
+
@ssl_verify_mode = nil
|
121
|
+
@ssl_ca_file = nil
|
122
|
+
@ssl_client_cert = nil
|
123
|
+
@ssl_client_key = nil
|
124
|
+
@middlewares = []
|
125
|
+
@request_middlewares = []
|
126
|
+
@response_middlewares = []
|
127
|
+
@timeout = 60
|
128
|
+
@debugging = false
|
129
|
+
@logger = Object.const_defined?(:Rails) ? Rails.logger : Logger.new(STDOUT)
|
130
|
+
|
131
|
+
yield(self) if block_given?
|
132
|
+
end
|
133
|
+
|
134
|
+
# The default Configuration object.
|
135
|
+
def self.default
|
136
|
+
@@default ||= Configuration.new
|
137
|
+
end
|
138
|
+
|
139
|
+
def configure
|
140
|
+
yield(self) if block_given?
|
141
|
+
end
|
142
|
+
|
143
|
+
def scheme=(scheme)
|
144
|
+
# remove :// from scheme
|
145
|
+
@scheme = scheme.sub(/:\/\//, '')
|
146
|
+
end
|
147
|
+
|
148
|
+
def host=(host)
|
149
|
+
# remove http(s):// and anything after a slash
|
150
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
151
|
+
end
|
152
|
+
|
153
|
+
def base_path=(base_path)
|
154
|
+
# Add leading and trailing slashes to base_path
|
155
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
156
|
+
@base_path = '' if @base_path == '/'
|
157
|
+
end
|
158
|
+
|
159
|
+
# Returns base URL
|
160
|
+
def base_url
|
161
|
+
"#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
162
|
+
end
|
163
|
+
|
164
|
+
def debugging
|
165
|
+
return @debugging if @debugging == true
|
166
|
+
ENV['MINATO_RUBY_API_CLIENT_DEBUG'] == 'true'
|
167
|
+
end
|
168
|
+
|
169
|
+
# Gets API key (with prefix if set).
|
170
|
+
# @param [String] param_name the parameter name of API key auth
|
171
|
+
def api_key_with_prefix(param_name, param_alias = nil)
|
172
|
+
key = @api_key[param_name]
|
173
|
+
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
|
174
|
+
if @api_key_prefix[param_name]
|
175
|
+
"#{@api_key_prefix[param_name]} #{key}"
|
176
|
+
else
|
177
|
+
key
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# Gets Basic Auth token string
|
182
|
+
def basic_auth_token
|
183
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns Auth Settings hash for api client.
|
187
|
+
def auth_settings
|
188
|
+
auth_settings = {
|
189
|
+
'bearer_auth' =>
|
190
|
+
{
|
191
|
+
type: 'bearer',
|
192
|
+
in: 'header',
|
193
|
+
key: 'Authorization',
|
194
|
+
value: "Bearer #{access_token}"
|
195
|
+
},
|
196
|
+
'basic_auth' =>
|
197
|
+
{
|
198
|
+
type: 'basic',
|
199
|
+
in: 'header',
|
200
|
+
key: 'Authorization',
|
201
|
+
value: basic_auth_token
|
202
|
+
},
|
203
|
+
}
|
204
|
+
|
205
|
+
api_key.each do |k, v|
|
206
|
+
auth_settings['apikey'] = {
|
207
|
+
type: 'apikey',
|
208
|
+
in: 'header',
|
209
|
+
key: k,
|
210
|
+
value: api_key_with_prefix(k)
|
211
|
+
}
|
212
|
+
end
|
213
|
+
|
214
|
+
auth_settings
|
215
|
+
end
|
216
|
+
|
217
|
+
# Adds middleware to the stack
|
218
|
+
def use(*middleware)
|
219
|
+
@middlewares << middleware
|
220
|
+
end
|
221
|
+
|
222
|
+
# Adds request middleware to the stack
|
223
|
+
def request(*middleware)
|
224
|
+
@request_middlewares << middleware
|
225
|
+
end
|
226
|
+
|
227
|
+
# Adds response middleware to the stack
|
228
|
+
def response(*middleware)
|
229
|
+
@response_middlewares << middleware
|
230
|
+
end
|
231
|
+
|
232
|
+
# Set up middleware on the connection
|
233
|
+
def configure_middleware(connection)
|
234
|
+
@middlewares.each do |middleware|
|
235
|
+
connection.use(*middleware)
|
236
|
+
end
|
237
|
+
|
238
|
+
@request_middlewares.each do |middleware|
|
239
|
+
connection.request(*middleware)
|
240
|
+
end
|
241
|
+
|
242
|
+
@response_middlewares.each do |middleware|
|
243
|
+
connection.response(*middleware)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module MinatoRubyApiClient
|
2
|
-
VERSION = '0.2.
|
3
|
-
end
|
1
|
+
module MinatoRubyApiClient
|
2
|
+
VERSION = '0.2.3'
|
3
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
# Common files
|
2
|
-
require 'minato_ruby_api_client/api_client'
|
3
|
-
require 'minato_ruby_api_client/api_error'
|
4
|
-
require 'minato_ruby_api_client/version'
|
5
|
-
require 'minato_ruby_api_client/configuration'
|
6
|
-
|
7
|
-
|
8
|
-
module MinatoRubyApiClient
|
9
|
-
class << self
|
10
|
-
# Customize default settings for the SDK using block.
|
11
|
-
# MinatoRubyApiClient.configure do |config|
|
12
|
-
# config.username = "xxx"
|
13
|
-
# config.password = "xxx"
|
14
|
-
# end
|
15
|
-
# If no block given, return the default Configuration object.
|
16
|
-
def configure
|
17
|
-
if block_given?
|
18
|
-
yield(Configuration.default)
|
19
|
-
else
|
20
|
-
Configuration.default
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
1
|
+
# Common files
|
2
|
+
require 'minato_ruby_api_client/api_client'
|
3
|
+
require 'minato_ruby_api_client/api_error'
|
4
|
+
require 'minato_ruby_api_client/version'
|
5
|
+
require 'minato_ruby_api_client/configuration'
|
6
|
+
|
7
|
+
|
8
|
+
module MinatoRubyApiClient
|
9
|
+
class << self
|
10
|
+
# Customize default settings for the SDK using block.
|
11
|
+
# MinatoRubyApiClient.configure do |config|
|
12
|
+
# config.username = "xxx"
|
13
|
+
# config.password = "xxx"
|
14
|
+
# end
|
15
|
+
# If no block given, return the default Configuration object.
|
16
|
+
def configure
|
17
|
+
if block_given?
|
18
|
+
yield(Configuration.default)
|
19
|
+
else
|
20
|
+
Configuration.default
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
=begin
|
4
|
-
# Minato Ruby Api Client
|
5
|
-
|
6
|
-
The Minato ruby HTTP Client
|
7
|
-
|
8
|
-
=end
|
9
|
-
|
10
|
-
$:.push File.expand_path("../lib", __FILE__)
|
11
|
-
require "minato_ruby_api_client/version"
|
12
|
-
|
13
|
-
Gem::Specification.new do |s|
|
14
|
-
s.name = "minato_ruby_api_client"
|
15
|
-
s.version = MinatoRubyApiClient::VERSION
|
16
|
-
s.platform = Gem::Platform::RUBY
|
17
|
-
s.authors = ["Ferreri"]
|
18
|
-
s.email = ["support@ferreri.co"]
|
19
|
-
s.homepage = "http://ferreri.co"
|
20
|
-
s.summary = "A Minato ruby HTTP Client"
|
21
|
-
s.description = "Minato HTTP Client"
|
22
|
-
s.license = "
|
23
|
-
s.required_ruby_version = ">= 3.0"
|
24
|
-
|
25
|
-
s.add_runtime_dependency 'faraday', '~> 1.0', '>= 1.0.1'
|
26
|
-
s.add_runtime_dependency 'minato_error_handler', '~> 0.1.
|
27
|
-
s.add_runtime_dependency 'minato-trace', '~> 0.
|
28
|
-
|
29
|
-
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
30
|
-
|
31
|
-
s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
|
32
|
-
s.test_files = `find spec/*`.split("\n")
|
33
|
-
s.executables = []
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
=begin
|
4
|
+
# Minato Ruby Api Client
|
5
|
+
|
6
|
+
The Minato ruby HTTP Client
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
$:.push File.expand_path("../lib", __FILE__)
|
11
|
+
require "minato_ruby_api_client/version"
|
12
|
+
|
13
|
+
Gem::Specification.new do |s|
|
14
|
+
s.name = "minato_ruby_api_client"
|
15
|
+
s.version = MinatoRubyApiClient::VERSION
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
s.authors = ["Ferreri"]
|
18
|
+
s.email = ["support@ferreri.co"]
|
19
|
+
s.homepage = "http://ferreri.co"
|
20
|
+
s.summary = "A Minato ruby HTTP Client"
|
21
|
+
s.description = "Minato HTTP Client"
|
22
|
+
s.license = "Unlicense"
|
23
|
+
s.required_ruby_version = ">= 3.0"
|
24
|
+
|
25
|
+
s.add_runtime_dependency 'faraday', '~> 1.0', '>= 1.0.1'
|
26
|
+
s.add_runtime_dependency 'minato_error_handler', '~> 0.1.12'
|
27
|
+
s.add_runtime_dependency 'minato-trace', '~> 0.2.0'
|
28
|
+
|
29
|
+
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
30
|
+
|
31
|
+
s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
|
32
|
+
s.test_files = `find spec/*`.split("\n")
|
33
|
+
s.executables = []
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
end
|