zahra-package-test 1.1.2
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.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +112 -0
- data/lib/swagger_petstore/api_helper.rb +10 -0
- data/lib/swagger_petstore/client.rb +84 -0
- data/lib/swagger_petstore/configuration.rb +124 -0
- data/lib/swagger_petstore/controllers/base_controller.rb +66 -0
- data/lib/swagger_petstore/controllers/pet_controller.rb +206 -0
- data/lib/swagger_petstore/controllers/store_controller.rb +94 -0
- data/lib/swagger_petstore/controllers/user_controller.rb +165 -0
- data/lib/swagger_petstore/exceptions/api_exception.rb +10 -0
- data/lib/swagger_petstore/exceptions/o_auth_provider_exception.rb +48 -0
- data/lib/swagger_petstore/http/auth/api_key.rb +42 -0
- data/lib/swagger_petstore/http/auth/http_basic.rb +50 -0
- data/lib/swagger_petstore/http/auth/petstore_auth.rb +91 -0
- data/lib/swagger_petstore/http/http_call_back.rb +10 -0
- data/lib/swagger_petstore/http/http_method_enum.rb +10 -0
- data/lib/swagger_petstore/http/http_request.rb +10 -0
- data/lib/swagger_petstore/http/http_response.rb +10 -0
- data/lib/swagger_petstore/models/api_response.rb +70 -0
- data/lib/swagger_petstore/models/base_model.rb +62 -0
- data/lib/swagger_petstore/models/category.rb +60 -0
- data/lib/swagger_petstore/models/category2.rb +60 -0
- data/lib/swagger_petstore/models/content_type_enum.rb +20 -0
- data/lib/swagger_petstore/models/o_auth_provider_error_enum.rb +45 -0
- data/lib/swagger_petstore/models/o_auth_scope_petstore_auth_enum.rb +23 -0
- data/lib/swagger_petstore/models/o_auth_token.rb +100 -0
- data/lib/swagger_petstore/models/order.rb +109 -0
- data/lib/swagger_petstore/models/pet.rb +107 -0
- data/lib/swagger_petstore/models/pet_request.rb +107 -0
- data/lib/swagger_petstore/models/status1_enum.rb +26 -0
- data/lib/swagger_petstore/models/status2_enum.rb +26 -0
- data/lib/swagger_petstore/models/status_enum.rb +26 -0
- data/lib/swagger_petstore/models/store_order_request.rb +109 -0
- data/lib/swagger_petstore/models/tag.rb +60 -0
- data/lib/swagger_petstore/models/user.rb +120 -0
- data/lib/swagger_petstore/models/user_request.rb +120 -0
- data/lib/swagger_petstore/utilities/date_time_helper.rb +11 -0
- data/lib/swagger_petstore/utilities/file_wrapper.rb +16 -0
- data/lib/swagger_petstore.rb +61 -0
- data/test/controllers/controller_test_base.rb +38 -0
- data/test/controllers/test_store_controller.rb +32 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e924c5ec96c1398c5df6db08a7250b67eb4b2a3371cee000434f6fe21ab156d3
|
4
|
+
data.tar.gz: ef40dd5a2ea7d6db982f5e5b58caafe1007db3c1629024ab0fc313fc25f05f4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: afda0517a1f5895bbaa99fb082a6882a1946de06e535116236c9f39ea8fa1473619970b11cea36db31dded4ddf42188825791713e996d2e3565cc87555272d0c
|
7
|
+
data.tar.gz: ac2c8d54190f1e083966a9d74589fb2188c14daa612a6466418888a69a34c84b4b24de4eb461593b39664dd56efa80911251f9ffdab9bd1392b0040a6c78b830
|
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,112 @@
|
|
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 zahra-package-test -v 1.1.2
|
16
|
+
```
|
17
|
+
|
18
|
+
Or add the gem to your Gemfile and run `bundle`:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'zahra-package-test', '1.1.2'
|
22
|
+
```
|
23
|
+
|
24
|
+
For additional gem details, see the [RubyGems page for the zahra-package-test gem](https://rubygems.org/gems/zahra-package-test/versions/1.1.2).
|
25
|
+
|
26
|
+
## Test the SDK
|
27
|
+
|
28
|
+
To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
|
29
|
+
|
30
|
+
```
|
31
|
+
rake
|
32
|
+
```
|
33
|
+
|
34
|
+
## Initialize the API Client
|
35
|
+
|
36
|
+
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/client.md)
|
37
|
+
|
38
|
+
The following parameters are configurable for the API Client:
|
39
|
+
|
40
|
+
| Parameter | Type | Description |
|
41
|
+
| --- | --- | --- |
|
42
|
+
| `test_header` | `String` | This is a test header<br>*Default*: `'TestHeaderDefaultValue'` |
|
43
|
+
| `environment` | `Environment` | The API environment. <br> **Default: `Environment.PRODUCTION`** |
|
44
|
+
| `connection` | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
|
45
|
+
| `adapter` | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
|
46
|
+
| `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
|
47
|
+
| `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
|
48
|
+
| `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
|
49
|
+
| `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
|
50
|
+
| `retry_statuses` | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
|
51
|
+
| `retry_methods` | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
|
52
|
+
| `http_callback` | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
|
53
|
+
| `api_key_credentials` | [`ApiKeyCredentials`](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/$a/https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/custom-header-signature.md) | The credential object for Custom Header Signature |
|
54
|
+
| `http_basic_credentials` | [`HttpBasicCredentials`](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/$a/https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/basic-authentication.md) | The credential object for Basic Authentication |
|
55
|
+
| `petstore_auth_credentials` | [`PetstoreAuthCredentials`](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/$a/https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/oauth-2-implicit-grant.md) | The credential object for OAuth 2 Implicit Grant |
|
56
|
+
|
57
|
+
The API client can be initialized as follows:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
client = SwaggerPetstore::Client.new(
|
61
|
+
test_header: 'TestHeaderDefaultValue',
|
62
|
+
api_key_credentials: ApiKeyCredentials.new(
|
63
|
+
api_key: 'api_key'
|
64
|
+
),
|
65
|
+
http_basic_credentials: HttpBasicCredentials.new(
|
66
|
+
username: 'username',
|
67
|
+
passwprd: 'passwprd'
|
68
|
+
),
|
69
|
+
petstore_auth_credentials: PetstoreAuthCredentials.new(
|
70
|
+
o_auth_client_id: 'OAuthClientId',
|
71
|
+
o_auth_redirect_uri: 'OAuthRedirectUri',
|
72
|
+
o_auth_scopes: [
|
73
|
+
OAuthScopePetstoreAuthEnum::READPETS,
|
74
|
+
OAuthScopePetstoreAuthEnum::WRITEPETS
|
75
|
+
]
|
76
|
+
),
|
77
|
+
environment: Environment::PRODUCTION
|
78
|
+
)
|
79
|
+
```
|
80
|
+
|
81
|
+
## Environments
|
82
|
+
|
83
|
+
The SDK can be configured to use a different environment for making API calls. Available environments are:
|
84
|
+
|
85
|
+
### Fields
|
86
|
+
|
87
|
+
| Name | Description |
|
88
|
+
| --- | --- |
|
89
|
+
| production | **Default** |
|
90
|
+
| environment2 | - |
|
91
|
+
| environment3 | - |
|
92
|
+
|
93
|
+
## Authorization
|
94
|
+
|
95
|
+
This API uses the following authentication schemes.
|
96
|
+
|
97
|
+
* [`api_key (Custom Header Signature)`](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/$a/https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/custom-header-signature.md)
|
98
|
+
* [`httpBasic (Basic Authentication)`](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/$a/https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/basic-authentication.md)
|
99
|
+
* [`petstore_auth (OAuth 2 Implicit Grant)`](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/$a/https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/oauth-2-implicit-grant.md)
|
100
|
+
|
101
|
+
## List of APIs
|
102
|
+
|
103
|
+
* [Pet](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/controllers/pet.md)
|
104
|
+
* [Store](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/controllers/store.md)
|
105
|
+
* [User](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/controllers/user.md)
|
106
|
+
|
107
|
+
## Classes Documentation
|
108
|
+
|
109
|
+
* [Utility Classes](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/utility-classes.md)
|
110
|
+
* [HttpResponse](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/http-response.md)
|
111
|
+
* [HttpRequest](https://www.github.com/ZahraN444/zeepackage-1-ruby-sdk/tree/1.1.2/doc/http-request.md)
|
112
|
+
|
@@ -0,0 +1,84 @@
|
|
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
|
+
include CoreLibrary
|
10
|
+
attr_reader :config, :auth_managers
|
11
|
+
|
12
|
+
# Returns the configured authentication petstore_auth instance.
|
13
|
+
def petstore_auth
|
14
|
+
@auth_managers['petstore_auth']
|
15
|
+
end
|
16
|
+
|
17
|
+
# Access to pet controller.
|
18
|
+
# @return [PetController] Returns the controller instance.
|
19
|
+
def pet
|
20
|
+
@pet ||= PetController.new @global_configuration
|
21
|
+
end
|
22
|
+
|
23
|
+
# Access to store controller.
|
24
|
+
# @return [StoreController] Returns the controller instance.
|
25
|
+
def store
|
26
|
+
@store ||= StoreController.new @global_configuration
|
27
|
+
end
|
28
|
+
|
29
|
+
# Access to user controller.
|
30
|
+
# @return [UserController] Returns the controller instance.
|
31
|
+
def user
|
32
|
+
@user ||= UserController.new @global_configuration
|
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_credentials: nil,
|
41
|
+
http_basic_credentials: nil, petstore_auth_credentials: nil,
|
42
|
+
test_header: 'TestHeaderDefaultValue', config: nil
|
43
|
+
)
|
44
|
+
@config = if config.nil?
|
45
|
+
Configuration.new(
|
46
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
47
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
48
|
+
backoff_factor: backoff_factor,
|
49
|
+
retry_statuses: retry_statuses,
|
50
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
51
|
+
environment: environment,
|
52
|
+
api_key_credentials: api_key_credentials,
|
53
|
+
http_basic_credentials: http_basic_credentials,
|
54
|
+
petstore_auth_credentials: petstore_auth_credentials,
|
55
|
+
test_header: test_header
|
56
|
+
)
|
57
|
+
else
|
58
|
+
config
|
59
|
+
end
|
60
|
+
|
61
|
+
@global_configuration = GlobalConfiguration.new(client_configuration: @config)
|
62
|
+
.base_uri_executor(@config.method(:get_base_uri))
|
63
|
+
.global_errors(BaseController::GLOBAL_ERRORS)
|
64
|
+
.user_agent(BaseController.user_agent)
|
65
|
+
.global_header('TestHeader', @config.test_header)
|
66
|
+
|
67
|
+
initialize_auth_managers(@global_configuration)
|
68
|
+
@global_configuration = @global_configuration.auth_managers(@auth_managers)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Initializes the auth managers hash used for authenticating API calls.
|
72
|
+
# @param [GlobalConfiguration] global_config The global configuration of the SDK)
|
73
|
+
def initialize_auth_managers(global_config)
|
74
|
+
@auth_managers = {}
|
75
|
+
http_client_config = global_config.client_configuration
|
76
|
+
%w[api_key httpBasic petstore_auth].each { |auth| @auth_managers[auth] = nil }
|
77
|
+
@auth_managers['api_key'] = ApiKey.new(http_client_config.api_key_credentials)
|
78
|
+
@auth_managers['httpBasic'] = HttpBasic.new(http_client_config.http_basic_credentials)
|
79
|
+
@auth_managers['petstore_auth'] = PetstoreAuth.new(
|
80
|
+
http_client_config.petstore_auth_credentials, global_config
|
81
|
+
)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,124 @@
|
|
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
|
+
ENVIRONMENT2 = 'environment2'.freeze,
|
12
|
+
ENVIRONMENT3 = 'environment3'.freeze
|
13
|
+
].freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
# An enum for API servers.
|
17
|
+
class Server
|
18
|
+
SERVER = [
|
19
|
+
DEFAULT = 'default'.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, :api_key_credentials, :http_basic_credentials,
|
28
|
+
:petstore_auth_credentials, :test_header
|
29
|
+
|
30
|
+
class << self
|
31
|
+
attr_reader :environments
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(
|
35
|
+
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
36
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
37
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
38
|
+
retry_methods: %i[get put], http_callback: nil,
|
39
|
+
environment: Environment::PRODUCTION, api_key_credentials: nil,
|
40
|
+
http_basic_credentials: nil, petstore_auth_credentials: nil,
|
41
|
+
test_header: 'TestHeaderDefaultValue'
|
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
|
+
# The object holding Custom Header Signature credentials
|
53
|
+
@api_key_credentials = api_key_credentials
|
54
|
+
|
55
|
+
# The object holding Basic Authentication credentials
|
56
|
+
@http_basic_credentials = http_basic_credentials
|
57
|
+
|
58
|
+
# The object holding OAuth 2 Implicit Grant credentials
|
59
|
+
@petstore_auth_credentials = petstore_auth_credentials
|
60
|
+
|
61
|
+
# This is a test header
|
62
|
+
@test_header = test_header
|
63
|
+
|
64
|
+
# The Http Client to use for making requests.
|
65
|
+
set_http_client CoreLibrary::FaradayClient.new(self)
|
66
|
+
end
|
67
|
+
|
68
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
69
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
70
|
+
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
71
|
+
environment: nil, api_key_credentials: nil,
|
72
|
+
http_basic_credentials: nil, petstore_auth_credentials: nil,
|
73
|
+
test_header: nil)
|
74
|
+
connection ||= self.connection
|
75
|
+
adapter ||= self.adapter
|
76
|
+
timeout ||= self.timeout
|
77
|
+
max_retries ||= self.max_retries
|
78
|
+
retry_interval ||= self.retry_interval
|
79
|
+
backoff_factor ||= self.backoff_factor
|
80
|
+
retry_statuses ||= self.retry_statuses
|
81
|
+
retry_methods ||= self.retry_methods
|
82
|
+
http_callback ||= self.http_callback
|
83
|
+
environment ||= self.environment
|
84
|
+
api_key_credentials ||= self.api_key_credentials
|
85
|
+
http_basic_credentials ||= self.http_basic_credentials
|
86
|
+
petstore_auth_credentials ||= self.petstore_auth_credentials
|
87
|
+
test_header ||= self.test_header
|
88
|
+
|
89
|
+
Configuration.new(connection: connection, adapter: adapter,
|
90
|
+
timeout: timeout, max_retries: max_retries,
|
91
|
+
retry_interval: retry_interval,
|
92
|
+
backoff_factor: backoff_factor,
|
93
|
+
retry_statuses: retry_statuses,
|
94
|
+
retry_methods: retry_methods,
|
95
|
+
http_callback: http_callback, environment: environment,
|
96
|
+
api_key_credentials: api_key_credentials,
|
97
|
+
http_basic_credentials: http_basic_credentials,
|
98
|
+
petstore_auth_credentials: petstore_auth_credentials,
|
99
|
+
test_header: test_header)
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
# All the environments the SDK can run in.
|
104
|
+
ENVIRONMENTS = {
|
105
|
+
Environment::PRODUCTION => {
|
106
|
+
Server::DEFAULT => 'https://petstore.swagger.io/v2'
|
107
|
+
},
|
108
|
+
Environment::ENVIRONMENT2 => {
|
109
|
+
Server::DEFAULT => 'http://petstore.swagger.io/v2'
|
110
|
+
},
|
111
|
+
Environment::ENVIRONMENT3 => {
|
112
|
+
Server::DEFAULT => 'https://petstore.swagger.io/oauth'
|
113
|
+
}
|
114
|
+
}.freeze
|
115
|
+
|
116
|
+
# Generates the appropriate base URI for the environment and the server.
|
117
|
+
# @param [Configuration::Server] server The server enum for which the base URI is
|
118
|
+
# required.
|
119
|
+
# @return [String] The base URI.
|
120
|
+
def get_base_uri(server = Server::DEFAULT)
|
121
|
+
ENVIRONMENTS[environment][server].clone
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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
|
+
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,206 @@
|
|
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
|
+
# Multiple tags can be provided with comma separated strings. Use tag1,
|
10
|
+
# tag2, tag3 for testing.
|
11
|
+
# @param [Array[String]] tags Required parameter: Tags to filter by
|
12
|
+
# @return [Array[Pet]] response from the API call
|
13
|
+
def find_pets_by_tags(tags)
|
14
|
+
warn 'Endpoint find_pets_by_tags in PetController is deprecated'
|
15
|
+
new_api_call_builder
|
16
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
17
|
+
'/pet/findByTags',
|
18
|
+
Server::DEFAULT)
|
19
|
+
.query_param(new_parameter(tags, key: 'tags'))
|
20
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
21
|
+
.auth(Single.new('petstore_auth')))
|
22
|
+
.response(new_response_handler
|
23
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
24
|
+
.deserialize_into(Pet.method(:from_hash))
|
25
|
+
.is_response_array(true)
|
26
|
+
.local_error('400',
|
27
|
+
'Invalid tag value',
|
28
|
+
APIException))
|
29
|
+
.execute
|
30
|
+
end
|
31
|
+
|
32
|
+
# Update an existing pet
|
33
|
+
# @param [PetRequest] body Required parameter: Pet object that needs to be
|
34
|
+
# added to the store
|
35
|
+
# @return [void] response from the API call
|
36
|
+
def update_pet(body)
|
37
|
+
new_api_call_builder
|
38
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
39
|
+
'/pet',
|
40
|
+
Server::DEFAULT)
|
41
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
42
|
+
.body_param(new_parameter(body))
|
43
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
44
|
+
.auth(Single.new('petstore_auth')))
|
45
|
+
.response(new_response_handler
|
46
|
+
.is_response_void(true)
|
47
|
+
.local_error('400',
|
48
|
+
'Invalid ID supplied',
|
49
|
+
APIException)
|
50
|
+
.local_error('404',
|
51
|
+
'Pet not found',
|
52
|
+
APIException)
|
53
|
+
.local_error('405',
|
54
|
+
'Validation exception',
|
55
|
+
APIException))
|
56
|
+
.execute
|
57
|
+
end
|
58
|
+
|
59
|
+
# Add a new pet to the store
|
60
|
+
# @param [PetRequest] body Required parameter: Pet object that needs to be
|
61
|
+
# added to the store
|
62
|
+
# @return [void] response from the API call
|
63
|
+
def add_pet(body)
|
64
|
+
new_api_call_builder
|
65
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
66
|
+
'/pet',
|
67
|
+
Server::DEFAULT)
|
68
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
69
|
+
.body_param(new_parameter(body))
|
70
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
71
|
+
.auth(Single.new('petstore_auth')))
|
72
|
+
.response(new_response_handler
|
73
|
+
.is_response_void(true)
|
74
|
+
.local_error('405',
|
75
|
+
'Invalid input',
|
76
|
+
APIException))
|
77
|
+
.execute
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns a single pet
|
81
|
+
# @param [Integer] pet_id Required parameter: ID of pet to return
|
82
|
+
# @return [Pet] response from the API call
|
83
|
+
def get_pet_by_id(pet_id)
|
84
|
+
new_api_call_builder
|
85
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
86
|
+
'/pet/{petId}',
|
87
|
+
Server::DEFAULT)
|
88
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
89
|
+
.should_encode(true))
|
90
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
91
|
+
.auth(Single.new('api_key')))
|
92
|
+
.response(new_response_handler
|
93
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
94
|
+
.deserialize_into(Pet.method(:from_hash))
|
95
|
+
.local_error('400',
|
96
|
+
'Invalid ID supplied',
|
97
|
+
APIException)
|
98
|
+
.local_error('404',
|
99
|
+
'Pet not found',
|
100
|
+
APIException))
|
101
|
+
.execute
|
102
|
+
end
|
103
|
+
|
104
|
+
# Multiple status values can be provided with comma separated strings
|
105
|
+
# @param [Array[Status2Enum]] status Required parameter: Status values that
|
106
|
+
# need to be considered for filter
|
107
|
+
# @return [Array[Pet]] response from the API call
|
108
|
+
def find_pets_by_status(status)
|
109
|
+
new_api_call_builder
|
110
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
111
|
+
'/pet/findByStatus',
|
112
|
+
Server::DEFAULT)
|
113
|
+
.query_param(new_parameter(status, key: 'status'))
|
114
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
115
|
+
.auth(Single.new('petstore_auth')))
|
116
|
+
.response(new_response_handler
|
117
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
118
|
+
.deserialize_into(Pet.method(:from_hash))
|
119
|
+
.is_response_array(true)
|
120
|
+
.local_error('400',
|
121
|
+
'Invalid status value',
|
122
|
+
APIException))
|
123
|
+
.execute
|
124
|
+
end
|
125
|
+
|
126
|
+
# Updates a pet in the store with form data
|
127
|
+
# @param [Integer] pet_id Required parameter: ID of pet that needs to be
|
128
|
+
# updated
|
129
|
+
# @param [ContentTypeEnum] content_type Required parameter: Example:
|
130
|
+
# @param [String] name Optional parameter: Updated name of the pet
|
131
|
+
# @param [String] status Optional parameter: Updated status of the pet
|
132
|
+
# @return [void] response from the API call
|
133
|
+
def update_pet_with_form(pet_id,
|
134
|
+
content_type,
|
135
|
+
name: nil,
|
136
|
+
status: nil)
|
137
|
+
new_api_call_builder
|
138
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
139
|
+
'/pet/{petId}',
|
140
|
+
Server::DEFAULT)
|
141
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
142
|
+
.should_encode(true))
|
143
|
+
.form_param(new_parameter(name, key: 'name'))
|
144
|
+
.form_param(new_parameter(status, key: 'status'))
|
145
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
146
|
+
.auth(Single.new('petstore_auth')))
|
147
|
+
.response(new_response_handler
|
148
|
+
.is_response_void(true)
|
149
|
+
.local_error('405',
|
150
|
+
'Invalid input',
|
151
|
+
APIException))
|
152
|
+
.execute
|
153
|
+
end
|
154
|
+
|
155
|
+
# Deletes a pet
|
156
|
+
# @param [Integer] pet_id Required parameter: Pet id to delete
|
157
|
+
# @param [String] api_key Optional parameter: Example:
|
158
|
+
# @return [void] response from the API call
|
159
|
+
def delete_pet(pet_id,
|
160
|
+
api_key: nil)
|
161
|
+
new_api_call_builder
|
162
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
163
|
+
'/pet/{petId}',
|
164
|
+
Server::DEFAULT)
|
165
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
166
|
+
.should_encode(true))
|
167
|
+
.header_param(new_parameter(api_key, key: 'api_key'))
|
168
|
+
.auth(Single.new('petstore_auth')))
|
169
|
+
.response(new_response_handler
|
170
|
+
.is_response_void(true)
|
171
|
+
.local_error('400',
|
172
|
+
'Invalid ID supplied',
|
173
|
+
APIException)
|
174
|
+
.local_error('404',
|
175
|
+
'Pet not found',
|
176
|
+
APIException))
|
177
|
+
.execute
|
178
|
+
end
|
179
|
+
|
180
|
+
# uploads an image
|
181
|
+
# @param [Integer] pet_id Required parameter: ID of pet to update
|
182
|
+
# @param [String] additional_metadata Optional parameter: Additional data to
|
183
|
+
# pass to server
|
184
|
+
# @param [File | UploadIO] file Optional parameter: file to upload
|
185
|
+
# @return [ApiResponse] response from the API call
|
186
|
+
def upload_file(pet_id,
|
187
|
+
additional_metadata: nil,
|
188
|
+
file: nil)
|
189
|
+
new_api_call_builder
|
190
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
191
|
+
'/pet/{petId}/uploadImage',
|
192
|
+
Server::DEFAULT)
|
193
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
194
|
+
.should_encode(true))
|
195
|
+
.form_param(new_parameter(additional_metadata, key: 'additionalMetadata'))
|
196
|
+
.multipart_param(new_parameter(file, key: 'file')
|
197
|
+
.default_content_type('application/octet-stream'))
|
198
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
199
|
+
.auth(Single.new('petstore_auth')))
|
200
|
+
.response(new_response_handler
|
201
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
202
|
+
.deserialize_into(ApiResponse.method(:from_hash)))
|
203
|
+
.execute
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|