petstore-pets 1.0.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 (37) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +96 -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 +21 -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 +90 -0
  18. data/lib/swagger_petstore_open_api30/models/base_model.rb +110 -0
  19. data/lib/swagger_petstore_open_api30/models/category.rb +71 -0
  20. data/lib/swagger_petstore_open_api30/models/customer.rb +90 -0
  21. data/lib/swagger_petstore_open_api30/models/order.rb +120 -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 +118 -0
  24. data/lib/swagger_petstore_open_api30/models/pet_image.rb +81 -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 +71 -0
  28. data/lib/swagger_petstore_open_api30/models/user.rb +132 -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 +28 -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 +50 -0
  34. data/test/controllers/test_store_controller.rb +56 -0
  35. data/test/controllers/test_user_controller.rb +53 -0
  36. data/test/http_response_catcher.rb +19 -0
  37. metadata +147 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f0a7aed9fa819b5492fa756ec9db1377eae99420147ede5e94b1f82c6de132fa
4
+ data.tar.gz: a3dc6175b7f71f2eaab7d36587fbf87abeb97db0c7752df1a87624699dcf092c
5
+ SHA512:
6
+ metadata.gz: 02cd14e5fdab2f1f94299b89b02ff17589056fec933b9f58bade65df90308fe97b8bb36d814f7b220d6c740ff355f69647b76030405470743c05ba4064425d6a
7
+ data.tar.gz: c9120abcbfa4be699e72aac5871afaf18b20c8a868b6d79d0826da63d6cb528eff0774c74d50b83a40c2187549297d105d8be95d52b82a0d76bd4454bc109a2f
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 - 2025 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,96 @@
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
+ ```bash
25
+ gem install petstore-pets -v 1.0.0
26
+ ```
27
+
28
+ Or add the gem to your Gemfile and run `bundle`:
29
+
30
+ ```ruby
31
+ gem 'petstore-pets', '1.0.0'
32
+ ```
33
+
34
+ For additional gem details, see the [RubyGems page for the petstore-pets gem](https://rubygems.org/gems/petstore-pets/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/auth/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/auth/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
+ ## SDK Infrastructure
86
+
87
+ ### HTTP
88
+
89
+ * [HttpResponse](doc/http-response.md)
90
+ * [HttpRequest](doc/http-request.md)
91
+
92
+ ### Utilities
93
+
94
+ * [ApiHelper](doc/api-helper.md)
95
+ * [DateTimeHelper](doc/date-time-helper.md)
96
+
@@ -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
+ # Multiple tags can be provided with comma separated strings. Use tag1,
10
+ # tag2, tag3 for testing.
11
+ # @param [Array[String]] tags Optional parameter: Tags to filter by
12
+ # @return [Array[Pet]] response from the API call.
13
+ def find_pets_by_tags(tags: nil)
14
+ new_api_call_builder
15
+ .request(new_request_builder(HttpMethodEnum::GET,
16
+ '/pet/findByTags',
17
+ Server::DEFAULT)
18
+ .query_param(new_parameter(tags, key: 'tags'))
19
+ .header_param(new_parameter('application/json', key: 'accept')))
20
+ .response(new_response_handler
21
+ .deserializer(APIHelper.method(:custom_type_deserializer))
22
+ .deserialize_into(Pet.method(:from_hash))
23
+ .is_response_array(true)
24
+ .local_error('400',
25
+ 'Invalid tag value',
26
+ APIException))
27
+ .execute
28
+ end
29
+
30
+ # delete a pet
31
+ # @param [Integer] pet_id Required parameter: Pet id to delete
32
+ # @param [String] api_key Optional parameter: Example:
33
+ # @return [void] response from the API call.
34
+ def delete_pet(pet_id,
35
+ api_key: nil)
36
+ new_api_call_builder
37
+ .request(new_request_builder(HttpMethodEnum::DELETE,
38
+ '/pet/{petId}',
39
+ Server::DEFAULT)
40
+ .template_param(new_parameter(pet_id, key: 'petId')
41
+ .should_encode(true))
42
+ .header_param(new_parameter(api_key, key: 'api_key')))
43
+ .response(new_response_handler
44
+ .is_response_void(true)
45
+ .local_error('400',
46
+ 'Invalid pet value',
47
+ APIException))
48
+ .execute
49
+ end
50
+
51
+ # TODO: type endpoint description here
52
+ # @param [Integer] pet_id Required parameter: ID of pet to update
53
+ # @param [String] additional_metadata Optional parameter: Additional
54
+ # Metadata
55
+ # @param [File | UploadIO] body Optional parameter: Example:
56
+ # @return [PetImage] response from the API call.
57
+ def upload_file(pet_id,
58
+ additional_metadata: nil,
59
+ body: nil)
60
+ new_api_call_builder
61
+ .request(new_request_builder(HttpMethodEnum::POST,
62
+ '/pet/{petId}/uploadImage',
63
+ Server::DEFAULT)
64
+ .template_param(new_parameter(pet_id, key: 'petId')
65
+ .should_encode(true))
66
+ .query_param(new_parameter(additional_metadata, key: 'additionalMetadata'))
67
+ .multipart_param(new_parameter(body, key: 'body')
68
+ .default_content_type('application/octet-stream'))
69
+ .header_param(new_parameter('application/json', key: 'accept')))
70
+ .response(new_response_handler
71
+ .deserializer(APIHelper.method(:custom_type_deserializer))
72
+ .deserialize_into(PetImage.method(:from_hash)))
73
+ .execute
74
+ end
75
+
76
+ # Update an existing pet by Id
77
+ # @param [String] name Required parameter: Example:
78
+ # @param [Array[String]] photo_urls Required parameter: Example:
79
+ # @param [Integer] id Optional parameter: Example:
80
+ # @param [Category] category Optional parameter: Example:
81
+ # @param [Array[Tag]] tags Optional parameter: Example:
82
+ # @param [PetStatusEnum] pet_status Optional parameter: pet status in the
83
+ # store
84
+ # @return [Pet] response from the API call.
85
+ def update_pet(name,
86
+ photo_urls,
87
+ id: nil,
88
+ category: nil,
89
+ tags: nil,
90
+ pet_status: nil)
91
+ new_api_call_builder
92
+ .request(new_request_builder(HttpMethodEnum::PUT,
93
+ '/pet',
94
+ Server::DEFAULT)
95
+ .form_param(new_parameter(name, key: 'name'))
96
+ .form_param(new_parameter(photo_urls, key: 'photoUrls'))
97
+ .form_param(new_parameter(id, key: 'id'))
98
+ .form_param(new_parameter(category, key: 'category'))
99
+ .form_param(new_parameter(tags, key: 'tags'))
100
+ .form_param(new_parameter(pet_status, key: 'petStatus'))
101
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
102
+ .header_param(new_parameter('application/json', key: 'accept')))
103
+ .response(new_response_handler
104
+ .deserializer(APIHelper.method(:custom_type_deserializer))
105
+ .deserialize_into(Pet.method(:from_hash))
106
+ .local_error('400',
107
+ 'Invalid ID supplied',
108
+ APIException)
109
+ .local_error('404',
110
+ 'Pet not found',
111
+ APIException)
112
+ .local_error('405',
113
+ 'Validation exception',
114
+ APIException))
115
+ .execute
116
+ end
117
+
118
+ # Add a new pet to the store
119
+ # @param [String] name Required parameter: Example:
120
+ # @param [Array[String]] photo_urls Required parameter: Example:
121
+ # @param [Integer] id Optional parameter: Example:
122
+ # @param [Category] category Optional parameter: Example:
123
+ # @param [Array[Tag]] tags Optional parameter: Example:
124
+ # @param [PetStatusEnum] pet_status Optional parameter: pet status in the
125
+ # store
126
+ # @return [Pet] response from the API call.
127
+ def add_pet(name,
128
+ photo_urls,
129
+ id: nil,
130
+ category: nil,
131
+ tags: nil,
132
+ pet_status: nil)
133
+ new_api_call_builder
134
+ .request(new_request_builder(HttpMethodEnum::POST,
135
+ '/pet',
136
+ Server::DEFAULT)
137
+ .form_param(new_parameter(name, key: 'name'))
138
+ .form_param(new_parameter(photo_urls, key: 'photoUrls'))
139
+ .form_param(new_parameter(id, key: 'id'))
140
+ .form_param(new_parameter(category, key: 'category'))
141
+ .form_param(new_parameter(tags, key: 'tags'))
142
+ .form_param(new_parameter(pet_status, key: 'petStatus'))
143
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
144
+ .header_param(new_parameter('application/json', key: 'accept')))
145
+ .response(new_response_handler
146
+ .deserializer(APIHelper.method(:custom_type_deserializer))
147
+ .deserialize_into(Pet.method(:from_hash))
148
+ .local_error('405',
149
+ 'Invalid input',
150
+ APIException))
151
+ .execute
152
+ end
153
+
154
+ # Returns a single pet
155
+ # @param [Integer] pet_id Required parameter: ID of pet to return
156
+ # @return [Pet] response from the API call.
157
+ def get_pet_by_id(pet_id)
158
+ new_api_call_builder
159
+ .request(new_request_builder(HttpMethodEnum::GET,
160
+ '/pet/{petId}',
161
+ Server::DEFAULT)
162
+ .template_param(new_parameter(pet_id, key: 'petId')
163
+ .should_encode(true))
164
+ .header_param(new_parameter('application/json', key: 'accept'))
165
+ .auth(Single.new('api_key')))
166
+ .response(new_response_handler
167
+ .deserializer(APIHelper.method(:custom_type_deserializer))
168
+ .deserialize_into(Pet.method(:from_hash))
169
+ .local_error('400',
170
+ 'Invalid ID supplied',
171
+ APIException)
172
+ .local_error('404',
173
+ 'Pet not found',
174
+ APIException))
175
+ .execute
176
+ end
177
+
178
+ # Multiple status values can be provided with comma separated strings
179
+ # @param [StatusEnum] status Optional parameter: Status values that need to
180
+ # be considered for filter
181
+ # @return [Array[Pet]] response from the API call.
182
+ def find_pets_by_status(status: StatusEnum::AVAILABLE)
183
+ new_api_call_builder
184
+ .request(new_request_builder(HttpMethodEnum::GET,
185
+ '/pet/findByStatus',
186
+ Server::DEFAULT)
187
+ .query_param(new_parameter(status, key: 'status'))
188
+ .header_param(new_parameter('application/json', key: 'accept')))
189
+ .response(new_response_handler
190
+ .deserializer(APIHelper.method(:custom_type_deserializer))
191
+ .deserialize_into(Pet.method(:from_hash))
192
+ .is_response_array(true)
193
+ .local_error('400',
194
+ 'Invalid status value',
195
+ APIException))
196
+ .execute
197
+ end
198
+
199
+ # TODO: type endpoint description here
200
+ # @param [Integer] pet_id Required parameter: ID of pet that needs to be
201
+ # updated
202
+ # @param [String] name Optional parameter: Name of pet that needs to be
203
+ # updated
204
+ # @param [String] status Optional parameter: Status of pet that needs to be
205
+ # updated
206
+ # @return [void] response from the API call.
207
+ def update_pet_with_form(pet_id,
208
+ name: nil,
209
+ status: nil)
210
+ new_api_call_builder
211
+ .request(new_request_builder(HttpMethodEnum::POST,
212
+ '/pet/{petId}',
213
+ Server::DEFAULT)
214
+ .template_param(new_parameter(pet_id, key: 'petId')
215
+ .should_encode(true))
216
+ .query_param(new_parameter(name, key: 'name'))
217
+ .query_param(new_parameter(status, key: 'status')))
218
+ .response(new_response_handler
219
+ .is_response_void(true)
220
+ .local_error('405',
221
+ 'Invalid input',
222
+ APIException))
223
+ .execute
224
+ end
225
+ end
226
+ end