apimaticPetstore 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +119 -0
  4. data/lib/swagger_petstore/api_helper.rb +10 -0
  5. data/lib/swagger_petstore/client.rb +76 -0
  6. data/lib/swagger_petstore/configuration.rb +125 -0
  7. data/lib/swagger_petstore/controllers/base_controller.rb +65 -0
  8. data/lib/swagger_petstore/controllers/pet_controller.rb +221 -0
  9. data/lib/swagger_petstore/controllers/store_controller.rb +104 -0
  10. data/lib/swagger_petstore/controllers/user_controller.rb +197 -0
  11. data/lib/swagger_petstore/exceptions/api_exception.rb +10 -0
  12. data/lib/swagger_petstore/exceptions/o_auth_provider_exception.rb +48 -0
  13. data/lib/swagger_petstore/http/http_call_back.rb +10 -0
  14. data/lib/swagger_petstore/http/http_method_enum.rb +10 -0
  15. data/lib/swagger_petstore/http/http_request.rb +10 -0
  16. data/lib/swagger_petstore/http/http_response.rb +10 -0
  17. data/lib/swagger_petstore/models/add_pet_request.rb +102 -0
  18. data/lib/swagger_petstore/models/base_model.rb +58 -0
  19. data/lib/swagger_petstore/models/category.rb +57 -0
  20. data/lib/swagger_petstore/models/create_user_request.rb +111 -0
  21. data/lib/swagger_petstore/models/create_users_with_array_input_request.rb +111 -0
  22. data/lib/swagger_petstore/models/create_users_with_list_input_request.rb +111 -0
  23. data/lib/swagger_petstore/models/o_auth_provider_error_enum.rb +39 -0
  24. data/lib/swagger_petstore/models/o_auth_scope_enum.rb +17 -0
  25. data/lib/swagger_petstore/models/o_auth_token.rb +100 -0
  26. data/lib/swagger_petstore/models/place_order_request.rb +93 -0
  27. data/lib/swagger_petstore/models/response200.rb +66 -0
  28. data/lib/swagger_petstore/models/response2001.rb +102 -0
  29. data/lib/swagger_petstore/models/response20011.rb +48 -0
  30. data/lib/swagger_petstore/models/response20012.rb +111 -0
  31. data/lib/swagger_petstore/models/response2007.rb +93 -0
  32. data/lib/swagger_petstore/models/tag.rb +66 -0
  33. data/lib/swagger_petstore/models/update_pet_request.rb +102 -0
  34. data/lib/swagger_petstore/models/update_user_request.rb +111 -0
  35. data/lib/swagger_petstore/utilities/date_time_helper.rb +11 -0
  36. data/lib/swagger_petstore/utilities/file_wrapper.rb +16 -0
  37. data/lib/swagger_petstore.rb +59 -0
  38. data/test/controllers/controller_test_base.rb +33 -0
  39. data/test/controllers/test_pet_controller.rb +194 -0
  40. data/test/controllers/test_store_controller.rb +158 -0
  41. data/test/controllers/test_user_controller.rb +184 -0
  42. data/test/http_response_catcher.rb +19 -0
  43. metadata +161 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1dd7db51473ed28c14f69f9024318943facf6123a6f3a411a1412fb00e43e3de
