demo-vender 1.5.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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +173 -0
  4. data/bin/console +15 -0
  5. data/lib/swagger_petstore_open_api30/api_helper.rb +10 -0
  6. data/lib/swagger_petstore_open_api30/apis/base_api.rb +67 -0
  7. data/lib/swagger_petstore_open_api30/apis/pet_api.rb +287 -0
  8. data/lib/swagger_petstore_open_api30/apis/store_api.rb +131 -0
  9. data/lib/swagger_petstore_open_api30/apis/user_api.rb +233 -0
  10. data/lib/swagger_petstore_open_api30/client.rb +95 -0
  11. data/lib/swagger_petstore_open_api30/configuration.rb +181 -0
  12. data/lib/swagger_petstore_open_api30/exceptions/api_exception.rb +21 -0
  13. data/lib/swagger_petstore_open_api30/exceptions/oauth_provider_exception.rb +64 -0
  14. data/lib/swagger_petstore_open_api30/http/api_response.rb +19 -0
  15. data/lib/swagger_petstore_open_api30/http/auth/api_key.rb +52 -0
  16. data/lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb +112 -0
  17. data/lib/swagger_petstore_open_api30/http/http_call_back.rb +10 -0
  18. data/lib/swagger_petstore_open_api30/http/http_method_enum.rb +10 -0
  19. data/lib/swagger_petstore_open_api30/http/http_request.rb +10 -0
  20. data/lib/swagger_petstore_open_api30/http/http_response.rb +10 -0
  21. data/lib/swagger_petstore_open_api30/http/proxy_settings.rb +22 -0
  22. data/lib/swagger_petstore_open_api30/logging/configuration/api_logging_configuration.rb +186 -0
  23. data/lib/swagger_petstore_open_api30/logging/sdk_logger.rb +17 -0
  24. data/lib/swagger_petstore_open_api30/models/api_response.rb +118 -0
  25. data/lib/swagger_petstore_open_api30/models/base_model.rb +110 -0
  26. data/lib/swagger_petstore_open_api30/models/category.rb +105 -0
  27. data/lib/swagger_petstore_open_api30/models/oauth_provider_error.rb +62 -0
  28. data/lib/swagger_petstore_open_api30/models/oauth_scope_petstore_auth.rb +36 -0
  29. data/lib/swagger_petstore_open_api30/models/oauth_token.rb +125 -0
  30. data/lib/swagger_petstore_open_api30/models/order.rb +167 -0
  31. data/lib/swagger_petstore_open_api30/models/order_status.rb +40 -0
  32. data/lib/swagger_petstore_open_api30/models/pet.rb +168 -0
  33. data/lib/swagger_petstore_open_api30/models/pet_status.rb +40 -0
  34. data/lib/swagger_petstore_open_api30/models/tag.rb +105 -0
  35. data/lib/swagger_petstore_open_api30/models/user.rb +182 -0
  36. data/lib/swagger_petstore_open_api30/utilities/date_time_helper.rb +11 -0
  37. data/lib/swagger_petstore_open_api30/utilities/file_wrapper.rb +28 -0
  38. data/lib/swagger_petstore_open_api30/utilities/xml_utilities.rb +12 -0
  39. data/lib/swagger_petstore_open_api30.rb +62 -0
  40. metadata +122 -0
