CalculatorApimatic 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +113 -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 +129 -0
  7. data/lib/swagger_petstore/controllers/base_controller.rb +65 -0
  8. data/lib/swagger_petstore/controllers/pet_controller.rb +204 -0
  9. data/lib/swagger_petstore/controllers/store_controller.rb +97 -0
  10. data/lib/swagger_petstore/controllers/user_controller.rb +185 -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/api_response.rb +70 -0
  18. data/lib/swagger_petstore/models/base_model.rb +58 -0
  19. data/lib/swagger_petstore/models/category.rb +60 -0
  20. data/lib/swagger_petstore/models/o_auth_provider_error_enum.rb +39 -0
  21. data/lib/swagger_petstore/models/o_auth_scope_enum.rb +17 -0
  22. data/lib/swagger_petstore/models/o_auth_token.rb +100 -0
  23. data/lib/swagger_petstore/models/order.rb +109 -0
  24. data/lib/swagger_petstore/models/pet.rb +107 -0
  25. data/lib/swagger_petstore/models/status1_enum.rb +20 -0
  26. data/lib/swagger_petstore/models/status2_enum.rb +20 -0
  27. data/lib/swagger_petstore/models/status_enum.rb +20 -0
  28. data/lib/swagger_petstore/models/tag.rb +60 -0
  29. data/lib/swagger_petstore/models/user.rb +120 -0
  30. data/lib/swagger_petstore/utilities/date_time_helper.rb +11 -0
  31. data/lib/swagger_petstore/utilities/file_wrapper.rb +16 -0
  32. data/lib/swagger_petstore.rb +54 -0
  33. metadata +117 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 03c6179d58bfa517055e7665d88466afa660afc157377186ede2cbac6ec7e6d5
