petstore-test-sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +90 -0
  4. data/lib/swagger_petstore_open_api30/api_helper.rb +10 -0
  5. data/lib/swagger_petstore_open_api30/client.rb +72 -0
  6. data/lib/swagger_petstore_open_api30/configuration.rb +125 -0
  7. data/lib/swagger_petstore_open_api30/controllers/base_controller.rb +66 -0
  8. data/lib/swagger_petstore_open_api30/controllers/pet_controller.rb +226 -0
  9. data/lib/swagger_petstore_open_api30/controllers/store_controller.rb +107 -0
  10. data/lib/swagger_petstore_open_api30/controllers/user_controller.rb +189 -0
  11. data/lib/swagger_petstore_open_api30/exceptions/api_exception.rb +10 -0
  12. data/lib/swagger_petstore_open_api30/http/auth/custom_header_authentication.rb +42 -0
  13. data/lib/swagger_petstore_open_api30/http/http_call_back.rb +10 -0
  14. data/lib/swagger_petstore_open_api30/http/http_method_enum.rb +10 -0
  15. data/lib/swagger_petstore_open_api30/http/http_request.rb +10 -0
  16. data/lib/swagger_petstore_open_api30/http/http_response.rb +10 -0
  17. data/lib/swagger_petstore_open_api30/models/address.rb +77 -0
  18. data/lib/swagger_petstore_open_api30/models/base_model.rb +62 -0
  19. data/lib/swagger_petstore_open_api30/models/category.rb +59 -0
  20. data/lib/swagger_petstore_open_api30/models/customer.rb +77 -0
  21. data/lib/swagger_petstore_open_api30/models/order.rb +105 -0
  22. data/lib/swagger_petstore_open_api30/models/order_status_enum.rb +26 -0
  23. data/lib/swagger_petstore_open_api30/models/pet.rb +103 -0
  24. data/lib/swagger_petstore_open_api30/models/pet_image.rb +68 -0
  25. data/lib/swagger_petstore_open_api30/models/pet_status_enum.rb +26 -0
  26. data/lib/swagger_petstore_open_api30/models/status_enum.rb +26 -0
  27. data/lib/swagger_petstore_open_api30/models/tag.rb +59 -0
  28. data/lib/swagger_petstore_open_api30/models/user.rb +115 -0
  29. data/lib/swagger_petstore_open_api30/utilities/date_time_helper.rb +11 -0
  30. data/lib/swagger_petstore_open_api30/utilities/file_wrapper.rb +16 -0
  31. data/lib/swagger_petstore_open_api30.rb +53 -0
  32. data/test/controllers/controller_test_base.rb +29 -0
  33. data/test/controllers/test_pet_controller.rb +76 -0
  34. data/test/controllers/test_store_controller.rb +58 -0
  35. data/test/controllers/test_user_controller.rb +55 -0
  36. data/test/http_response_catcher.rb +19 -0
  37. metadata +154 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0022c914268e55bdff04046a245ac07f2cd54f7e7a0ace3ffea09289bcd7a5ef
