chainlink-apimatic-sdk 0.0.1

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 +181 -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 +94 -0
  11. data/lib/swagger_petstore_open_api30/configuration.rb +180 -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 +123 -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,94 @@
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],
43
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
44
+ logging_configuration: nil, environment: Environment::PRODUCTION,
45
+ petstore_auth_credentials: nil, api_key_credentials: nil, config: nil
46
+ )
47
+ @config = if config.nil?
48
+ Configuration.new(
49
+ connection: connection, adapter: adapter, timeout: timeout,
50
+ max_retries: max_retries, retry_interval: retry_interval,
51
+ backoff_factor: backoff_factor,
52
+ retry_statuses: retry_statuses,
53
+ retry_methods: retry_methods, http_callback: http_callback,
54
+ proxy_settings: proxy_settings,
55
+ logging_configuration: logging_configuration,
56
+ environment: environment,
57
+ petstore_auth_credentials: petstore_auth_credentials,
58
+ api_key_credentials: api_key_credentials
59
+ )
60
+ else
61
+ config
62
+ end
63
+ user_agent_params = BaseApi.user_agent_parameters
64
+
65
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
66
+ .base_uri_executor(@config.method(:get_base_uri))
67
+ .global_errors(BaseApi::GLOBAL_ERRORS)
68
+ .user_agent(BaseApi.user_agent,
69
+ agent_parameters: user_agent_params)
70
+
71
+ initialize_auth_managers(@global_configuration)
72
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
73
+ end
74
+
75
+ # Initializes the auth managers hash used for authenticating API calls.
76
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
77
+ def initialize_auth_managers(global_config)
78
+ @auth_managers = {}
79
+ http_client_config = global_config.client_configuration
80
+ %w[petstore_auth api_key].each { |auth| @auth_managers[auth] = nil }
81
+ @auth_managers['petstore_auth'] = PetstoreAuth.new(
82
+ http_client_config.petstore_auth_credentials, global_config
83
+ )
84
+ @auth_managers['api_key'] = ApiKey.new(http_client_config.api_key_credentials)
85
+ end
86
+
87
+ # Creates a client directly from environment variables.
88
+ def self.from_env(**overrides)
89
+ default_config = Configuration.build_default_config_from_env
90
+ new_config = default_config.clone_with(**overrides)
91
+ new(config: new_config)
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,180 @@
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],
58
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
59
+ logging_configuration: nil, environment: Environment::PRODUCTION,
60
+ petstore_auth_credentials: nil, api_key_credentials: nil
61
+ )
62
+ super connection: connection, adapter: adapter, timeout: timeout,
63
+ max_retries: max_retries, retry_interval: retry_interval,
64
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
65
+ retry_methods: retry_methods, http_callback: http_callback,
66
+ proxy_settings: proxy_settings,
67
+ logging_configuration: logging_configuration
68
+
69
+ # Current API environment
70
+ @environment = String(environment)
71
+
72
+ # The object holding OAuth 2 Implicit Grant credentials
73
+ @petstore_auth_credentials = petstore_auth_credentials
74
+
75
+ # The object holding Custom Header Signature credentials
76
+ @api_key_credentials = api_key_credentials
77
+
78
+ # The Http Client to use for making requests.
79
+ set_http_client CoreLibrary::FaradayClient.new(self)
80
+ end
81
+
82
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
83
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
84
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
85
+ proxy_settings: nil, logging_configuration: nil,
86
+ environment: nil, petstore_auth_credentials: nil,
87
+ api_key_credentials: nil)
88
+ connection ||= self.connection
89
+ adapter ||= self.adapter
90
+ timeout ||= self.timeout
91
+ max_retries ||= self.max_retries
92
+ retry_interval ||= self.retry_interval
93
+ backoff_factor ||= self.backoff_factor
94
+ retry_statuses ||= self.retry_statuses
95
+ retry_methods ||= self.retry_methods
96
+ http_callback ||= self.http_callback
97
+ proxy_settings ||= self.proxy_settings
98
+ logging_configuration ||= self.logging_configuration
99
+ environment ||= self.environment
100
+ petstore_auth_credentials ||= self.petstore_auth_credentials
101
+ api_key_credentials ||= self.api_key_credentials
102
+
103
+ Configuration.new(connection: connection, adapter: adapter,
104
+ timeout: timeout, max_retries: max_retries,
105
+ retry_interval: retry_interval,
106
+ backoff_factor: backoff_factor,
107
+ retry_statuses: retry_statuses,
108
+ retry_methods: retry_methods,
109
+ http_callback: http_callback,
110
+ proxy_settings: proxy_settings,
111
+ logging_configuration: logging_configuration,
112
+ environment: environment,
113
+ petstore_auth_credentials: petstore_auth_credentials,
114
+ api_key_credentials: api_key_credentials)
115
+ end
116
+
117
+
118
+ # All the environments the SDK can run in.
119
+ ENVIRONMENTS = {
120
+ Environment::PRODUCTION => {
121
+ Server::DEFAULT => 'https://petstore3.swagger.io/api/v3',
122
+ Server::AUTH_SERVER => 'https://petstore3.swagger.io/oauth'
123
+ }
124
+ }.freeze
125
+
126
+ # Generates the appropriate base URI for the environment and the server.
127
+ # @param [Configuration::Server] server The server enum for which the base URI is
128
+ # required.
129
+ # @return [String] The base URI.
130
+ def get_base_uri(server = Server::DEFAULT)
131
+ ENVIRONMENTS[environment][server].clone
132
+ end
133
+
134
+ # Builds a Configuration instance using environment variables.
135
+ def self.build_default_config_from_env
136
+ # === Core environment ===
137
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
138
+ timeout = (ENV['TIMEOUT'] || 30).to_f
139
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
140
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
141
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
142
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
143
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
144
+ .split(',')
145
+ .map(&:strip)
146
+ .map do |item|
147
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
148
+ end
149
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
150
+ .split(',')
151
+ .map(&:strip)
152
+ .map do |item|
153
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
154
+ end
155
+
156
+ # === Authentication credentials ===
157
+ petstore_auth_credentials = PetstoreAuthCredentials.from_env
158
+ api_key_credentials = ApiKeyCredentials.from_env
159
+
160
+ # === Proxy settings ===
161
+ proxy_settings = ProxySettings.from_env
162
+ # === Logging Configuration ===
163
+ logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured?
164
+
165
+ Configuration.new(
166
+ environment: environment,
167
+ timeout: timeout,
168
+ max_retries: max_retries,
169
+ retry_interval: retry_interval,
170
+ backoff_factor: backoff_factor,
171
+ retry_statuses: retry_statuses,
172
+ retry_methods: retry_methods,
173
+ petstore_auth_credentials: petstore_auth_credentials,
174
+ api_key_credentials: api_key_credentials,
175
+ proxy_settings: proxy_settings,
176
+ logging_configuration: logging_configuration
177
+ )
178
+ end
179
+ end
180
+ 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