4
+ data.tar.gz: 8ea422481dc324f8d6f45bc26b7f03753f723885d5f488373a12c558d504baa3
5
+ SHA512:
6
+ metadata.gz: 8a3d1f019bd9b5430f875b6adb598ef6c5524157ff99c923c6288d5c57d01ac35f9f5a977ab5bdc3ef189bcddd0c99f349b5b423e63bf9af36021dc5fc86cff9
7
+ data.tar.gz: 1fccaa88c50abe1982d2335b8971fc4f12b2713f8b159643cace0cf661f3946839b7d24e8a843b341895ad76dd34c8232fe16031ffe54eaeba83a45842022a12
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,113 @@
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
+ Find out more about Swagger: [http://swagger.io](http://swagger.io)
9
+
10
+ ## Install the Package
11
+
12
+ Install the gem from the command line:
13
+
14
+ ```ruby
15
+ gem install CalculatorApimatic -v 1.0.1
16
+ ```
17
+
18
+ Or add the gem to your Gemfile and run `bundle`:
19
+
20
+ ```ruby
21
+ gem 'CalculatorApimatic', '1.0.1'
22
+ ```
23
+
24
+ For additional gem details, see the [RubyGems page for the CalculatorApimatic gem](https://rubygems.org/gems/CalculatorApimatic/versions/1.0.1).
25
+
26
+ ## Initialize the API Client
27
+
28
+ **_Note:_** Documentation for the client can be found [here.](doc/client.md)
29
+
30
+ The following parameters are configurable for the API Client:
31
+
32
+ | Parameter | Type | Description |
33
+ | --- | --- | --- |
34
+ | `environment` | Environment | The API environment. <br> **Default: `Environment.PRODUCTION`** |
35
+ | `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
36
+ | `adapter` | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
37
+ | `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
38
+ | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
39
+ | `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
40
+ | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
41
+ | `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
42
+ | `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
43
+ | `http_callback` | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
44
+ | `o_auth_client_id` | `String` | OAuth 2 Client ID |
45
+ | `o_auth_redirect_uri` | `String` | OAuth 2 Redirection endpoint or Callback Uri |
46
+ | `o_auth_token` | `OAuthToken` | Object for storing information about the OAuth token |
47
+ | `o_auth_scopes` | `OAuthScopeEnum` | |
48
+
49
+ The API client can be initialized as follows:
50
+
51
+ ```ruby
52
+ client = SwaggerPetstore::Client.new(
53
+ o_auth_client_id: 'OAuthClientId',
54
+ o_auth_redirect_uri: 'OAuthRedirectUri',
55
+ o_auth_scopes: [
56
+ OAuthScopeEnum::READPETS,
57
+ OAuthScopeEnum::WRITEPETS
58
+ ],
59
+ environment: Environment::PRODUCTION
60
+ )
61
+ ```
62
+
63
+ ## Authorization
64
+
65
+ This API uses `OAuth 2 Implicit Grant`.
66
+
67
+ ## Implicit Grant
68
+
69
+ 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
70
+
71
+ 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.
72
+
73
+ ### 1\. Obtain user consent
74
+
75
+ 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.
76
+
77
+ ```ruby
78
+ auth_url = client.auth.get_authorization_url
79
+ ```
80
+
81
+ ### 2\. Handle the OAuth server response
82
+
83
+ 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`.
84
+
85
+ The redirect URI will receive the *access token* as the `token` argument in the URL fragment.
86
+
87
+ ```
88
+ https://example.com/oauth/callback#token=XXXXXXXXXXXXXXXXXXXXXXXXX
89
+ ```
90
+
91
+ 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.
92
+
93
+ ### Scopes
94
+
95
+ 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.
96
+
97
+ | Scope Name | Description |
98
+ | --- | --- |
99
+ | `READPETS` | read your pets |
100
+ | `WRITEPETS` | modify pets in your account |
101
+
102
+ ## List of APIs
103
+
104
+ * [Pet](doc/controllers/pet.md)
105
+ * [Store](doc/controllers/store.md)
106
+ * [User](doc/controllers/user.md)
107
+
108
+ ## Classes Documentation
109
+
110
+ * [Utility Classes](doc/utility-classes.md)
111
+ * [HttpResponse](doc/http-response.md)
112
+ * [HttpRequest](doc/http-request.md)
113
+
@@ -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,129 @@
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
+ SERVER1 = 'server1'.freeze,
18
+ SERVER2 = 'server2'.freeze,
19
+ AUTH_SERVER = 'auth server'.freeze
20
+ ].freeze
21
+ end
22
+
23
+ # All configuration including auth info and base URI for the API access
24
+ # are configured in this class.
25
+ class Configuration < CoreLibrary::HttpClientConfiguration
26
+ # The attribute readers for properties.
27
+ attr_reader :environment, :o_auth_client_id, :o_auth_redirect_uri, :o_auth_scopes
28
+
29
+ def o_auth_token
30
+ if @o_auth_token.is_a? OAuthToken
31
+ OAuthToken.from_hash @o_auth_token.to_hash
32
+ else
33
+ @o_auth_token
34
+ end
35
+ end
36
+
37
+ class << self
38
+ attr_reader :environments
39
+ end
40
+
41
+ def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
42
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
43
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
44
+ retry_methods: %i[get put], http_callback: nil,
45
+ environment: Environment::PRODUCTION,
46
+ o_auth_client_id: 'TODO: Replace',
47
+ o_auth_redirect_uri: 'TODO: Replace', o_auth_token: nil,
48
+ o_auth_scopes: nil)
49
+
50
+ super connection: connection, adapter: adapter, timeout: timeout,
51
+ max_retries: max_retries, retry_interval: retry_interval,
52
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
53
+ retry_methods: retry_methods, http_callback: http_callback
54
+
55
+ # Current API environment
56
+ @environment = String(environment)
57
+
58
+ # OAuth 2 Client ID
59
+ @o_auth_client_id = o_auth_client_id
60
+
61
+ # OAuth 2 Redirection endpoint or Callback Uri
62
+ @o_auth_redirect_uri = o_auth_redirect_uri
63
+
64
+ # Object for storing information about the OAuth token
65
+ @o_auth_token = if o_auth_token.is_a? OAuthToken
66
+ OAuthToken.from_hash o_auth_token.to_hash
67
+ else
68
+ o_auth_token
69
+ end
70
+
71
+ # TODO: Replace
72
+ @o_auth_scopes = o_auth_scopes
73
+
74
+ # The Http Client to use for making requests.
75
+ set_http_client CoreLibrary::FaradayClient.new(self)
76
+ end
77
+
78
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
79
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
80
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
81
+ environment: nil, o_auth_client_id: nil,
82
+ o_auth_redirect_uri: nil, o_auth_token: nil,
83
+ o_auth_scopes: nil)
84
+ connection ||= self.connection
85
+ adapter ||= self.adapter
86
+ timeout ||= self.timeout
87
+ max_retries ||= self.max_retries
88
+ retry_interval ||= self.retry_interval
89
+ backoff_factor ||= self.backoff_factor
90
+ retry_statuses ||= self.retry_statuses
91
+ retry_methods ||= self.retry_methods
92
+ http_callback ||= self.http_callback
93
+ environment ||= self.environment
94
+ o_auth_client_id ||= self.o_auth_client_id
95
+ o_auth_redirect_uri ||= self.o_auth_redirect_uri
96
+ o_auth_token ||= self.o_auth_token
97
+ o_auth_scopes ||= self.o_auth_scopes
98
+
99
+ Configuration.new(connection: connection, adapter: adapter,
100
+ timeout: timeout, max_retries: max_retries,
101
+ retry_interval: retry_interval,
102
+ backoff_factor: backoff_factor,
103
+ retry_statuses: retry_statuses,
104
+ retry_methods: retry_methods,
105
+ http_callback: http_callback, environment: environment,
106
+ o_auth_client_id: o_auth_client_id,
107
+ o_auth_redirect_uri: o_auth_redirect_uri,
108
+ o_auth_token: o_auth_token,
109
+ o_auth_scopes: o_auth_scopes)
110
+ end
111
+
112
+ # All the environments the SDK can run in.
113
+ ENVIRONMENTS = {
114
+ Environment::PRODUCTION => {
115
+ Server::SERVER1 => 'https://petstore.swagger.io/v2',
116
+ Server::SERVER2 => 'http://petstore.swagger.io/v2',
117
+ Server::AUTH_SERVER => 'https://petstore.swagger.io/oauth'
118
+ }
119
+ }.freeze
120
+
121
+ # Generates the appropriate base URI for the environment and the server.
122
+ # @param [Configuration::Server] server The server enum for which the base URI is
123
+ # required.
124
+ # @return [String] The base URI.
125
+ def get_base_uri(server = Server::SERVER1)
126
+ ENVIRONMENTS[environment][server].clone
127
+ end
128
+ end
129
+ 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,204 @@
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] additional_metadata Optional parameter: Additional data to
12
+ # pass to server
13
+ # @param [File | UploadIO] file Optional parameter: file to upload
14
+ # @return [ApiResponse] response from the API call
15
+ def upload_file(pet_id,
16
+ additional_metadata: nil,
17
+ file: nil)
18
+ new_api_call_builder
19
+ .request(new_request_builder(HttpMethodEnum::POST,
20
+ '/pet/{petId}/uploadImage',
21
+ Server::SERVER1)
22
+ .template_param(new_parameter(pet_id, key: 'petId')
23
+ .should_encode(true))
24
+ .form_param(new_parameter(additional_metadata, key: 'additionalMetadata'))
25
+ .multipart_param(new_parameter(file, key: 'file')
26
+ .default_content_type('application/octet-stream'))
27
+ .header_param(new_parameter('application/json', key: 'accept'))
28
+ .auth(Single.new('global')))
29
+ .response(new_response_handler
30
+ .deserializer(APIHelper.method(:custom_type_deserializer))
31
+ .deserialize_into(ApiResponse.method(:from_hash)))
32
+ .execute
33
+ end
34
+
35
+ # Add a new pet to the store
36
+ # @param [Pet] body Required parameter: Pet object that needs to be added to
37
+ # the store
38
+ # @return [void] response from the API call
39
+ def add_pet(body)
40
+ new_api_call_builder
41
+ .request(new_request_builder(HttpMethodEnum::POST,
42
+ '/pet',
43
+ Server::SERVER1)
44
+ .body_param(new_parameter(body))
45
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
46
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
47
+ .auth(Single.new('global')))
48
+ .response(new_response_handler
49
+ .is_response_void(true)
50
+ .local_error('405',
51
+ 'Invalid input',
52
+ APIException))
53
+ .execute
54
+ end
55
+
56
+ # Update an existing pet
57
+ # @param [Pet] body Required parameter: Pet object that needs to be added to
58
+ # the store
59
+ # @return [void] response from the API call
60
+ def update_pet(body)
61
+ new_api_call_builder
62
+ .request(new_request_builder(HttpMethodEnum::PUT,
63
+ '/pet',
64
+ Server::SERVER1)
65
+ .body_param(new_parameter(body))
66
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
67
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
68
+ .auth(Single.new('global')))
69
+ .response(new_response_handler
70
+ .is_response_void(true)
71
+ .local_error('400',
72
+ 'Invalid ID supplied',
73
+ APIException)
74
+ .local_error('404',
75
+ 'Pet not found',
76
+ APIException)
77
+ .local_error('405',
78
+ 'Validation exception',
79
+ APIException))
80
+ .execute
81
+ end
82
+
83
+ # Multiple status values can be provided with comma separated strings
84
+ # @param [List of Status2Enum] status Required parameter: Status values that
85
+ # need to be considered for filter
86
+ # @return [List of Pet] response from the API call
87
+ def find_pets_by_status(status)
88
+ new_api_call_builder
89
+ .request(new_request_builder(HttpMethodEnum::GET,
90
+ '/pet/findByStatus',
91
+ Server::SERVER1)
92
+ .query_param(new_parameter(status, key: 'status'))
93
+ .header_param(new_parameter('application/json', key: 'accept'))
94
+ .auth(Single.new('global')))
95
+ .response(new_response_handler
96
+ .deserializer(APIHelper.method(:custom_type_deserializer))
97
+ .deserialize_into(Pet.method(:from_hash))
98
+ .is_response_array(true)
99
+ .local_error('400',
100
+ 'Invalid status value',
101
+ APIException))
102
+ .execute
103
+ end
104
+
105
+ # Multiple tags can be provided with comma separated strings. Use tag1,
106
+ # tag2, tag3 for testing.
107
+ # @param [List of String] tags Required parameter: Tags to filter by
108
+ # @return [List of Pet] response from the API call
109
+ def find_pets_by_tags(tags)
110
+ warn 'Endpoint find_pets_by_tags in PetController is deprecated'
111
+ new_api_call_builder
112
+ .request(new_request_builder(HttpMethodEnum::GET,
113
+ '/pet/findByTags',
114
+ Server::SERVER1)
115
+ .query_param(new_parameter(tags, key: 'tags'))
116
+ .header_param(new_parameter('application/json', key: 'accept'))
117
+ .auth(Single.new('global')))
118
+ .response(new_response_handler
119
+ .deserializer(APIHelper.method(:custom_type_deserializer))
120
+ .deserialize_into(Pet.method(:from_hash))
121
+ .is_response_array(true)
122
+ .local_error('400',
123
+ 'Invalid tag value',
124
+ APIException))
125
+ .execute
126
+ end
127
+
128
+ # Returns a single pet
129
+ # @param [Integer] pet_id Required parameter: ID of pet to return
130
+ # @return [Pet] response from the API call
131
+ def get_pet_by_id(pet_id)
132
+ new_api_call_builder
133
+ .request(new_request_builder(HttpMethodEnum::GET,
134
+ '/pet/{petId}',
135
+ Server::SERVER1)
136
+ .template_param(new_parameter(pet_id, key: 'petId')
137
+ .should_encode(true))
138
+ .header_param(new_parameter('application/json', key: 'accept'))
139
+ .auth(Single.new('global')))
140
+ .response(new_response_handler
141
+ .deserializer(APIHelper.method(:custom_type_deserializer))
142
+ .deserialize_into(Pet.method(:from_hash))
143
+ .local_error('400',
144
+ 'Invalid ID supplied',
145
+ APIException)
146
+ .local_error('404',
147
+ 'Pet not found',
148
+ APIException))
149
+ .execute
150
+ end
151
+
152
+ # Updates a pet in the store with form data
153
+ # @param [Integer] pet_id Required parameter: ID of pet that needs to be
154
+ # updated
155
+ # @param [String] name Optional parameter: Updated name of the pet
156
+ # @param [String] status Optional parameter: Updated status of the pet
157
+ # @return [void] response from the API call
158
+ def update_pet_with_form(pet_id,
159
+ name: nil,
160
+ status: nil)
161
+ new_api_call_builder
162
+ .request(new_request_builder(HttpMethodEnum::POST,
163
+ '/pet/{petId}',
164
+ Server::SERVER1)
165
+ .template_param(new_parameter(pet_id, key: 'petId')
166
+ .should_encode(true))
167
+ .form_param(new_parameter(name, key: 'name'))
168
+ .form_param(new_parameter(status, key: 'status'))
169
+ .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
170
+ .auth(Single.new('global')))
171
+ .response(new_response_handler
172
+ .is_response_void(true)
173
+ .local_error('405',
174
+ 'Invalid input',
175
+ APIException))
176
+ .execute
177
+ end
178
+
179
+ # Deletes a pet
180
+ # @param [Integer] pet_id Required parameter: Pet id to delete
181
+ # @param [String] api_key Optional parameter: Example:
182
+ # @return [void] response from the API call
183
+ def delete_pet(pet_id,
184
+ api_key: nil)
185
+ new_api_call_builder
186
+ .request(new_request_builder(HttpMethodEnum::DELETE,
187
+ '/pet/{petId}',
188
+ Server::SERVER1)
189
+ .template_param(new_parameter(pet_id, key: 'petId')
190
+ .should_encode(true))
191
+ .header_param(new_parameter(api_key, key: 'api_key'))
192
+ .auth(Single.new('global')))
193
+ .response(new_response_handler
194
+ .is_response_void(true)
195
+ .local_error('400',
196
+ 'Invalid ID supplied',
197
+ APIException)
198
+ .local_error('404',
199
+ 'Pet not found',
200
+ APIException))
201
+ .execute
202
+ end
203
+ end
204
+ end