4
+ data.tar.gz: fb3d1deca75e97d7d674fe09860f3e6f1c8c01514bf91aa0660772a069e8a6a0
5
+ SHA512:
6
+ metadata.gz: 4a06384c1efa4835923c2f9a1b360655e5d0be1118e9bdcc11bc07f289ebf40742a2e2dc834278f8bde9f4ac6d9915967ae1e52f5b631980b225491a223ef237
7
+ data.tar.gz: 3302f2e241792519f29e524848752eb06364d95d8545dd009256c1885c57bd7973f47094fd41415549b0db302d2b8eade345680e9f88fd54b5c89a313ac21acd
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 - 2023 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,119 @@
1
+
2
+ # Getting Started with Swagger Petstore
3
+
4
+ ## Introduction
5
+
6
+ This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
7
+
8
+ ## Install the Package
9
+
10
+ Install the gem from the command line:
11
+
12
+ ```ruby
13
+ gem install apimaticPetstore -v 1.0.1
14
+ ```
15
+
16
+ Or add the gem to your Gemfile and run `bundle`:
17
+
18
+ ```ruby
19
+ gem 'apimaticPetstore', '1.0.1'
20
+ ```
21
+
22
+ For additional gem details, see the [RubyGems page for the apimaticPetstore gem](https://rubygems.org/gems/apimaticPetstore/versions/1.0.1).
23
+
24
+ ## Test the SDK
25
+
26
+ To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
27
+
28
+ ```
29
+ rake
30
+ ```
31
+
32
+ ## Initialize the API Client
33
+
34
+ **_Note:_** Documentation for the client can be found [here.](doc/client.md)
35
+
36
+ The following parameters are configurable for the API Client:
37
+
38
+ | Parameter | Type | Description |
39
+ | --- | --- | --- |
40
+ | `environment` | Environment | The API environment. <br> **Default: `Environment.PRODUCTION`** |
41
+ | `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
42
+ | `adapter` | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
43
+ | `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
44
+ | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
45
+ | `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
46
+ | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
47
+ | `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
48
+ | `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
49
+ | `http_callback` | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
50
+ | `o_auth_client_id` | `String` | OAuth 2 Client ID |
51
+ | `o_auth_redirect_uri` | `String` | OAuth 2 Redirection endpoint or Callback Uri |
52
+ | `o_auth_token` | `OAuthToken` | Object for storing information about the OAuth token |
53
+ | `o_auth_scopes` | `OAuthScopeEnum` | |
54
+
55
+ The API client can be initialized as follows:
56
+
57
+ ```ruby
58
+ client = SwaggerPetstore::Client.new(
59
+ o_auth_client_id: 'OAuthClientId',
60
+ o_auth_redirect_uri: 'OAuthRedirectUri',
61
+ o_auth_scopes: [
62
+ OAuthScopeEnum::READPETS,
63
+ OAuthScopeEnum::WRITEPETS
64
+ ],
65
+ environment: Environment::PRODUCTION
66
+ )
67
+ ```
68
+
69
+ ## Authorization
70
+
71
+ This API uses `OAuth 2 Implicit Grant`.
72
+
73
+ ## Implicit Grant
74
+
75
+ Your application must obtain user authorization before it can execute an endpoint call incase this SDK chooses to use *OAuth 2.0 Implicit Grant* to obtain a user's consent to perform an API request on user's behalf. This authorization includes the following steps
76
+
77
+ This process requires the presence of a client-side JavaScript code on the redirect URI page to receive the *access token* after the consent step is completed.
78
+
79
+ ### 1\. Obtain user consent
80
+
81
+ To obtain user's consent, you must redirect the user to the authorization page. The `get_authorization_url()` method creates the URL to the authorization page. You must have initialized the client with scopes for which you need permission to access.
82
+
83
+ ```ruby
84
+ auth_url = client.auth.get_authorization_url
85
+ ```
86
+
87
+ ### 2\. Handle the OAuth server response
88
+
89
+ Once the user responds to the consent request, the OAuth 2.0 server responds to your application's access request by redirecting the user to the redirect URI specified set in `Configuration`.
90
+
91
+ The redirect URI will receive the *access token* as the `token` argument in the URL fragment.
92
+
93
+ ```
94
+ https://example.com/oauth/callback#token=XXXXXXXXXXXXXXXXXXXXXXXXX
95
+ ```
96
+
97
+ The access token must be extracted by the client-side JavaScript code. The access token can be used to authorize any further endpoint calls by the JavaScript code.
98
+
99
+ ### Scopes
100
+
101
+ Scopes enable your application to only request access to the resources it needs while enabling users to control the amount of access they grant to your application. Available scopes are defined in the `OAuthScopeEnum` enumeration.
102
+
103
+ | Scope Name |
104
+ | --- |
105
+ | `READPETS` |
106
+ | `WRITEPETS` |
107
+
108
+ ## List of APIs
109
+
110
+ * [Pet](doc/controllers/pet.md)
111
+ * [Store](doc/controllers/store.md)
112
+ * [User](doc/controllers/user.md)
113
+
114
+ ## Classes Documentation
115
+
116
+ * [Utility Classes](doc/utility-classes.md)
117
+ * [HttpResponse](doc/http-response.md)
118
+ * [HttpRequest](doc/http-request.md)
119
+
@@ -0,0 +1,10 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,76 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
7
+ # swagger_petstore client class.
8
+ class Client
9
+ attr_reader :config, :auth_managers
10
+
11
+ # Access to pet controller.
12
+ # @return [PetController] Returns the controller instance.
13
+ def pet
14
+ @pet ||= PetController.new @global_configuration
15
+ end
16
+
17
+ # Access to store controller.
18
+ # @return [StoreController] Returns the controller instance.
19
+ def store
20
+ @store ||= StoreController.new @global_configuration
21
+ end
22
+
23
+ # Access to user controller.
24
+ # @return [UserController] Returns the controller instance.
25
+ def user
26
+ @user ||= UserController.new @global_configuration
27
+ end
28
+
29
+ def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
30
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
31
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
32
+ retry_methods: %i[get put], http_callback: nil,
33
+ environment: Environment::PRODUCTION,
34
+ o_auth_client_id: 'TODO: Replace',
35
+ o_auth_redirect_uri: 'TODO: Replace', o_auth_token: nil,
36
+ o_auth_scopes: nil, config: nil)
37
+ @config = if config.nil?
38
+ Configuration.new(connection: connection, adapter: adapter,
39
+ timeout: timeout, max_retries: max_retries,
40
+ retry_interval: retry_interval,
41
+ backoff_factor: backoff_factor,
42
+ retry_statuses: retry_statuses,
43
+ retry_methods: retry_methods,
44
+ http_callback: http_callback,
45
+ environment: environment,
46
+ o_auth_client_id: o_auth_client_id,
47
+ o_auth_redirect_uri: o_auth_redirect_uri,
48
+ o_auth_token: o_auth_token,
49
+ o_auth_scopes: o_auth_scopes)
50
+ else
51
+ config
52
+ end
53
+
54
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
55
+ .base_uri_executor(@config.method(:get_base_uri))
56
+ .global_errors(BaseController::GLOBAL_ERRORS)
57
+ .user_agent(BaseController.user_agent)
58
+ .sdk_module(SwaggerPetstore)
59
+
60
+ initialize_auth_managers(@global_configuration)
61
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
62
+ end
63
+
64
+ # Initializes the auth managers hash used for authenticating API calls.
65
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
66
+ def initialize_auth_managers(global_config)
67
+ @auth_managers = {}
68
+ http_client_config = global_config.client_configuration
69
+ ['global'].each { |auth| @auth_managers[auth] = nil }
70
+ @auth_managers['global'] = OAuth2.new(http_client_config.o_auth_client_id,
71
+ http_client_config.o_auth_redirect_uri,
72
+ http_client_config.o_auth_token, global_config,
73
+ http_client_config.o_auth_scopes)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,125 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
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
+ SERVER_1 = 'Server 1'.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
+ # The attribute readers for properties.
25
+ attr_reader :environment, :o_auth_client_id, :o_auth_redirect_uri, :o_auth_scopes
26
+
27
+ def o_auth_token
28
+ if @o_auth_token.is_a? OAuthToken
29
+ OAuthToken.from_hash @o_auth_token.to_hash
30
+ else
31
+ @o_auth_token
32
+ end
33
+ end
34
+
35
+ class << self
36
+ attr_reader :environments
37
+ end
38
+
39
+ def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
40
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
41
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
42
+ retry_methods: %i[get put], http_callback: nil,
43
+ environment: Environment::PRODUCTION,
44
+ o_auth_client_id: 'TODO: Replace',
45
+ o_auth_redirect_uri: 'TODO: Replace', o_auth_token: nil,
46
+ o_auth_scopes: nil)
47
+
48
+ super connection: connection, adapter: adapter, timeout: timeout,
49
+ max_retries: max_retries, retry_interval: retry_interval,
50
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
51
+ retry_methods: retry_methods, http_callback: http_callback
52
+
53
+ # Current API environment
54
+ @environment = String(environment)
55
+
56
+ # OAuth 2 Client ID
57
+ @o_auth_client_id = o_auth_client_id
58
+
59
+ # OAuth 2 Redirection endpoint or Callback Uri
60
+ @o_auth_redirect_uri = o_auth_redirect_uri
61
+
62
+ # Object for storing information about the OAuth token
63
+ @o_auth_token = if o_auth_token.is_a? OAuthToken
64
+ OAuthToken.from_hash o_auth_token.to_hash
65
+ else
66
+ o_auth_token
67
+ end
68
+
69
+ # TODO: Replace
70
+ @o_auth_scopes = o_auth_scopes
71
+
72
+ # The Http Client to use for making requests.
73
+ set_http_client CoreLibrary::FaradayClient.new(self)
74
+ end
75
+
76
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
77
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
78
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
79
+ environment: nil, o_auth_client_id: nil,
80
+ o_auth_redirect_uri: nil, o_auth_token: nil,
81
+ o_auth_scopes: nil)
82
+ connection ||= self.connection
83
+ adapter ||= self.adapter
84
+ timeout ||= self.timeout
85
+ max_retries ||= self.max_retries
86
+ retry_interval ||= self.retry_interval
87
+ backoff_factor ||= self.backoff_factor
88
+ retry_statuses ||= self.retry_statuses
89
+ retry_methods ||= self.retry_methods
90
+ http_callback ||= self.http_callback
91
+ environment ||= self.environment
92
+ o_auth_client_id ||= self.o_auth_client_id
93
+ o_auth_redirect_uri ||= self.o_auth_redirect_uri
94
+ o_auth_token ||= self.o_auth_token
95
+ o_auth_scopes ||= self.o_auth_scopes
96
+
97
+ Configuration.new(connection: connection, adapter: adapter,
98
+ timeout: timeout, max_retries: max_retries,
99
+ retry_interval: retry_interval,
100
+ backoff_factor: backoff_factor,
101
+ retry_statuses: retry_statuses,
102
+ retry_methods: retry_methods,
103
+ http_callback: http_callback, environment: environment,
104
+ o_auth_client_id: o_auth_client_id,
105
+ o_auth_redirect_uri: o_auth_redirect_uri,
106
+ o_auth_token: o_auth_token,
107
+ o_auth_scopes: o_auth_scopes)
108
+ end
109
+
110
+ # All the environments the SDK can run in.
111
+ ENVIRONMENTS = {
112
+ Environment::PRODUCTION => {
113
+ Server::SERVER_1 => 'https://petstore.swagger.io/v2'
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::SERVER_1)
122
+ ENVIRONMENTS[environment][server].clone
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,65 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
7
+ # BaseController.
8
+ class BaseController
9
+ attr_accessor :config, :http_call_back
10
+
11
+ def self.user_agent
12
+ 'APIMATIC 3.0'
13
+ end
14
+
15
+
16
+ GLOBAL_ERRORS = {
17
+ 'default' => ErrorCase.new
18
+ .error_message('HTTP response not OK.')
19
+ .exception_type(APIException)
20
+ }.freeze
21
+
22
+ # Initialization constructor.
23
+ # @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
24
+ def initialize(global_configuration)
25
+ @global_configuration = global_configuration
26
+ @config = @global_configuration.client_configuration
27
+ @http_call_back = @config.http_callback
28
+ @api_call = ApiCall.new(@global_configuration)
29
+ end
30
+
31
+ # Creates a new builder for the Api Call instance.
32
+ # @return [ApiCall] The instance of ApiCall.
33
+ def new_api_call_builder
34
+ @api_call.new_builder
35
+ end
36
+
37
+ # Creates a new instance of the request builder.
38
+ # @param [HttpMethodEnum] http_method The HTTP method to use in the request.
39
+ # @param [String] path The endpoint path to use in the request.
40
+ # @param [String] server The server to extract the base uri for the request.
41
+ # @return [RequestBuilder] The instance of RequestBuilder.
42
+ def new_request_builder(http_method, path, server)
43
+ RequestBuilder.new
44
+ .http_method(http_method)
45
+ .path(path)
46
+ .server(server)
47
+ end
48
+
49
+ # Creates a new instance of the response handler.
50
+ # @return [ResponseHandler] The instance of ResponseHandler.
51
+ def new_response_handler
52
+ ResponseHandler.new
53
+ end
54
+
55
+ # Creates a new instance of the parameter.
56
+ # @param [String|optional] key The key of the parameter.
57
+ # @param [Object] value The value of the parameter.
58
+ # @return [Parameter] The instance of Parameter.
59
+ def new_parameter(value, key: nil)
60
+ Parameter.new
61
+ .key(key)
62
+ .value(value)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,221 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
7
+ # PetController
8
+ class PetController < BaseController
9
+ # uploads an image
10
+ # @param [Integer] pet_id Required parameter: ID of pet to update
11
+ # @param [String] accept Required parameter: Example:
12
+ # @param [String] additional_metadata Required parameter: Additional data to
13
+ # pass to server
14
+ # @param [File | UploadIO] file Required parameter: file to upload
15
+ # @return [Response200] response from the API call
16
+ def upload_file(pet_id,
17
+ accept,
18
+ additional_metadata,
19
+ file)
20
+ new_api_call_builder
21
+ .request(new_request_builder(HttpMethodEnum::POST,
22
+ '/pet/{petId}/uploadImage',
23
+ Server::SERVER_1)
24
+ .template_param(new_parameter(pet_id, key: 'petId')
25
+ .should_encode(true))
26
+ .header_param(new_parameter(accept, key: 'Accept'))
27
+ .form_param(new_parameter(additional_metadata, key: 'additionalMetadata'))
28
+ .multipart_param(new_parameter(file, key: 'file')
29
+ .default_content_type('application/octet-stream'))
30
+ .auth(Single.new('global')))
31
+ .response(new_response_handler
32
+ .deserializer(APIHelper.method(:custom_type_deserializer))
33
+ .deserialize_into(Response200.method(:from_hash)))
34
+ .execute
35
+ end
36
+
37
+ # Add a new pet to the store
38
+ # @param [String] accept Required parameter: Example:
39
+ # @param [AddPetRequest] body Required parameter: Example:
40
+ # @return [void] response from the API call
41
+ def add_pet(accept,
42
+ body)
43
+ new_api_call_builder
44
+ .request(new_request_builder(HttpMethodEnum::POST,
45
+ '/pet',
46
+ Server::SERVER_1)
47
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
48
+ .header_param(new_parameter(accept, key: 'Accept'))
49
+ .body_param(new_parameter(body))
50
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
51
+ .auth(Single.new('global')))
52
+ .response(new_response_handler
53
+ .is_response_void(true)
54
+ .local_error('405',
55
+ 'Invalid input',
56
+ APIException))
57
+ .execute
58
+ end
59
+
60
+ # Update an existing pet
61
+ # @param [String] accept Required parameter: Example:
62
+ # @param [UpdatePetRequest] body Required parameter: Example:
63
+ # @return [void] response from the API call
64
+ def update_pet(accept,
65
+ body)
66
+ new_api_call_builder
67
+ .request(new_request_builder(HttpMethodEnum::PUT,
68
+ '/pet',
69
+ Server::SERVER_1)
70
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
71
+ .header_param(new_parameter(accept, key: 'Accept'))
72
+ .body_param(new_parameter(body))
73
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
74
+ .auth(Single.new('global')))
75
+ .response(new_response_handler
76
+ .is_response_void(true)
77
+ .local_error('400',
78
+ 'Invalid ID supplied',
79
+ APIException)
80
+ .local_error('404',
81
+ 'Pet not found',
82
+ APIException)
83
+ .local_error('405',
84
+ 'Validation exception',
85
+ APIException))
86
+ .execute
87
+ end
88
+
89
+ # Multiple status values can be provided with comma separated strings
90
+ # @param [List of String] status Required parameter: Status values that need
91
+ # to be considered for filter
92
+ # @param [String] accept Required parameter: Example:
93
+ # @return [List of Response2001] response from the API call
94
+ def find_pets_by_status(status,
95
+ accept)
96
+ new_api_call_builder
97
+ .request(new_request_builder(HttpMethodEnum::GET,
98
+ '/pet/findByStatus',
99
+ Server::SERVER_1)
100
+ .query_param(new_parameter(status, key: 'status'))
101
+ .header_param(new_parameter(accept, key: 'Accept'))
102
+ .auth(Single.new('global')))
103
+ .response(new_response_handler
104
+ .deserializer(APIHelper.method(:custom_type_deserializer))
105
+ .deserialize_into(Response2001.method(:from_hash))
106
+ .is_response_array(true)
107
+ .local_error('400',
108
+ 'Invalid status value',
109
+ APIException))
110
+ .execute
111
+ end
112
+
113
+ # Multiple tags can be provided with comma separated strings. Use tag1,
114
+ # tag2, tag3 for testing.
115
+ # @param [List of String] tags Required parameter: Tags to filter by
116
+ # @param [String] accept Required parameter: Example:
117
+ # @return [List of Response2001] response from the API call
118
+ def find_pets_by_tags(tags,
119
+ accept)
120
+ new_api_call_builder
121
+ .request(new_request_builder(HttpMethodEnum::GET,
122
+ '/pet/findByTags',
123
+ Server::SERVER_1)
124
+ .query_param(new_parameter(tags, key: 'tags'))
125
+ .header_param(new_parameter(accept, key: 'Accept'))
126
+ .auth(Single.new('global')))
127
+ .response(new_response_handler
128
+ .deserializer(APIHelper.method(:custom_type_deserializer))
129
+ .deserialize_into(Response2001.method(:from_hash))
130
+ .is_response_array(true)
131
+ .local_error('400',
132
+ 'Invalid tag value',
133
+ APIException))
134
+ .execute
135
+ end
136
+
137
+ # Returns a single pet
138
+ # @param [Integer] pet_id Required parameter: ID of pet to return
139
+ # @param [String] accept Required parameter: Example:
140
+ # @return [Response2001] response from the API call
141
+ def get_pet_by_id(pet_id,
142
+ accept)
143
+ new_api_call_builder
144
+ .request(new_request_builder(HttpMethodEnum::GET,
145
+ '/pet/{petId}',
146
+ Server::SERVER_1)
147
+ .template_param(new_parameter(pet_id, key: 'petId')
148
+ .should_encode(true))
149
+ .header_param(new_parameter(accept, key: 'Accept'))
150
+ .auth(Single.new('global')))
151
+ .response(new_response_handler
152
+ .deserializer(APIHelper.method(:custom_type_deserializer))
153
+ .deserialize_into(Response2001.method(:from_hash))
154
+ .local_error('400',
155
+ 'Invalid ID supplied',
156
+ APIException)
157
+ .local_error('404',
158
+ 'Pet not found',
159
+ APIException))
160
+ .execute
161
+ end
162
+
163
+ # Updates a pet in the store with form data
164
+ # @param [Integer] pet_id Required parameter: ID of pet that needs to be
165
+ # updated
166
+ # @param [String] accept Required parameter: Example:
167
+ # @param [String] name Required parameter: Updated name of the pet
168
+ # @param [String] status Required parameter: Updated status of the pet
169
+ # @return [void] response from the API call
170
+ def update_pet_with_form(pet_id,
171
+ accept,
172
+ name,
173
+ status)
174
+ new_api_call_builder
175
+ .request(new_request_builder(HttpMethodEnum::POST,
176
+ '/pet/{petId}',
177
+ Server::SERVER_1)
178
+ .template_param(new_parameter(pet_id, key: 'petId')
179
+ .should_encode(true))
180
+ .header_param(new_parameter(accept, key: 'Accept'))
181
+ .form_param(new_parameter(name, key: 'name'))
182
+ .form_param(new_parameter(status, key: 'status'))
183
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
184
+ .auth(Single.new('global')))
185
+ .response(new_response_handler
186
+ .is_response_void(true)
187
+ .local_error('405',
188
+ 'Invalid input',
189
+ APIException))
190
+ .execute
191
+ end
192
+
193
+ # Deletes a pet
194
+ # @param [Integer] pet_id Required parameter: Pet id to delete
195
+ # @param [String] api_key Required parameter: Example:
196
+ # @param [String] accept Required parameter: Example:
197
+ # @return [void] response from the API call
198
+ def delete_pet(pet_id,
199
+ api_key,
200
+ accept)
201
+ new_api_call_builder
202
+ .request(new_request_builder(HttpMethodEnum::DELETE,
203
+ '/pet/{petId}',
204
+ Server::SERVER_1)
205
+ .template_param(new_parameter(pet_id, key: 'petId')
206
+ .should_encode(true))
207
+ .header_param(new_parameter(api_key, key: 'api_key'))
208
+ .header_param(new_parameter(accept, key: 'Accept'))
209
+ .auth(Single.new('global')))
210
+ .response(new_response_handler
211
+ .is_response_void(true)
212
+ .local_error('400',
213
+ 'Invalid ID supplied',
214
+ APIException)
215
+ .local_error('404',
216
+ 'Pet not found',
217
+ APIException))
218
+ .execute
219
+ end
220
+ end
221
+ end