wesley-key-sdk 3.0.7 → 4.2.0
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/README.md +168 -131
- data/bin/console +4 -4
- data/lib/swagger_petstore_open_api30/api_helper.rb +10 -0
- data/lib/{cypress_test_api/controllers/base_controller.rb → swagger_petstore_open_api30/apis/base_api.rb} +17 -10
- data/lib/swagger_petstore_open_api30/apis/pet_api.rb +287 -0
- data/lib/swagger_petstore_open_api30/apis/store_api.rb +131 -0
- data/lib/swagger_petstore_open_api30/apis/user_api.rb +233 -0
- data/lib/swagger_petstore_open_api30/client.rb +95 -0
- data/lib/{cypress_test_api → swagger_petstore_open_api30}/configuration.rb +72 -47
- data/lib/{cypress_test_api → swagger_petstore_open_api30}/exceptions/api_exception.rb +4 -4
- data/lib/swagger_petstore_open_api30/exceptions/oauth_provider_exception.rb +64 -0
- data/lib/swagger_petstore_open_api30/http/api_response.rb +19 -0
- data/lib/swagger_petstore_open_api30/http/auth/api_key.rb +52 -0
- data/lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb +112 -0
- data/lib/swagger_petstore_open_api30/http/http_call_back.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/http_method_enum.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/http_request.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/http_response.rb +10 -0
- data/lib/{cypress_test_api → swagger_petstore_open_api30}/http/proxy_settings.rb +4 -4
- data/lib/swagger_petstore_open_api30/logging/configuration/api_logging_configuration.rb +186 -0
- data/lib/swagger_petstore_open_api30/logging/sdk_logger.rb +17 -0
- data/lib/swagger_petstore_open_api30/models/api_response.rb +118 -0
- data/lib/{cypress_test_api → swagger_petstore_open_api30}/models/base_model.rb +4 -4
- data/lib/swagger_petstore_open_api30/models/category.rb +105 -0
- data/lib/swagger_petstore_open_api30/models/oauth_provider_error.rb +62 -0
- data/lib/swagger_petstore_open_api30/models/oauth_scope_petstore_auth.rb +36 -0
- data/lib/swagger_petstore_open_api30/models/oauth_token.rb +125 -0
- data/lib/swagger_petstore_open_api30/models/order.rb +167 -0
- data/lib/swagger_petstore_open_api30/models/order_status.rb +40 -0
- data/lib/swagger_petstore_open_api30/models/pet.rb +168 -0
- data/lib/swagger_petstore_open_api30/models/pet_status.rb +40 -0
- data/lib/swagger_petstore_open_api30/models/tag.rb +105 -0
- data/lib/swagger_petstore_open_api30/models/user.rb +182 -0
- data/lib/swagger_petstore_open_api30/utilities/date_time_helper.rb +11 -0
- data/lib/{cypress_test_api → swagger_petstore_open_api30}/utilities/file_wrapper.rb +4 -4
- data/lib/swagger_petstore_open_api30/utilities/xml_utilities.rb +12 -0
- data/lib/swagger_petstore_open_api30.rb +62 -0
- metadata +37 -64
- data/lib/cypress_test_api/api_helper.rb +0 -10
- data/lib/cypress_test_api/client.rb +0 -58
- data/lib/cypress_test_api/controllers/api_controller.rb +0 -102
- data/lib/cypress_test_api/http/http_call_back.rb +0 -10
- data/lib/cypress_test_api/http/http_method_enum.rb +0 -10
- data/lib/cypress_test_api/http/http_request.rb +0 -10
- data/lib/cypress_test_api/http/http_response.rb +0 -10
- data/lib/cypress_test_api/models/custom_enum.rb +0 -40
- data/lib/cypress_test_api/models/deer.rb +0 -68
- data/lib/cypress_test_api/models/item.rb +0 -166
- data/lib/cypress_test_api/models/item_response.rb +0 -80
- data/lib/cypress_test_api/models/lion.rb +0 -68
- data/lib/cypress_test_api/models/message.rb +0 -68
- data/lib/cypress_test_api/models/message2.rb +0 -71
- data/lib/cypress_test_api/models/multiple_arrays_request.rb +0 -70
- data/lib/cypress_test_api/models/nac_tag.rb +0 -265
- data/lib/cypress_test_api/models/o_auth_scope_o_auth_acg_enum.rb +0 -44
- data/lib/cypress_test_api/models/response_http400.rb +0 -62
- data/lib/cypress_test_api/models/response_http404.rb +0 -62
- data/lib/cypress_test_api/models/status11_enum.rb +0 -40
- data/lib/cypress_test_api/models/status1_enum.rb +0 -40
- data/lib/cypress_test_api/models/status_enum.rb +0 -40
- data/lib/cypress_test_api/models/tokens_request.rb +0 -60
- data/lib/cypress_test_api/utilities/date_time_helper.rb +0 -11
- data/lib/cypress_test_api.rb +0 -55
- data/test/controllers/controller_test_base.rb +0 -23
- data/test/controllers/test_api_controller.rb +0 -40
- data/test/http_response_catcher.rb +0 -19
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# swagger_petstore_open_api30 client class.
|
|
8
|
+
class Client
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
attr_reader :config, :auth_managers
|
|
11
|
+
|
|
12
|
+
def user_agent_detail
|
|
13
|
+
config.user_agent_detail
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns the configured authentication petstore_auth instance.
|
|
17
|
+
def petstore_auth
|
|
18
|
+
@auth_managers['petstore_auth']
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Access to pet controller.
|
|
22
|
+
# @return [PetApi] Returns the controller instance.
|
|
23
|
+
def pet
|
|
24
|
+
@pet ||= PetApi.new @global_configuration
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Access to store controller.
|
|
28
|
+
# @return [StoreApi] Returns the controller instance.
|
|
29
|
+
def store
|
|
30
|
+
@store ||= StoreApi.new @global_configuration
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Access to user controller.
|
|
34
|
+
# @return [UserApi] Returns the controller instance.
|
|
35
|
+
def user
|
|
36
|
+
@user ||= UserApi.new @global_configuration
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def initialize(
|
|
40
|
+
connection: nil, adapter: :net_http_persistent, timeout: 30,
|
|
41
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
|
42
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
43
|
+
retry_methods: %i[get put get put], http_callback: nil,
|
|
44
|
+
proxy_settings: nil, logging_configuration: nil,
|
|
45
|
+
environment: Environment::PRODUCTION, petstore_auth_credentials: nil,
|
|
46
|
+
api_key_credentials: nil, config: nil
|
|
47
|
+
)
|
|
48
|
+
@config = if config.nil?
|
|
49
|
+
Configuration.new(
|
|
50
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
|
51
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
|
52
|
+
backoff_factor: backoff_factor,
|
|
53
|
+
retry_statuses: retry_statuses,
|
|
54
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
|
55
|
+
proxy_settings: proxy_settings,
|
|
56
|
+
logging_configuration: logging_configuration,
|
|
57
|
+
environment: environment,
|
|
58
|
+
petstore_auth_credentials: petstore_auth_credentials,
|
|
59
|
+
api_key_credentials: api_key_credentials
|
|
60
|
+
)
|
|
61
|
+
else
|
|
62
|
+
config
|
|
63
|
+
end
|
|
64
|
+
user_agent_params = BaseApi.user_agent_parameters
|
|
65
|
+
|
|
66
|
+
@global_configuration = GlobalConfiguration.new(client_configuration: @config)
|
|
67
|
+
.base_uri_executor(@config.method(:get_base_uri))
|
|
68
|
+
.global_errors(BaseApi::GLOBAL_ERRORS)
|
|
69
|
+
.user_agent(BaseApi.user_agent,
|
|
70
|
+
agent_parameters: user_agent_params)
|
|
71
|
+
|
|
72
|
+
initialize_auth_managers(@global_configuration)
|
|
73
|
+
@global_configuration = @global_configuration.auth_managers(@auth_managers)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Initializes the auth managers hash used for authenticating API calls.
|
|
77
|
+
# @param [GlobalConfiguration] global_config The global configuration of the SDK)
|
|
78
|
+
def initialize_auth_managers(global_config)
|
|
79
|
+
@auth_managers = {}
|
|
80
|
+
http_client_config = global_config.client_configuration
|
|
81
|
+
%w[petstore_auth api_key].each { |auth| @auth_managers[auth] = nil }
|
|
82
|
+
@auth_managers['petstore_auth'] = PetstoreAuth.new(
|
|
83
|
+
http_client_config.petstore_auth_credentials, global_config
|
|
84
|
+
)
|
|
85
|
+
@auth_managers['api_key'] = ApiKey.new(http_client_config.api_key_credentials)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Creates a client directly from environment variables.
|
|
89
|
+
def self.from_env(**overrides)
|
|
90
|
+
default_config = Configuration.build_default_config_from_env
|
|
91
|
+
new_config = default_config.clone_with(**overrides)
|
|
92
|
+
new(config: new_config)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
2
|
#
|
|
3
|
-
# This file was automatically generated by
|
|
4
|
-
# ( https://www.apimatic.io ).
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
5
|
|
|
6
|
-
module
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
7
|
# An enum for SDK environments.
|
|
8
8
|
class Environment
|
|
9
9
|
ENVIRONMENT = [
|
|
@@ -14,21 +14,30 @@ module CypressTestApi
|
|
|
14
14
|
def self.from_value(value, default_value = PRODUCTION)
|
|
15
15
|
return default_value if value.nil?
|
|
16
16
|
|
|
17
|
-
default_value
|
|
17
|
+
default_value
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# An enum for API servers.
|
|
22
22
|
class Server
|
|
23
23
|
SERVER = [
|
|
24
|
-
DEFAULT = 'default'.freeze
|
|
24
|
+
DEFAULT = 'default'.freeze,
|
|
25
|
+
AUTH_SERVER = 'auth server'.freeze
|
|
25
26
|
].freeze
|
|
26
27
|
|
|
27
28
|
# Converts a string or symbol into a valid Server constant.
|
|
28
29
|
def self.from_value(value, default_value = DEFAULT)
|
|
29
30
|
return default_value if value.nil?
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
str = value.to_s.strip.downcase
|
|
33
|
+
case str
|
|
34
|
+
when 'default' then DEFAULT
|
|
35
|
+
when 'auth_server' then AUTH_SERVER
|
|
36
|
+
|
|
37
|
+
else
|
|
38
|
+
warn "[Server] Unknown server '#{value}', falling back to #{default_value} "
|
|
39
|
+
default_value
|
|
40
|
+
end
|
|
32
41
|
end
|
|
33
42
|
end
|
|
34
43
|
|
|
@@ -36,31 +45,37 @@ module CypressTestApi
|
|
|
36
45
|
# are configured in this class.
|
|
37
46
|
class Configuration < CoreLibrary::HttpClientConfiguration
|
|
38
47
|
# The attribute readers for properties.
|
|
39
|
-
attr_reader :environment, :
|
|
48
|
+
attr_reader :environment, :petstore_auth_credentials, :api_key_credentials
|
|
40
49
|
|
|
41
50
|
class << self
|
|
42
51
|
attr_reader :environments
|
|
43
52
|
end
|
|
44
53
|
|
|
45
54
|
def initialize(
|
|
46
|
-
connection: nil, adapter: :net_http_persistent, timeout:
|
|
55
|
+
connection: nil, adapter: :net_http_persistent, timeout: 30,
|
|
47
56
|
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
|
48
|
-
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
49
|
-
retry_methods: %i[get put], http_callback: nil,
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
58
|
+
retry_methods: %i[get put get put], http_callback: nil,
|
|
59
|
+
proxy_settings: nil, logging_configuration: nil,
|
|
60
|
+
environment: Environment::PRODUCTION, petstore_auth_credentials: nil,
|
|
61
|
+
api_key_credentials: nil
|
|
62
|
+
)
|
|
52
63
|
super connection: connection, adapter: adapter, timeout: timeout,
|
|
53
64
|
max_retries: max_retries, retry_interval: retry_interval,
|
|
54
65
|
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
|
55
66
|
retry_methods: retry_methods, http_callback: http_callback,
|
|
56
|
-
proxy_settings: proxy_settings
|
|
57
|
-
|
|
67
|
+
proxy_settings: proxy_settings,
|
|
68
|
+
logging_configuration: logging_configuration
|
|
69
|
+
|
|
58
70
|
# Current API environment
|
|
59
71
|
@environment = String(environment)
|
|
60
|
-
|
|
61
|
-
#
|
|
62
|
-
@
|
|
63
|
-
|
|
72
|
+
|
|
73
|
+
# The object holding OAuth 2 Implicit Grant credentials
|
|
74
|
+
@petstore_auth_credentials = petstore_auth_credentials
|
|
75
|
+
|
|
76
|
+
# The object holding Custom Header Signature credentials
|
|
77
|
+
@api_key_credentials = api_key_credentials
|
|
78
|
+
|
|
64
79
|
# The Http Client to use for making requests.
|
|
65
80
|
set_http_client CoreLibrary::FaradayClient.new(self)
|
|
66
81
|
end
|
|
@@ -68,20 +83,24 @@ module CypressTestApi
|
|
|
68
83
|
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
|
69
84
|
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
|
70
85
|
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
|
71
|
-
proxy_settings: nil,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
proxy_settings: nil, logging_configuration: nil,
|
|
87
|
+
environment: nil, petstore_auth_credentials: nil,
|
|
88
|
+
api_key_credentials: nil)
|
|
89
|
+
connection ||= self.connection
|
|
90
|
+
adapter ||= self.adapter
|
|
91
|
+
timeout ||= self.timeout
|
|
92
|
+
max_retries ||= self.max_retries
|
|
93
|
+
retry_interval ||= self.retry_interval
|
|
94
|
+
backoff_factor ||= self.backoff_factor
|
|
95
|
+
retry_statuses ||= self.retry_statuses
|
|
96
|
+
retry_methods ||= self.retry_methods
|
|
97
|
+
http_callback ||= self.http_callback
|
|
98
|
+
proxy_settings ||= self.proxy_settings
|
|
99
|
+
logging_configuration ||= self.logging_configuration
|
|
100
|
+
environment ||= self.environment
|
|
101
|
+
petstore_auth_credentials ||= self.petstore_auth_credentials
|
|
102
|
+
api_key_credentials ||= self.api_key_credentials
|
|
103
|
+
|
|
85
104
|
Configuration.new(connection: connection, adapter: adapter,
|
|
86
105
|
timeout: timeout, max_retries: max_retries,
|
|
87
106
|
retry_interval: retry_interval,
|
|
@@ -90,14 +109,18 @@ module CypressTestApi
|
|
|
90
109
|
retry_methods: retry_methods,
|
|
91
110
|
http_callback: http_callback,
|
|
92
111
|
proxy_settings: proxy_settings,
|
|
93
|
-
|
|
112
|
+
logging_configuration: logging_configuration,
|
|
113
|
+
environment: environment,
|
|
114
|
+
petstore_auth_credentials: petstore_auth_credentials,
|
|
115
|
+
api_key_credentials: api_key_credentials)
|
|
94
116
|
end
|
|
95
117
|
|
|
96
118
|
|
|
97
119
|
# All the environments the SDK can run in.
|
|
98
120
|
ENVIRONMENTS = {
|
|
99
121
|
Environment::PRODUCTION => {
|
|
100
|
-
Server::DEFAULT => 'https://
|
|
122
|
+
Server::DEFAULT => 'https://petstore3.swagger.io/api/v3',
|
|
123
|
+
Server::AUTH_SERVER => 'https://petstore3.swagger.io/oauth'
|
|
101
124
|
}
|
|
102
125
|
}.freeze
|
|
103
126
|
|
|
@@ -106,50 +129,52 @@ module CypressTestApi
|
|
|
106
129
|
# required.
|
|
107
130
|
# @return [String] The base URI.
|
|
108
131
|
def get_base_uri(server = Server::DEFAULT)
|
|
109
|
-
|
|
110
|
-
'defaultHost' => { 'value' => default_host, 'encode' => false }
|
|
111
|
-
}
|
|
112
|
-
APIHelper.append_url_with_template_parameters(
|
|
113
|
-
ENVIRONMENTS[environment][server], parameters
|
|
114
|
-
)
|
|
132
|
+
ENVIRONMENTS[environment][server].clone
|
|
115
133
|
end
|
|
116
134
|
|
|
117
135
|
# Builds a Configuration instance using environment variables.
|
|
118
136
|
def self.build_default_config_from_env
|
|
119
137
|
# === Core environment ===
|
|
120
138
|
environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
|
|
121
|
-
|
|
122
|
-
timeout = (ENV['TIMEOUT'] || 60).to_f
|
|
139
|
+
timeout = (ENV['TIMEOUT'] || 30).to_f
|
|
123
140
|
max_retries = (ENV['MAX_RETRIES'] || 0).to_i
|
|
124
141
|
retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
|
|
125
142
|
backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
|
|
126
143
|
retry_statuses = ENV.fetch('RETRY_STATUSES',
|
|
127
|
-
'[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
|
|
144
|
+
'[408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
|
|
128
145
|
.split(',')
|
|
129
146
|
.map(&:strip)
|
|
130
147
|
.map do |item|
|
|
131
148
|
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
132
149
|
end
|
|
133
|
-
retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
|
|
150
|
+
retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put get put]').gsub(/[\[\]]/, '')
|
|
134
151
|
.split(',')
|
|
135
152
|
.map(&:strip)
|
|
136
153
|
.map do |item|
|
|
137
154
|
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
138
155
|
end
|
|
139
156
|
|
|
157
|
+
# === Authentication credentials ===
|
|
158
|
+
petstore_auth_credentials = PetstoreAuthCredentials.from_env
|
|
159
|
+
api_key_credentials = ApiKeyCredentials.from_env
|
|
160
|
+
|
|
140
161
|
# === Proxy settings ===
|
|
141
162
|
proxy_settings = ProxySettings.from_env
|
|
163
|
+
# === Logging Configuration ===
|
|
164
|
+
logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured?
|
|
142
165
|
|
|
143
166
|
Configuration.new(
|
|
144
167
|
environment: environment,
|
|
145
|
-
default_host: default_host,
|
|
146
168
|
timeout: timeout,
|
|
147
169
|
max_retries: max_retries,
|
|
148
170
|
retry_interval: retry_interval,
|
|
149
171
|
backoff_factor: backoff_factor,
|
|
150
172
|
retry_statuses: retry_statuses,
|
|
151
173
|
retry_methods: retry_methods,
|
|
152
|
-
|
|
174
|
+
petstore_auth_credentials: petstore_auth_credentials,
|
|
175
|
+
api_key_credentials: api_key_credentials,
|
|
176
|
+
proxy_settings: proxy_settings,
|
|
177
|
+
logging_configuration: logging_configuration
|
|
153
178
|
)
|
|
154
179
|
end
|
|
155
180
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
2
|
#
|
|
3
|
-
# This file was automatically generated by
|
|
4
|
-
# ( https://www.apimatic.io ).
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
5
|
|
|
6
|
-
module
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
7
|
# Class for exceptions when there is a network error, status code error, etc.
|
|
8
8
|
class APIException < CoreLibrary::ApiException
|
|
9
9
|
# Provides a human-readable string representation of the object.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# OAuth 2 Authorization endpoint exception.
|
|
8
|
+
class OauthProviderException < APIException
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Gets or sets error code.
|
|
13
|
+
# @return [OauthProviderError]
|
|
14
|
+
attr_accessor :error
|
|
15
|
+
|
|
16
|
+
# Gets or sets human-readable text providing additional information on
|
|
17
|
+
# error.
|
|
18
|
+
# Used to assist the client developer in understanding the error that
|
|
19
|
+
# occurred.
|
|
20
|
+
# @return [String]
|
|
21
|
+
attr_accessor :error_description
|
|
22
|
+
|
|
23
|
+
# Gets or sets a URI identifying a human-readable web page with information
|
|
24
|
+
# about the error, used to provide the client developer with additional
|
|
25
|
+
# information about the error.
|
|
26
|
+
# @return [String]
|
|
27
|
+
attr_accessor :error_uri
|
|
28
|
+
|
|
29
|
+
# The constructor.
|
|
30
|
+
# @param [String] reason The reason for raising an exception.
|
|
31
|
+
# @param [HttpResponse] response The HttpReponse of the API call.
|
|
32
|
+
def initialize(reason, response)
|
|
33
|
+
super(reason, response)
|
|
34
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
|
35
|
+
unbox(hash)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Populates this object by extracting properties from a hash.
|
|
39
|
+
# @param [Hash] hash The deserialized response sent by the server in the
|
|
40
|
+
# response body.
|
|
41
|
+
def unbox(hash)
|
|
42
|
+
return nil unless hash
|
|
43
|
+
|
|
44
|
+
@error = hash.key?('error') ? hash['error'] : nil
|
|
45
|
+
@error_description =
|
|
46
|
+
hash.key?('error_description') ? hash['error_description'] : SKIP
|
|
47
|
+
@error_uri = hash.key?('error_uri') ? hash['error_uri'] : SKIP
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Provides a human-readable string representation of the object.
|
|
51
|
+
def to_s
|
|
52
|
+
class_name = self.class.name.split('::').last
|
|
53
|
+
"<#{class_name} error: #{@error}, error_description: #{@error_description}, error_uri:"\
|
|
54
|
+
" #{@error_uri}>"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
58
|
+
def inspect
|
|
59
|
+
class_name = self.class.name.split('::').last
|
|
60
|
+
"<#{class_name} error: #{@error.inspect}, error_description: #{@error_description.inspect},"\
|
|
61
|
+
" error_uri: #{@error_uri.inspect}>"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# Http response received.
|
|
8
|
+
class ApiResponse < CoreLibrary::ApiResponse
|
|
9
|
+
# The constructor
|
|
10
|
+
# @param [HttpResponse] http_response The original, raw response from the api.
|
|
11
|
+
# @param [Object] data The data field specified for the response.
|
|
12
|
+
# @param [Array<String>] errors Any errors returned by the server.
|
|
13
|
+
def initialize(http_response,
|
|
14
|
+
data: nil,
|
|
15
|
+
errors: nil)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# Utility class for custom header authorization.
|
|
8
|
+
class ApiKey < CoreLibrary::HeaderAuth
|
|
9
|
+
# Display error message on occurrence of authentication failure.
|
|
10
|
+
# @returns [String] The oAuth error message.
|
|
11
|
+
def error_message
|
|
12
|
+
'ApiKey: api_key is undefined.'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Initialization constructor.
|
|
16
|
+
def initialize(api_key_credentials)
|
|
17
|
+
auth_params = {}
|
|
18
|
+
auth_params['api_key'] = api_key_credentials.api_key unless
|
|
19
|
+
api_key_credentials.nil? || api_key_credentials.api_key.nil?
|
|
20
|
+
|
|
21
|
+
super auth_params
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Data class for ApiKeyCredentials.
|
|
26
|
+
# Data class for ApiKeyCredentials.
|
|
27
|
+
class ApiKeyCredentials
|
|
28
|
+
attr_reader :api_key
|
|
29
|
+
|
|
30
|
+
def initialize(api_key:)
|
|
31
|
+
raise ArgumentError, 'api_key cannot be nil' if api_key.nil?
|
|
32
|
+
|
|
33
|
+
@api_key = api_key
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.from_env
|
|
37
|
+
api_key = ENV['API_KEY_API_KEY']
|
|
38
|
+
all_nil = [
|
|
39
|
+
api_key
|
|
40
|
+
].all?(&:nil?)
|
|
41
|
+
return nil if all_nil
|
|
42
|
+
|
|
43
|
+
new(api_key: api_key)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def clone_with(api_key: nil)
|
|
47
|
+
api_key ||= self.api_key
|
|
48
|
+
|
|
49
|
+
ApiKeyCredentials.new(api_key: api_key)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
|
8
|
+
class PetstoreAuth < CoreLibrary::HeaderAuth
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
# Display error message on occurrence of authentication failure.
|
|
11
|
+
# @returns [String] The oAuth error message.
|
|
12
|
+
def error_message
|
|
13
|
+
'PetstoreAuth: OAuthToken is undefined or expired.'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Initialization constructor.
|
|
17
|
+
def initialize(petstore_auth_credentials, config)
|
|
18
|
+
auth_params = {}
|
|
19
|
+
@_oauth_client_id = petstore_auth_credentials.oauth_client_id unless
|
|
20
|
+
petstore_auth_credentials.nil? || petstore_auth_credentials.oauth_client_id.nil?
|
|
21
|
+
@_oauth_redirect_uri = petstore_auth_credentials.oauth_redirect_uri unless
|
|
22
|
+
petstore_auth_credentials.nil? || petstore_auth_credentials.oauth_redirect_uri.nil?
|
|
23
|
+
@_oauth_token = petstore_auth_credentials.oauth_token unless
|
|
24
|
+
petstore_auth_credentials.nil? || petstore_auth_credentials.oauth_token.nil?
|
|
25
|
+
@_oauth_scopes = petstore_auth_credentials.oauth_scopes unless
|
|
26
|
+
petstore_auth_credentials.nil? || petstore_auth_credentials.oauth_scopes.nil?
|
|
27
|
+
@_o_auth_api = OauthAuthorizationApi.new(config)
|
|
28
|
+
auth_params[:Authorization] = "Bearer #{@_oauth_token.access_token}" unless @_oauth_token.nil?
|
|
29
|
+
|
|
30
|
+
super auth_params
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Validates the oAuth token.
|
|
34
|
+
# @return [Boolean] true if the token is present and not expired.
|
|
35
|
+
def valid
|
|
36
|
+
!@_oauth_token.nil? && !token_expired?(@_oauth_token)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Builds and returns an authorization URL.
|
|
40
|
+
# The user is expected to obtain an authorization code from this URL and then call the
|
|
41
|
+
# fetch token function with that authorization code.
|
|
42
|
+
# @param [String] state An opaque state string.
|
|
43
|
+
# @param [Hash] additional_params Any additional query parameters to be added to the URL.
|
|
44
|
+
# @return [String] The authorization URL.
|
|
45
|
+
def get_authorization_url(state: nil, additional_params: nil)
|
|
46
|
+
auth_url = @_config.get_base_uri_executor.call(Server::AUTH_SERVER)
|
|
47
|
+
auth_url += '/authorize'
|
|
48
|
+
query_params = {
|
|
49
|
+
'response_type' => 'code',
|
|
50
|
+
'client_id' => @_oauth_client_id,
|
|
51
|
+
'redirect_uri' => @_oauth_redirect_uri
|
|
52
|
+
}
|
|
53
|
+
query_params['scope'] = Array(@_o_auth_scopes).compact.join(' ') if @_o_auth_scopes
|
|
54
|
+
query_params['state'] = state if state
|
|
55
|
+
query_params.merge!(additional_params) if additional_params
|
|
56
|
+
auth_url = APIHelper.append_url_with_query_parameters(auth_url,
|
|
57
|
+
query_params)
|
|
58
|
+
APIHelper.clean_url(auth_url)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Checks if OAuth token has expired.
|
|
62
|
+
# @param [OAuthToken] token The oAuth token instance.
|
|
63
|
+
# @return [Boolean] true if the token is present and not expired.
|
|
64
|
+
def token_expired?(token)
|
|
65
|
+
token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Data class for PetstoreAuthCredentials.
|
|
70
|
+
class PetstoreAuthCredentials
|
|
71
|
+
attr_reader :oauth_client_id, :oauth_redirect_uri, :oauth_token,
|
|
72
|
+
:oauth_scopes
|
|
73
|
+
|
|
74
|
+
def initialize(oauth_client_id:, oauth_redirect_uri:, oauth_token: nil,
|
|
75
|
+
oauth_scopes: nil)
|
|
76
|
+
raise ArgumentError, 'oauth_client_id cannot be nil' if oauth_client_id.nil?
|
|
77
|
+
raise ArgumentError, 'oauth_redirect_uri cannot be nil' if oauth_redirect_uri.nil?
|
|
78
|
+
|
|
79
|
+
@oauth_client_id = oauth_client_id
|
|
80
|
+
@oauth_redirect_uri = oauth_redirect_uri
|
|
81
|
+
@oauth_token = oauth_token
|
|
82
|
+
@oauth_scopes = oauth_scopes
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def self.from_env
|
|
86
|
+
oauth_client_id = ENV['PETSTORE_AUTH_OAUTH_CLIENT_ID']
|
|
87
|
+
oauth_redirect_uri = ENV['PETSTORE_AUTH_OAUTH_REDIRECT_URI']
|
|
88
|
+
oauth_scopes = ENV['PETSTORE_AUTH_OAUTH_SCOPES']
|
|
89
|
+
all_nil = [
|
|
90
|
+
oauth_client_id,
|
|
91
|
+
oauth_redirect_uri
|
|
92
|
+
].all?(&:nil?)
|
|
93
|
+
return nil if all_nil
|
|
94
|
+
|
|
95
|
+
new(oauth_client_id: oauth_client_id,
|
|
96
|
+
oauth_redirect_uri: oauth_redirect_uri, oauth_scopes: oauth_scopes)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def clone_with(oauth_client_id: nil, oauth_redirect_uri: nil,
|
|
100
|
+
oauth_token: nil, oauth_scopes: nil)
|
|
101
|
+
oauth_client_id ||= self.oauth_client_id
|
|
102
|
+
oauth_redirect_uri ||= self.oauth_redirect_uri
|
|
103
|
+
oauth_token ||= self.oauth_token
|
|
104
|
+
oauth_scopes ||= self.oauth_scopes
|
|
105
|
+
|
|
106
|
+
PetstoreAuthCredentials.new(oauth_client_id: oauth_client_id,
|
|
107
|
+
oauth_redirect_uri: oauth_redirect_uri,
|
|
108
|
+
oauth_token: oauth_token,
|
|
109
|
+
oauth_scopes: oauth_scopes)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
2
|
#
|
|
3
|
-
# This file was automatically generated by
|
|
4
|
-
# ( https://www.apimatic.io ).
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
5
|
|
|
6
|
-
module
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
7
|
##
|
|
8
8
|
# ProxySettings encapsulates HTTP proxy configuration for Faraday,
|
|
9
9
|
# including optional basic authentication.
|