4
+ data.tar.gz: 5f638292ae5149bd3c6781f7b1a482a0ba57c5c4d38d2fc8c259902d8a8d7d11
5
+ SHA512:
6
+ metadata.gz: 40f1b4d14da30ea329346816697a51f0148a435b8d190e78c686a18423fff00ac3e61c20968ee85ec55bf942b90f9c83346d99da58d3c313e102ba0c4dde61b8
7
+ data.tar.gz: f2ac0d141f27a3b6ef80fdbc1e8e096df9eb02d050b2d374e3d0a8ce1eaf1dca78dc060dabf6f7b119943260c0b559a6e21adcc01b7eb9cf7f03428bcf98604f
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ License:
2
+ ========
3
+ The MIT License (MIT)
4
+ http://opensource.org/licenses/MIT
5
+
6
+ Copyright (c) 2014 - 2024 APIMATIC Limited
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Trade Mark:
27
+ ==========
28
+ APIMATIC is a trade mark for APIMATIC Limited
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+
2
+ # Getting Started with Swagger Petstore - OpenAPI 3.0
3
+
4
+ ## Introduction
5
+
6
+ This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about
7
+ Swagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!
8
+ You can now help us improve the API whether it's by making changes to the definition itself or to the code.
9
+ That way, with time, we can improve the API in general, and expose some of the new features in OAS3.
10
+
11
+ _If you're looking for the Swagger 2.0/OAS 2.0 version of Petstore, then click [here](https://editor.swagger.io/?url=https://petstore.swagger.io/v2/swagger.yaml). Alternatively, you can load via the `Edit > Load Petstore OAS 2.0` menu option!_
12
+
13
+ Some useful links:
14
+
15
+ - [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)
16
+ - [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
17
+
18
+ Find out more about Swagger: [http://swagger.io](http://swagger.io)
19
+
20
+ ## Install the Package
21
+
22
+ Install the gem from the command line:
23
+
24
+ ```ruby
25
+ gem install petstore-test-sdk -v 1.0.0
26
+ ```
27
+
28
+ Or add the gem to your Gemfile and run `bundle`:
29
+
30
+ ```ruby
31
+ gem 'petstore-test-sdk', '1.0.0'
32
+ ```
33
+
34
+ For additional gem details, see the [RubyGems page for the petstore-test-sdk gem](https://rubygems.org/gems/petstore-test-sdk/versions/1.0.0).
35
+
36
+ ## Test the SDK
37
+
38
+ To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
39
+
40
+ ```
41
+ rake
42
+ ```
43
+
44
+ ## Initialize the API Client
45
+
46
+ **_Note:_** Documentation for the client can be found [here.](doc/client.md)
47
+
48
+ The following parameters are configurable for the API Client:
49
+
50
+ | Parameter | Type | Description |
51
+ | --- | --- | --- |
52
+ | `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
53
+ | `adapter` | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
54
+ | `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
55
+ | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
56
+ | `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
57
+ | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
58
+ | `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
59
+ | `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
60
+ | `http_callback` | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
61
+ | `custom_header_authentication_credentials` | [`CustomHeaderAuthenticationCredentials`](__base_path/$a/custom-header-signature.md) | The credential object for Custom Header Signature |
62
+
63
+ The API client can be initialized as follows:
64
+
65
+ ```ruby
66
+ client = SwaggerPetstoreOpenApi30::Client.new(
67
+ custom_header_authentication_credentials: CustomHeaderAuthenticationCredentials.new(
68
+ api_key: 'api_key'
69
+ )
70
+ )
71
+ ```
72
+
73
+ ## Authorization
74
+
75
+ This API uses the following authentication schemes.
76
+
77
+ * [`api_key (Custom Header Signature)`](__base_path/$a/custom-header-signature.md)
78
+
79
+ ## List of APIs
80
+
81
+ * [Pet](doc/controllers/pet.md)
82
+ * [Store](doc/controllers/store.md)
83
+ * [User](doc/controllers/user.md)
84
+
85
+ ## Classes Documentation
86
+
87
+ * [Utility Classes](doc/utility-classes.md)
88
+ * [HttpResponse](doc/http-response.md)
89
+ * [HttpRequest](doc/http-request.md)
90
+
@@ -0,0 +1,10 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,72 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://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
+ # Access to pet controller.
13
+ # @return [PetController] Returns the controller instance.
14
+ def pet
15
+ @pet ||= PetController.new @global_configuration
16
+ end
17
+
18
+ # Access to store controller.
19
+ # @return [StoreController] Returns the controller instance.
20
+ def store
21
+ @store ||= StoreController.new @global_configuration
22
+ end
23
+
24
+ # Access to user controller.
25
+ # @return [UserController] Returns the controller instance.
26
+ def user
27
+ @user ||= UserController.new @global_configuration
28
+ end
29
+
30
+ def initialize(
31
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
32
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
33
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
34
+ retry_methods: %i[get put], http_callback: nil,
35
+ environment: Environment::PRODUCTION, api_key: nil,
36
+ custom_header_authentication_credentials: nil, config: nil
37
+ )
38
+ @config = if config.nil?
39
+ Configuration.new(
40
+ connection: connection, adapter: adapter, timeout: timeout,
41
+ max_retries: max_retries, retry_interval: retry_interval,
42
+ backoff_factor: backoff_factor,
43
+ retry_statuses: retry_statuses,
44
+ retry_methods: retry_methods, http_callback: http_callback,
45
+ environment: environment, api_key: api_key,
46
+ custom_header_authentication_credentials: custom_header_authentication_credentials
47
+ )
48
+ else
49
+ config
50
+ end
51
+
52
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
53
+ .base_uri_executor(@config.method(:get_base_uri))
54
+ .global_errors(BaseController::GLOBAL_ERRORS)
55
+ .user_agent(BaseController.user_agent)
56
+
57
+ initialize_auth_managers(@global_configuration)
58
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
59
+ end
60
+
61
+ # Initializes the auth managers hash used for authenticating API calls.
62
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
63
+ def initialize_auth_managers(global_config)
64
+ @auth_managers = {}
65
+ http_client_config = global_config.client_configuration
66
+ %w[api_key].each { |auth| @auth_managers[auth] = nil }
67
+ @auth_managers['api_key'] = CustomHeaderAuthentication.new(
68
+ http_client_config.custom_header_authentication_credentials
69
+ )
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,125 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ PRODUCTION = 'production'.freeze
11
+ ].freeze
12
+ end
13
+
14
+ # An enum for API servers.
15
+ class Server
16
+ SERVER = [
17
+ DEFAULT = 'default'.freeze
18
+ ].freeze
19
+ end
20
+
21
+ # All configuration including auth info and base URI for the API access
22
+ # are configured in this class.
23
+ class Configuration < CoreLibrary::HttpClientConfiguration
24
+ def api_key
25
+ @custom_header_authentication_credentials.api_key
26
+ end
27
+
28
+ # The attribute readers for properties.
29
+ attr_reader :environment, :custom_header_authentication_credentials
30
+
31
+ class << self
32
+ attr_reader :environments
33
+ end
34
+
35
+ def initialize(
36
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
37
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
38
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
39
+ retry_methods: %i[get put], http_callback: nil,
40
+ environment: Environment::PRODUCTION, api_key: nil,
41
+ custom_header_authentication_credentials: nil
42
+ )
43
+
44
+ super connection: connection, adapter: adapter, timeout: timeout,
45
+ max_retries: max_retries, retry_interval: retry_interval,
46
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
47
+ retry_methods: retry_methods, http_callback: http_callback
48
+
49
+ # Current API environment
50
+ @environment = String(environment)
51
+
52
+ # TODO: Replace
53
+ @api_key = api_key
54
+
55
+ # Initializing Custom Header Signature credentials with the provided auth parameters
56
+ @custom_header_authentication_credentials = create_auth_credentials_object(
57
+ api_key, custom_header_authentication_credentials
58
+ )
59
+
60
+ # The Http Client to use for making requests.
61
+ set_http_client CoreLibrary::FaradayClient.new(self)
62
+ end
63
+
64
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
65
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
66
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
67
+ environment: nil, api_key: nil,
68
+ custom_header_authentication_credentials: nil)
69
+ connection ||= self.connection
70
+ adapter ||= self.adapter
71
+ timeout ||= self.timeout
72
+ max_retries ||= self.max_retries
73
+ retry_interval ||= self.retry_interval
74
+ backoff_factor ||= self.backoff_factor
75
+ retry_statuses ||= self.retry_statuses
76
+ retry_methods ||= self.retry_methods
77
+ http_callback ||= self.http_callback
78
+ environment ||= self.environment
79
+ custom_header_authentication_credentials = create_auth_credentials_object(
80
+ api_key,
81
+ custom_header_authentication_credentials || self.custom_header_authentication_credentials
82
+ )
83
+
84
+ Configuration.new(
85
+ connection: connection, adapter: adapter, timeout: timeout,
86
+ max_retries: max_retries, retry_interval: retry_interval,
87
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
88
+ retry_methods: retry_methods, http_callback: http_callback,
89
+ environment: environment,
90
+ custom_header_authentication_credentials: custom_header_authentication_credentials
91
+ )
92
+ end
93
+
94
+ def create_auth_credentials_object(api_key,
95
+ custom_header_authentication_credentials)
96
+ return custom_header_authentication_credentials if api_key.nil?
97
+
98
+ warn('The \'api_key\' params are deprecated. Use \'custom_header_authent'\
99
+ 'ication_credentials\' param instead.')
100
+
101
+ unless custom_header_authentication_credentials.nil?
102
+ return custom_header_authentication_credentials.clone_with(
103
+ api_key: api_key
104
+ )
105
+ end
106
+
107
+ CustomHeaderAuthenticationCredentials.new(api_key: api_key)
108
+ end
109
+
110
+ # All the environments the SDK can run in.
111
+ ENVIRONMENTS = {
112
+ Environment::PRODUCTION => {
113
+ Server::DEFAULT => 'https://petstore3.swagger.io/api/v3'
114
+ }
115
+ }.freeze
116
+
117
+ # Generates the appropriate base URI for the environment and the server.
118
+ # @param [Configuration::Server] server The server enum for which the base URI is
119
+ # required.
120
+ # @return [String] The base URI.
121
+ def get_base_uri(server = Server::DEFAULT)
122
+ ENVIRONMENTS[environment][server].clone
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,66 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # BaseController.
8
+ class BaseController
9
+ include CoreLibrary
10
+ attr_accessor :config, :http_call_back
11
+
12
+ def self.user_agent
13
+ 'APIMATIC 3.0'
14
+ end
15
+
16
+
17
+ GLOBAL_ERRORS = {
18
+ 'default' => ErrorCase.new
19
+ .error_message('HTTP response not OK.')
20
+ .exception_type(APIException)
21
+ }.freeze
22
+
23
+ # Initialization constructor.
24
+ # @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
25
+ def initialize(global_configuration)
26
+ @global_configuration = global_configuration
27
+ @config = @global_configuration.client_configuration
28
+ @http_call_back = @config.http_callback
29
+ @api_call = ApiCall.new(@global_configuration)
30
+ end
31
+
32
+ # Creates a new builder for the Api Call instance.
33
+ # @return [ApiCall] The instance of ApiCall.
34
+ def new_api_call_builder
35
+ @api_call.new_builder
36
+ end
37
+
38
+ # Creates a new instance of the request builder.
39
+ # @param [String] http_method The HTTP method to use in the request.
40
+ # @param [String] path The endpoint path to use in the request.
41
+ # @param [String] server The server to extract the base uri for the request.
42
+ # @return [RequestBuilder] The instance of RequestBuilder.
43
+ def new_request_builder(http_method, path, server)
44
+ RequestBuilder.new
45
+ .http_method(http_method)
46
+ .path(path)
47
+ .server(server)
48
+ end
49
+
50
+ # Creates a new instance of the response handler.
51
+ # @return [ResponseHandler] The instance of ResponseHandler.
52
+ def new_response_handler
53
+ ResponseHandler.new
54
+ end
55
+
56
+ # Creates a new instance of the parameter.
57
+ # @param [String|optional] key The key of the parameter.
58
+ # @param [Object] value The value of the parameter.
59
+ # @return [Parameter] The instance of Parameter.
60
+ def new_parameter(value, key: nil)
61
+ Parameter.new
62
+ .key(key)
63
+ .value(value)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,226 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # PetController
8
+ class PetController < BaseController
9
+ # Add a new pet to the store
10
+ # @param [String] name Required parameter: Example:
11
+ # @param [Array[String]] photo_urls Required parameter: Example:
12
+ # @param [Integer] id Optional parameter: Example:
13
+ # @param [Category] category Optional parameter: Example:
14
+ # @param [Array[Tag]] tags Optional parameter: Example:
15
+ # @param [PetStatusEnum] pet_status Optional parameter: pet status in the
16
+ # store
17
+ # @return [Pet] response from the API call
18
+ def add_pet(name,
19
+ photo_urls,
20
+ id: nil,
21
+ category: nil,
22
+ tags: nil,
23
+ pet_status: nil)
24
+ new_api_call_builder
25
+ .request(new_request_builder(HttpMethodEnum::POST,
26
+ '/pet',
27
+ Server::DEFAULT)
28
+ .form_param(new_parameter(name, key: 'name'))
29
+ .form_param(new_parameter(photo_urls, key: 'photoUrls'))
30
+ .form_param(new_parameter(id, key: 'id'))
31
+ .form_param(new_parameter(category, key: 'category'))
32
+ .form_param(new_parameter(tags, key: 'tags'))
33
+ .form_param(new_parameter(pet_status, key: 'petStatus'))
34
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
35
+ .header_param(new_parameter('application/json', key: 'accept')))
36
+ .response(new_response_handler
37
+ .deserializer(APIHelper.method(:custom_type_deserializer))
38
+ .deserialize_into(Pet.method(:from_hash))
39
+ .local_error('405',
40
+ 'Invalid input',
41
+ APIException))
42
+ .execute
43
+ end
44
+
45
+ # Multiple tags can be provided with comma separated strings. Use tag1,
46
+ # tag2, tag3 for testing.
47
+ # @param [Array[String]] tags Optional parameter: Tags to filter by
48
+ # @return [Array[Pet]] response from the API call
49
+ def find_pets_by_tags(tags: nil)
50
+ new_api_call_builder
51
+ .request(new_request_builder(HttpMethodEnum::GET,
52
+ '/pet/findByTags',
53
+ Server::DEFAULT)
54
+ .query_param(new_parameter(tags, key: 'tags'))
55
+ .header_param(new_parameter('application/json', key: 'accept')))
56
+ .response(new_response_handler
57
+ .deserializer(APIHelper.method(:custom_type_deserializer))
58
+ .deserialize_into(Pet.method(:from_hash))
59
+ .is_response_array(true)
60
+ .local_error('400',
61
+ 'Invalid tag value',
62
+ APIException))
63
+ .execute
64
+ end
65
+
66
+ # delete a pet
67
+ # @param [Integer] pet_id Required parameter: Pet id to delete
68
+ # @param [String] api_key Optional parameter: Example:
69
+ # @return [void] response from the API call
70
+ def delete_pet(pet_id,
71
+ api_key: nil)
72
+ new_api_call_builder
73
+ .request(new_request_builder(HttpMethodEnum::DELETE,
74
+ '/pet/{petId}',
75
+ Server::DEFAULT)
76
+ .template_param(new_parameter(pet_id, key: 'petId')
77
+ .should_encode(true))
78
+ .header_param(new_parameter(api_key, key: 'api_key')))
79
+ .response(new_response_handler
80
+ .is_response_void(true)
81
+ .local_error('400',
82
+ 'Invalid pet value',
83
+ APIException))
84
+ .execute
85
+ end
86
+
87
+ # Returns a single pet
88
+ # @param [Integer] pet_id Required parameter: ID of pet to return
89
+ # @return [Pet] response from the API call
90
+ def get_pet_by_id(pet_id)
91
+ new_api_call_builder
92
+ .request(new_request_builder(HttpMethodEnum::GET,
93
+ '/pet/{petId}',
94
+ Server::DEFAULT)
95
+ .template_param(new_parameter(pet_id, key: 'petId')
96
+ .should_encode(true))
97
+ .header_param(new_parameter('application/json', key: 'accept'))
98
+ .auth(Single.new('api_key')))
99
+ .response(new_response_handler
100
+ .deserializer(APIHelper.method(:custom_type_deserializer))
101
+ .deserialize_into(Pet.method(:from_hash))
102
+ .local_error('400',
103
+ 'Invalid ID supplied',
104
+ APIException)
105
+ .local_error('404',
106
+ 'Pet not found',
107
+ APIException))
108
+ .execute
109
+ end
110
+
111
+ # TODO: type endpoint description here
112
+ # @param [Integer] pet_id Required parameter: ID of pet that needs to be
113
+ # updated
114
+ # @param [String] name Optional parameter: Name of pet that needs to be
115
+ # updated
116
+ # @param [String] status Optional parameter: Status of pet that needs to be
117
+ # updated
118
+ # @return [void] response from the API call
119
+ def update_pet_with_form(pet_id,
120
+ name: nil,
121
+ status: nil)
122
+ new_api_call_builder
123
+ .request(new_request_builder(HttpMethodEnum::POST,
124
+ '/pet/{petId}',
125
+ Server::DEFAULT)
126
+ .template_param(new_parameter(pet_id, key: 'petId')
127
+ .should_encode(true))
128
+ .query_param(new_parameter(name, key: 'name'))
129
+ .query_param(new_parameter(status, key: 'status')))
130
+ .response(new_response_handler
131
+ .is_response_void(true)
132
+ .local_error('405',
133
+ 'Invalid input',
134
+ APIException))
135
+ .execute
136
+ end
137
+
138
+ # TODO: type endpoint description here
139
+ # @param [Integer] pet_id Required parameter: ID of pet to update
140
+ # @param [String] additional_metadata Optional parameter: Additional
141
+ # Metadata
142
+ # @param [File | UploadIO] body Optional parameter: Example:
143
+ # @return [PetImage] response from the API call
144
+ def upload_file(pet_id,
145
+ additional_metadata: nil,
146
+ body: nil)
147
+ new_api_call_builder
148
+ .request(new_request_builder(HttpMethodEnum::POST,
149
+ '/pet/{petId}/uploadImage',
150
+ Server::DEFAULT)
151
+ .template_param(new_parameter(pet_id, key: 'petId')
152
+ .should_encode(true))
153
+ .query_param(new_parameter(additional_metadata, key: 'additionalMetadata'))
154
+ .multipart_param(new_parameter(body, key: 'body')
155
+ .default_content_type('application/octet-stream'))
156
+ .header_param(new_parameter('application/json', key: 'accept')))
157
+ .response(new_response_handler
158
+ .deserializer(APIHelper.method(:custom_type_deserializer))
159
+ .deserialize_into(PetImage.method(:from_hash)))
160
+ .execute
161
+ end
162
+
163
+ # Update an existing pet by Id
164
+ # @param [String] name Required parameter: Example:
165
+ # @param [Array[String]] photo_urls Required parameter: Example:
166
+ # @param [Integer] id Optional parameter: Example:
167
+ # @param [Category] category Optional parameter: Example:
168
+ # @param [Array[Tag]] tags Optional parameter: Example:
169
+ # @param [PetStatusEnum] pet_status Optional parameter: pet status in the
170
+ # store
171
+ # @return [Pet] response from the API call
172
+ def update_pet(name,
173
+ photo_urls,
174
+ id: nil,
175
+ category: nil,
176
+ tags: nil,
177
+ pet_status: nil)
178
+ new_api_call_builder
179
+ .request(new_request_builder(HttpMethodEnum::PUT,
180
+ '/pet',
181
+ Server::DEFAULT)
182
+ .form_param(new_parameter(name, key: 'name'))
183
+ .form_param(new_parameter(photo_urls, key: 'photoUrls'))
184
+ .form_param(new_parameter(id, key: 'id'))
185
+ .form_param(new_parameter(category, key: 'category'))
186
+ .form_param(new_parameter(tags, key: 'tags'))
187
+ .form_param(new_parameter(pet_status, key: 'petStatus'))
188
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
189
+ .header_param(new_parameter('application/json', key: 'accept')))
190
+ .response(new_response_handler
191
+ .deserializer(APIHelper.method(:custom_type_deserializer))
192
+ .deserialize_into(Pet.method(:from_hash))
193
+ .local_error('400',
194
+ 'Invalid ID supplied',
195
+ APIException)
196
+ .local_error('404',
197
+ 'Pet not found',
198
+ APIException)
199
+ .local_error('405',
200
+ 'Validation exception',
201
+ APIException))
202
+ .execute
203
+ end
204
+
205
+ # Multiple status values can be provided with comma separated strings
206
+ # @param [StatusEnum] status Optional parameter: Status values that need to
207
+ # be considered for filter
208
+ # @return [Array[Pet]] response from the API call
209
+ def find_pets_by_status(status: StatusEnum::AVAILABLE)
210
+ new_api_call_builder
211
+ .request(new_request_builder(HttpMethodEnum::GET,
212
+ '/pet/findByStatus',
213
+ Server::DEFAULT)
214
+ .query_param(new_parameter(status, key: 'status'))
215
+ .header_param(new_parameter('application/json', key: 'accept')))
216
+ .response(new_response_handler
217
+ .deserializer(APIHelper.method(:custom_type_deserializer))
218
+ .deserialize_into(Pet.method(:from_hash))
219
+ .is_response_array(true)
220
+ .local_error('400',
221
+ 'Invalid status value',
222
+ APIException))
223
+ .execute
224
+ end
225
+ end
226
+ end