@@ -0,0 +1,131 @@
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
+ # StoreApi
8
+ class StoreApi < BaseApi
9
+ # Returns a map of status codes to quantities.
10
+ # @return [ApiResponse] Complete http response with raw body and status code.
11
+ def get_inventory
12
+ @api_call
13
+ .request(new_request_builder(HttpMethodEnum::GET,
14
+ '/store/inventory',
15
+ Server::DEFAULT)
16
+ .auth(Single.new('api_key')))
17
+ .response(new_response_handler
18
+ .deserializer(APIHelper.method(:deserialize_primitive_types))
19
+ .deserialize_into(proc do |response| response&.to_i end)
20
+ .is_api_response(true)
21
+ .is_primitive_response(true)
22
+ .local_error('default',
23
+ 'Unexpected error',
24
+ APIException))
25
+ .execute
26
+ end
27
+
28
+ # Place a new order in the store.
29
+ # @param [Integer] id Optional parameter: TODO: type description here
30
+ # @param [Integer] pet_id Optional parameter: TODO: type description here
31
+ # @param [Integer] quantity Optional parameter: TODO: type description
32
+ # here
33
+ # @param [DateTime] ship_date Optional parameter: TODO: type description
34
+ # here
35
+ # @param [OrderStatus] status Optional parameter: Order Status
36
+ # @param [TrueClass | FalseClass] complete Optional parameter: TODO: type
37
+ # description here
38
+ # @return [ApiResponse] Complete http response with raw body and status code.
39
+ def place_order(id: nil,
40
+ pet_id: nil,
41
+ quantity: nil,
42
+ ship_date: nil,
43
+ status: nil,
44
+ complete: nil)
45
+ @api_call
46
+ .request(new_request_builder(HttpMethodEnum::POST,
47
+ '/store/order',
48
+ Server::DEFAULT)
49
+ .form_param(new_parameter(id, key: 'id'))
50
+ .form_param(new_parameter(pet_id, key: 'petId'))
51
+ .form_param(new_parameter(quantity, key: 'quantity'))
52
+ .form_param(new_parameter(ship_date, key: 'shipDate'))
53
+ .form_param(new_parameter(status, key: 'status'))
54
+ .form_param(new_parameter(complete, key: 'complete'))
55
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
56
+ .header_param(new_parameter('application/json', key: 'accept')))
57
+ .response(new_response_handler
58
+ .deserializer(APIHelper.method(:custom_type_deserializer))
59
+ .deserialize_into(Order.method(:from_hash))
60
+ .is_api_response(true)
61
+ .local_error('400',
62
+ 'Invalid input',
63
+ APIException)
64
+ .local_error('422',
65
+ 'Validation exception',
66
+ APIException)
67
+ .local_error('default',
68
+ 'Unexpected error',
69
+ APIException))
70
+ .execute
71
+ end
72
+
73
+ # For valid response try integer IDs with value <= 5 or > 10. Other values
74
+ # will generate exceptions.
75
+ # @param [Integer] order_id Required parameter: ID of order that needs to be
76
+ # fetched
77
+ # @return [ApiResponse] Complete http response with raw body and status code.
78
+ def get_order_by_id(order_id)
79
+ @api_call
80
+ .request(new_request_builder(HttpMethodEnum::GET,
81
+ '/store/order/{orderId}',
82
+ Server::DEFAULT)
83
+ .template_param(new_parameter(order_id, key: 'orderId')
84
+ .is_required(true)
85
+ .should_encode(true))
86
+ .header_param(new_parameter('application/json', key: 'accept')))
87
+ .response(new_response_handler
88
+ .deserializer(APIHelper.method(:custom_type_deserializer))
89
+ .deserialize_into(Order.method(:from_hash))
90
+ .is_api_response(true)
91
+ .local_error('400',
92
+ 'Invalid ID supplied',
93
+ APIException)
94
+ .local_error('404',
95
+ 'Order not found',
96
+ APIException)
97
+ .local_error('default',
98
+ 'Unexpected error',
99
+ APIException))
100
+ .execute
101
+ end
102
+
103
+ # For valid response try integer IDs with value < 1000. Anything above 1000
104
+ # or non-integers will generate API errors.
105
+ # @param [Integer] order_id Required parameter: ID of the order that needs
106
+ # to be deleted
107
+ # @return [ApiResponse] Complete http response with raw body and status code.
108
+ def delete_order(order_id)
109
+ @api_call
110
+ .request(new_request_builder(HttpMethodEnum::DELETE,
111
+ '/store/order/{orderId}',
112
+ Server::DEFAULT)
113
+ .template_param(new_parameter(order_id, key: 'orderId')
114
+ .is_required(true)
115
+ .should_encode(true)))
116
+ .response(new_response_handler
117
+ .is_response_void(true)
118
+ .is_api_response(true)
119
+ .local_error('400',
120
+ 'Invalid ID supplied',
121
+ APIException)
122
+ .local_error('404',
123
+ 'Order not found',
124
+ APIException)
125
+ .local_error('default',
126
+ 'Unexpected error',
127
+ APIException))
128
+ .execute
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,233 @@
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
+ # UserApi
8
+ class UserApi < BaseApi
9
+ # This can only be done by the logged in user.
10
+ # @param [Integer] id Optional parameter: TODO: type description here
11
+ # @param [String] username Optional parameter: TODO: type description here
12
+ # @param [String] first_name Optional parameter: TODO: type description
13
+ # here
14
+ # @param [String] last_name Optional parameter: TODO: type description
15
+ # here
16
+ # @param [String] email Optional parameter: TODO: type description here
17
+ # @param [String] password Optional parameter: TODO: type description here
18
+ # @param [String] phone Optional parameter: TODO: type description here
19
+ # @param [Integer] user_status Optional parameter: User Status
20
+ # @return [ApiResponse] Complete http response with raw body and status code.
21
+ def create_user(id: nil,
22
+ username: nil,
23
+ first_name: nil,
24
+ last_name: nil,
25
+ email: nil,
26
+ password: nil,
27
+ phone: nil,
28
+ user_status: nil)
29
+ @api_call
30
+ .request(new_request_builder(HttpMethodEnum::POST,
31
+ '/user',
32
+ Server::DEFAULT)
33
+ .form_param(new_parameter(id, key: 'id'))
34
+ .form_param(new_parameter(username, key: 'username'))
35
+ .form_param(new_parameter(first_name, key: 'firstName'))
36
+ .form_param(new_parameter(last_name, key: 'lastName'))
37
+ .form_param(new_parameter(email, key: 'email'))
38
+ .form_param(new_parameter(password, key: 'password'))
39
+ .form_param(new_parameter(phone, key: 'phone'))
40
+ .form_param(new_parameter(user_status, key: 'userStatus'))
41
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
42
+ .header_param(new_parameter('application/json', key: 'accept')))
43
+ .response(new_response_handler
44
+ .deserializer(APIHelper.method(:custom_type_deserializer))
45
+ .deserialize_into(User.method(:from_hash))
46
+ .is_api_response(true)
47
+ .local_error('default',
48
+ 'Unexpected error',
49
+ APIException))
50
+ .execute
51
+ end
52
+
53
+ # Creates list of users with given input array.
54
+ # @param [Array[User]] body Optional parameter: TODO: type description
55
+ # here
56
+ # @return [ApiResponse] Complete http response with raw body and status code.
57
+ def create_users_with_list_input(body: nil)
58
+ @api_call
59
+ .request(new_request_builder(HttpMethodEnum::POST,
60
+ '/user/createWithList',
61
+ Server::DEFAULT)
62
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
63
+ .body_param(new_parameter(body))
64
+ .header_param(new_parameter('application/json', key: 'accept'))
65
+ .body_serializer(proc do |param| param.to_json unless param.nil? end))
66
+ .response(new_response_handler
67
+ .deserializer(APIHelper.method(:custom_type_deserializer))
68
+ .deserialize_into(User.method(:from_hash))
69
+ .is_api_response(true)
70
+ .local_error('default',
71
+ 'Unexpected error',
72
+ APIException))
73
+ .execute
74
+ end
75
+
76
+ # Log into the system.
77
+ # @param [String] username Optional parameter: The user name for login
78
+ # @param [String] password Optional parameter: The password for login in
79
+ # clear text
80
+ # @return [ApiResponse] Complete http response with raw body and status code.
81
+ def login_user(username: nil,
82
+ password: nil)
83
+ @api_call
84
+ .request(new_request_builder(HttpMethodEnum::GET,
85
+ '/user/login',
86
+ Server::DEFAULT)
87
+ .query_param(new_parameter(username, key: 'username'))
88
+ .query_param(new_parameter(password, key: 'password'))
89
+ .header_param(new_parameter('application/xml', key: 'accept')))
90
+ .response(new_response_handler
91
+ .deserializer(XmlUtilities.method(:deserialize_xml))
92
+ .deserialize_into(String)
93
+ .is_xml_response(true)
94
+ .xml_attribute(XmlAttributes.new
95
+ .root_element_name('response'))
96
+ .is_api_response(true)
97
+ .is_primitive_response(true)
98
+ .local_error('400',
99
+ 'Invalid username/password supplied',
100
+ APIException)
101
+ .local_error('default',
102
+ 'Unexpected error',
103
+ APIException))
104
+ .execute
105
+ end
106
+
107
+ # Log user out of the system.
108
+ # @return [ApiResponse] Complete http response with raw body and status code.
109
+ def logout_user
110
+ @api_call
111
+ .request(new_request_builder(HttpMethodEnum::GET,
112
+ '/user/logout',
113
+ Server::DEFAULT))
114
+ .response(new_response_handler
115
+ .is_response_void(true)
116
+ .is_api_response(true)
117
+ .local_error('default',
118
+ 'Unexpected error',
119
+ APIException))
120
+ .execute
121
+ end
122
+
123
+ # Get user detail based on username.
124
+ # @param [String] usersname Required parameter: The username that needs to
125
+ # be processed
126
+ # @return [ApiResponse] Complete http response with raw body and status code.
127
+ def get_user_by_name(usersname)
128
+ @api_call
129
+ .request(new_request_builder(HttpMethodEnum::GET,
130
+ '/user/{usersname}',
131
+ Server::DEFAULT)
132
+ .template_param(new_parameter(usersname, key: 'usersname')
133
+ .is_required(true)
134
+ .should_encode(true))
135
+ .header_param(new_parameter('application/json', key: 'accept')))
136
+ .response(new_response_handler
137
+ .deserializer(APIHelper.method(:custom_type_deserializer))
138
+ .deserialize_into(User.method(:from_hash))
139
+ .is_api_response(true)
140
+ .local_error('400',
141
+ 'Invalid username supplied',
142
+ APIException)
143
+ .local_error('404',
144
+ 'User not found',
145
+ APIException)
146
+ .local_error('default',
147
+ 'Unexpected error',
148
+ APIException))
149
+ .execute
150
+ end
151
+
152
+ # This can only be done by the logged in user.
153
+ # @param [String] usersname Required parameter: The username that needs to
154
+ # be processed
155
+ # @param [Integer] id Optional parameter: TODO: type description here
156
+ # @param [String] username Optional parameter: TODO: type description here
157
+ # @param [String] first_name Optional parameter: TODO: type description
158
+ # here
159
+ # @param [String] last_name Optional parameter: TODO: type description
160
+ # here
161
+ # @param [String] email Optional parameter: TODO: type description here
162
+ # @param [String] password Optional parameter: TODO: type description here
163
+ # @param [String] phone Optional parameter: TODO: type description here
164
+ # @param [Integer] user_status Optional parameter: User Status
165
+ # @return [ApiResponse] Complete http response with raw body and status code.
166
+ def update_user(usersname,
167
+ id: nil,
168
+ username: nil,
169
+ first_name: nil,
170
+ last_name: nil,
171
+ email: nil,
172
+ password: nil,
173
+ phone: nil,
174
+ user_status: nil)
175
+ @api_call
176
+ .request(new_request_builder(HttpMethodEnum::PUT,
177
+ '/user/{usersname}',
178
+ Server::DEFAULT)
179
+ .template_param(new_parameter(usersname, key: 'usersname')
180
+ .is_required(true)
181
+ .should_encode(true))
182
+ .form_param(new_parameter(id, key: 'id'))
183
+ .form_param(new_parameter(username, key: 'username'))
184
+ .form_param(new_parameter(first_name, key: 'firstName'))
185
+ .form_param(new_parameter(last_name, key: 'lastName'))
186
+ .form_param(new_parameter(email, key: 'email'))
187
+ .form_param(new_parameter(password, key: 'password'))
188
+ .form_param(new_parameter(phone, key: 'phone'))
189
+ .form_param(new_parameter(user_status, key: 'userStatus'))
190
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')))
191
+ .response(new_response_handler
192
+ .is_response_void(true)
193
+ .is_api_response(true)
194
+ .local_error('400',
195
+ 'bad request',
196
+ APIException)
197
+ .local_error('404',
198
+ 'user not found',
199
+ APIException)
200
+ .local_error('default',
201
+ 'Unexpected error',
202
+ APIException))
203
+ .execute
204
+ end
205
+
206
+ # This can only be done by the logged in user.
207
+ # @param [String] usersname Required parameter: The username that needs to
208
+ # be processed
209
+ # @return [ApiResponse] Complete http response with raw body and status code.
210
+ def delete_user(usersname)
211
+ @api_call
212
+ .request(new_request_builder(HttpMethodEnum::DELETE,
213
+ '/user/{usersname}',
214
+ Server::DEFAULT)
215
+ .template_param(new_parameter(usersname, key: 'usersname')
216
+ .is_required(true)
217
+ .should_encode(true)))
218
+ .response(new_response_handler
219
+ .is_response_void(true)
220
+ .is_api_response(true)
221
+ .local_error('400',
222
+ 'Invalid username supplied',
223
+ APIException)
224
+ .local_error('404',
225
+ 'User not found',
226
+ APIException)
227
+ .local_error('default',
228
+ 'Unexpected error',
229
+ APIException))
230
+ .execute
231
+ end
232
+ end
233
+ end
@@ -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
@@ -0,0 +1,181 @@
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
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ PRODUCTION = 'production'.freeze
11
+ ].freeze
12
+
13
+ # Converts a string or symbol into a valid Environment constant.
14
+ def self.from_value(value, default_value = PRODUCTION)
15
+ return default_value if value.nil?
16
+
17
+ default_value
18
+ end
19
+ end
20
+
21
+ # An enum for API servers.
22
+ class Server
23
+ SERVER = [
24
+ DEFAULT = 'default'.freeze,
25
+ AUTH_SERVER = 'auth server'.freeze
26
+ ].freeze
27
+
28
+ # Converts a string or symbol into a valid Server constant.
29
+ def self.from_value(value, default_value = DEFAULT)
30
+ return default_value if value.nil?
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
41
+ end
42
+ end
43
+
44
+ # All configuration including auth info and base URI for the API access
45
+ # are configured in this class.
46
+ class Configuration < CoreLibrary::HttpClientConfiguration
47
+ # The attribute readers for properties.
48
+ attr_reader :environment, :petstore_auth_credentials, :api_key_credentials
49
+
50
+ class << self
51
+ attr_reader :environments
52
+ end
53
+
54
+ def initialize(
55
+ connection: nil, adapter: :net_http_persistent, timeout: 30,
56
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
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
+ )
63
+ super connection: connection, adapter: adapter, timeout: timeout,
64
+ max_retries: max_retries, retry_interval: retry_interval,
65
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
66
+ retry_methods: retry_methods, http_callback: http_callback,
67
+ proxy_settings: proxy_settings,
68
+ logging_configuration: logging_configuration
69
+
70
+ # Current API environment
71
+ @environment = String(environment)
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
+
79
+ # The Http Client to use for making requests.
80
+ set_http_client CoreLibrary::FaradayClient.new(self)
81
+ end
82
+
83
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
84
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
85
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
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
+
104
+ Configuration.new(connection: connection, adapter: adapter,
105
+ timeout: timeout, max_retries: max_retries,
106
+ retry_interval: retry_interval,
107
+ backoff_factor: backoff_factor,
108
+ retry_statuses: retry_statuses,
109
+ retry_methods: retry_methods,
110
+ http_callback: http_callback,
111
+ proxy_settings: proxy_settings,
112
+ logging_configuration: logging_configuration,
113
+ environment: environment,
114
+ petstore_auth_credentials: petstore_auth_credentials,
115
+ api_key_credentials: api_key_credentials)
116
+ end
117
+
118
+
119
+ # All the environments the SDK can run in.
120
+ ENVIRONMENTS = {
121
+ Environment::PRODUCTION => {
122
+ Server::DEFAULT => 'https://petstore3.swagger.io/api/v3',
123
+ Server::AUTH_SERVER => 'https://petstore3.swagger.io/oauth'
124
+ }
125
+ }.freeze
126
+
127
+ # Generates the appropriate base URI for the environment and the server.
128
+ # @param [Configuration::Server] server The server enum for which the base URI is
129
+ # required.
130
+ # @return [String] The base URI.
131
+ def get_base_uri(server = Server::DEFAULT)
132
+ ENVIRONMENTS[environment][server].clone
133
+ end
134
+
135
+ # Builds a Configuration instance using environment variables.
136
+ def self.build_default_config_from_env
137
+ # === Core environment ===
138
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
139
+ timeout = (ENV['TIMEOUT'] || 30).to_f
140
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
141
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
142
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
143
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
144
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
145
+ .split(',')
146
+ .map(&:strip)
147
+ .map do |item|
148
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
149
+ end
150
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put get put]').gsub(/[\[\]]/, '')
151
+ .split(',')
152
+ .map(&:strip)
153
+ .map do |item|
154
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
155
+ end
156
+
157
+ # === Authentication credentials ===
158
+ petstore_auth_credentials = PetstoreAuthCredentials.from_env
159
+ api_key_credentials = ApiKeyCredentials.from_env
160
+
161
+ # === Proxy settings ===
162
+ proxy_settings = ProxySettings.from_env
163
+ # === Logging Configuration ===
164
+ logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured?
165
+
166
+ Configuration.new(
167
+ environment: environment,
168
+ timeout: timeout,
169
+ max_retries: max_retries,
170
+ retry_interval: retry_interval,
171
+ backoff_factor: backoff_factor,
172
+ retry_statuses: retry_statuses,
173
+ retry_methods: retry_methods,
174
+ petstore_auth_credentials: petstore_auth_credentials,
175
+ api_key_credentials: api_key_credentials,
176
+ proxy_settings: proxy_settings,
177
+ logging_configuration: logging_configuration
178
+ )
179
+ end
180
+ end
181
+ end
@@ -0,0 +1,21 @@
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
+ # Class for exceptions when there is a network error, status code error, etc.
8
+ class APIException < CoreLibrary::ApiException
9
+ # Provides a human-readable string representation of the object.
10
+ def to_s
11
+ class_name = self.class.name.split('::').last
12
+ "<#{class_name} status_code: #{@response_code}, reason: #{@reason}>"
13
+ end
14
+
15
+ # Provides a debugging-friendly string with detailed object information.
16
+ def inspect
17
+ class_name = self.class.name.split('::').last
18
+ "<#{class_name} status_code: #{@response_code.inspect}, reason: #{@reason.inspect}>"
19
+ end
20
+ end
21
+ end