rose-nielsen-sdk 0.0.7 → 0.1.1
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 +4 -4
- data/README.md +60 -18
- data/lib/{cypress_test_api → swagger_petstore}/api_helper.rb +2 -2
- data/lib/swagger_petstore/client.rb +84 -0
- data/lib/{cypress_test_api → swagger_petstore}/configuration.rb +41 -17
- data/lib/{cypress_test_api → swagger_petstore}/controllers/base_controller.rb +2 -2
- 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/{cypress_test_api → swagger_petstore}/exceptions/api_exception.rb +2 -2
- data/lib/swagger_petstore/exceptions/o_auth_provider_exception.rb +64 -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 +98 -0
- data/lib/{cypress_test_api → swagger_petstore}/http/http_call_back.rb +2 -2
- data/lib/{cypress_test_api → swagger_petstore}/http/http_method_enum.rb +2 -2
- data/lib/{cypress_test_api → swagger_petstore}/http/http_request.rb +2 -2
- data/lib/{cypress_test_api → swagger_petstore}/http/http_response.rb +2 -2
- data/lib/{cypress_test_api → swagger_petstore}/http/proxy_settings.rb +2 -2
- data/lib/{cypress_test_api/models/message2.rb → swagger_petstore/models/api_response.rb} +24 -14
- data/lib/{cypress_test_api → swagger_petstore}/models/base_model.rb +2 -2
- data/lib/{cypress_test_api/models/item_response.rb → swagger_petstore/models/category.rb} +10 -19
- data/lib/{cypress_test_api/models/deer.rb → swagger_petstore/models/category2.rb} +21 -18
- 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 +96 -0
- data/lib/swagger_petstore/models/order.rb +120 -0
- data/lib/swagger_petstore/models/pet.rb +117 -0
- data/lib/swagger_petstore/models/pet_request.rb +117 -0
- data/lib/swagger_petstore/models/status1_enum.rb +26 -0
- data/lib/swagger_petstore/models/status2_enum.rb +26 -0
- data/lib/{cypress_test_api → swagger_petstore}/models/status_enum.rb +9 -9
- data/lib/swagger_petstore/models/store_order_request.rb +120 -0
- data/lib/{cypress_test_api/models/response_http404.rb → swagger_petstore/models/tag.rb} +18 -9
- data/lib/swagger_petstore/models/user.rb +132 -0
- data/lib/swagger_petstore/models/user_request.rb +132 -0
- data/lib/{cypress_test_api → swagger_petstore}/utilities/date_time_helper.rb +2 -2
- data/lib/{cypress_test_api → swagger_petstore}/utilities/file_wrapper.rb +2 -2
- data/lib/swagger_petstore.rb +62 -0
- data/test/controllers/controller_test_base.rb +13 -5
- data/test/controllers/test_store_controller.rb +31 -0
- data/test/http_response_catcher.rb +2 -2
- metadata +41 -34
- data/lib/cypress_test_api/client.rb +0 -47
- data/lib/cypress_test_api/controllers/api_controller.rb +0 -102
- data/lib/cypress_test_api/models/custom_enum.rb +0 -26
- data/lib/cypress_test_api/models/item.rb +0 -166
- data/lib/cypress_test_api/models/lion.rb +0 -68
- data/lib/cypress_test_api/models/message.rb +0 -68
- data/lib/cypress_test_api/models/multiple_arrays_request.rb +0 -70
- data/lib/cypress_test_api/models/nac_tag.rb +0 -265
- data/lib/cypress_test_api/models/o_auth_scope_o_auth_acg_enum.rb +0 -29
- data/lib/cypress_test_api/models/response_http400.rb +0 -62
- data/lib/cypress_test_api/models/status11_enum.rb +0 -26
- data/lib/cypress_test_api/models/status1_enum.rb +0 -26
- data/lib/cypress_test_api/models/tokens_request.rb +0 -60
- data/lib/cypress_test_api.rb +0 -55
- data/test/controllers/test_api_controller.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb8a5c8fea2cf6c916c8029d4fe15d5bc5508ec8faf1b0a07511e75bd6d5aef8
|
4
|
+
data.tar.gz: c6e2d9cfe0b63cb2d299bbc619ed2ec82bc76d732569e41f8493dad4220e94d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a82f1e66a1432fb11706aa5ebb89b346643de966d97ae6cf861707846eaa895f35962c87a17dfdf6865298ae56d9511b112622a09c39f9a4867c6107f106d287
|
7
|
+
data.tar.gz: b88fee604dbcb169a5a6ba298541d98a27f30dd52e2725199186f4f6555b9b611696d6469b4cdfec32ba1b5bd5b96280017a13a4c71184f93f625355f58a9456
|
data/README.md
CHANGED
@@ -1,25 +1,27 @@
|
|
1
1
|
|
2
|
-
# Getting Started with
|
2
|
+
# Getting Started with Swagger Petstore
|
3
3
|
|
4
4
|
## Introduction
|
5
5
|
|
6
|
-
This is a sample
|
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)
|
7
9
|
|
8
10
|
## Install the Package
|
9
11
|
|
10
12
|
Install the gem from the command line:
|
11
13
|
|
12
14
|
```bash
|
13
|
-
gem install rose-nielsen-sdk -v 0.
|
15
|
+
gem install rose-nielsen-sdk -v 0.1.1
|
14
16
|
```
|
15
17
|
|
16
18
|
Or add the gem to your Gemfile and run `bundle`:
|
17
19
|
|
18
20
|
```ruby
|
19
|
-
gem 'rose-nielsen-sdk', '0.
|
21
|
+
gem 'rose-nielsen-sdk', '0.1.1'
|
20
22
|
```
|
21
23
|
|
22
|
-
For additional gem details, see the [RubyGems page for the rose-nielsen-sdk gem](https://rubygems.org/gems/rose-nielsen-sdk/versions/0.
|
24
|
+
For additional gem details, see the [RubyGems page for the rose-nielsen-sdk gem](https://rubygems.org/gems/rose-nielsen-sdk/versions/0.1.1).
|
23
25
|
|
24
26
|
## Test the SDK
|
25
27
|
|
@@ -31,13 +33,13 @@ rake
|
|
31
33
|
|
32
34
|
## Initialize the API Client
|
33
35
|
|
34
|
-
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.
|
36
|
+
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/client.md)
|
35
37
|
|
36
38
|
The following parameters are configurable for the API Client:
|
37
39
|
|
38
40
|
| Parameter | Type | Description |
|
39
41
|
| --- | --- | --- |
|
40
|
-
|
|
42
|
+
| test_header | `String` | This is a test header<br>*Default*: `'TestHeaderDefaultValue'` |
|
41
43
|
| environment | `Environment` | The API environment. <br> **Default: `Environment.PRODUCTION`** |
|
42
44
|
| connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
|
43
45
|
| adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
|
@@ -48,37 +50,77 @@ The following parameters are configurable for the API Client:
|
|
48
50
|
| retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
|
49
51
|
| retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
|
50
52
|
| http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
|
51
|
-
| proxy_settings | [`ProxySettings`](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.
|
53
|
+
| proxy_settings | [`ProxySettings`](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
|
54
|
+
| api_key_credentials | [`ApiKeyCredentials`](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/auth/custom-header-signature.md) | The credential object for Custom Header Signature |
|
55
|
+
| http_basic_credentials | [`HttpBasicCredentials`](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/auth/basic-authentication.md) | The credential object for Basic Authentication |
|
56
|
+
| petstore_auth_credentials | [`PetstoreAuthCredentials`](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/auth/oauth-2-implicit-grant.md) | The credential object for OAuth 2 Implicit Grant |
|
52
57
|
|
53
58
|
The API client can be initialized as follows:
|
54
59
|
|
55
60
|
```ruby
|
56
|
-
require '
|
57
|
-
include
|
61
|
+
require 'swagger_petstore'
|
62
|
+
include SwaggerPetstore
|
58
63
|
|
59
64
|
client = Client.new(
|
60
|
-
|
61
|
-
|
65
|
+
test_header: 'TestHeaderDefaultValue',
|
66
|
+
api_key_credentials: ApiKeyCredentials.new(
|
67
|
+
api_key: 'api_key'
|
68
|
+
),
|
69
|
+
http_basic_credentials: HttpBasicCredentials.new(
|
70
|
+
username: 'username',
|
71
|
+
passwprd: 'passwprd'
|
72
|
+
),
|
73
|
+
petstore_auth_credentials: PetstoreAuthCredentials.new(
|
74
|
+
o_auth_client_id: 'OAuthClientId',
|
75
|
+
o_auth_redirect_uri: 'OAuthRedirectUri',
|
76
|
+
o_auth_scopes: [
|
77
|
+
OAuthScopePetstoreAuthEnum::READPETS,
|
78
|
+
OAuthScopePetstoreAuthEnum::WRITEPETS
|
79
|
+
]
|
80
|
+
),
|
81
|
+
environment: Environment::PRODUCTION
|
62
82
|
)
|
63
83
|
```
|
64
84
|
|
85
|
+
## Environments
|
86
|
+
|
87
|
+
The SDK can be configured to use a different environment for making API calls. Available environments are:
|
88
|
+
|
89
|
+
### Fields
|
90
|
+
|
91
|
+
| Name | Description |
|
92
|
+
| --- | --- |
|
93
|
+
| production | **Default** |
|
94
|
+
| environment2 | - |
|
95
|
+
| environment3 | - |
|
96
|
+
|
97
|
+
## Authorization
|
98
|
+
|
99
|
+
This API uses the following authentication schemes.
|
100
|
+
|
101
|
+
* [`api_key (Custom Header Signature)`](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/auth/custom-header-signature.md)
|
102
|
+
* [`httpBasic (Basic Authentication)`](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/auth/basic-authentication.md)
|
103
|
+
* [`petstore_auth (OAuth 2 Implicit Grant)`](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/auth/oauth-2-implicit-grant.md)
|
104
|
+
|
65
105
|
## List of APIs
|
66
106
|
|
67
|
-
* [
|
107
|
+
* [Pet](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/controllers/pet.md)
|
108
|
+
* [Store](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/controllers/store.md)
|
109
|
+
* [User](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/controllers/user.md)
|
68
110
|
|
69
111
|
## SDK Infrastructure
|
70
112
|
|
71
113
|
### Configuration
|
72
114
|
|
73
|
-
* [ProxySettings](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.
|
115
|
+
* [ProxySettings](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/proxy-settings.md)
|
74
116
|
|
75
117
|
### HTTP
|
76
118
|
|
77
|
-
* [HttpResponse](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.
|
78
|
-
* [HttpRequest](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.
|
119
|
+
* [HttpResponse](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/http-response.md)
|
120
|
+
* [HttpRequest](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/http-request.md)
|
79
121
|
|
80
122
|
### Utilities
|
81
123
|
|
82
|
-
* [ApiHelper](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.
|
83
|
-
* [DateTimeHelper](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.
|
124
|
+
* [ApiHelper](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/api-helper.md)
|
125
|
+
* [DateTimeHelper](https://www.github.com/ZahraN444/rose-nielsen-ruby-sdk/tree/0.1.1/doc/date-time-helper.md)
|
84
126
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# swagger_petstore
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
4
|
+
# ( https://www.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, proxy_settings: 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
|
+
proxy_settings: proxy_settings, 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
|
@@ -1,13 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# swagger_petstore
|
2
2
|
#
|
3
3
|
# This file was automatically generated by APIMATIC v3.0
|
4
4
|
# ( https://www.apimatic.io ).
|
5
5
|
|
6
|
-
module
|
6
|
+
module SwaggerPetstore
|
7
7
|
# An enum for SDK environments.
|
8
8
|
class Environment
|
9
9
|
ENVIRONMENT = [
|
10
|
-
PRODUCTION = 'production'.freeze
|
10
|
+
PRODUCTION = 'production'.freeze,
|
11
|
+
ENVIRONMENT2 = 'environment2'.freeze,
|
12
|
+
ENVIRONMENT3 = 'environment3'.freeze
|
11
13
|
].freeze
|
12
14
|
end
|
13
15
|
|
@@ -22,7 +24,8 @@ module CypressTestApi
|
|
22
24
|
# are configured in this class.
|
23
25
|
class Configuration < CoreLibrary::HttpClientConfiguration
|
24
26
|
# The attribute readers for properties.
|
25
|
-
attr_reader :environment, :
|
27
|
+
attr_reader :environment, :api_key_credentials, :http_basic_credentials,
|
28
|
+
:petstore_auth_credentials, :test_header
|
26
29
|
|
27
30
|
class << self
|
28
31
|
attr_reader :environments
|
@@ -33,7 +36,9 @@ module CypressTestApi
|
|
33
36
|
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
34
37
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
35
38
|
retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
|
36
|
-
environment: Environment::PRODUCTION,
|
39
|
+
environment: Environment::PRODUCTION, api_key_credentials: nil,
|
40
|
+
http_basic_credentials: nil, petstore_auth_credentials: nil,
|
41
|
+
test_header: 'TestHeaderDefaultValue'
|
37
42
|
)
|
38
43
|
super connection: connection, adapter: adapter, timeout: timeout,
|
39
44
|
max_retries: max_retries, retry_interval: retry_interval,
|
@@ -44,8 +49,17 @@ module CypressTestApi
|
|
44
49
|
# Current API environment
|
45
50
|
@environment = String(environment)
|
46
51
|
|
47
|
-
#
|
48
|
-
@
|
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
|
49
63
|
|
50
64
|
# The Http Client to use for making requests.
|
51
65
|
set_http_client CoreLibrary::FaradayClient.new(self)
|
@@ -54,7 +68,9 @@ module CypressTestApi
|
|
54
68
|
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
55
69
|
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
56
70
|
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
57
|
-
proxy_settings: nil, environment: nil,
|
71
|
+
proxy_settings: nil, environment: nil,
|
72
|
+
api_key_credentials: nil, http_basic_credentials: nil,
|
73
|
+
petstore_auth_credentials: nil, test_header: nil)
|
58
74
|
connection ||= self.connection
|
59
75
|
adapter ||= self.adapter
|
60
76
|
timeout ||= self.timeout
|
@@ -66,7 +82,10 @@ module CypressTestApi
|
|
66
82
|
http_callback ||= self.http_callback
|
67
83
|
proxy_settings ||= self.proxy_settings
|
68
84
|
environment ||= self.environment
|
69
|
-
|
85
|
+
api_key_credentials ||= self.api_key_credentials
|
86
|
+
http_basic_credentials ||= self.http_basic_credentials
|
87
|
+
petstore_auth_credentials ||= self.petstore_auth_credentials
|
88
|
+
test_header ||= self.test_header
|
70
89
|
|
71
90
|
Configuration.new(connection: connection, adapter: adapter,
|
72
91
|
timeout: timeout, max_retries: max_retries,
|
@@ -76,14 +95,24 @@ module CypressTestApi
|
|
76
95
|
retry_methods: retry_methods,
|
77
96
|
http_callback: http_callback,
|
78
97
|
proxy_settings: proxy_settings,
|
79
|
-
environment: environment,
|
98
|
+
environment: environment,
|
99
|
+
api_key_credentials: api_key_credentials,
|
100
|
+
http_basic_credentials: http_basic_credentials,
|
101
|
+
petstore_auth_credentials: petstore_auth_credentials,
|
102
|
+
test_header: test_header)
|
80
103
|
end
|
81
104
|
|
82
105
|
|
83
106
|
# All the environments the SDK can run in.
|
84
107
|
ENVIRONMENTS = {
|
85
108
|
Environment::PRODUCTION => {
|
86
|
-
Server::DEFAULT => 'https://
|
109
|
+
Server::DEFAULT => 'https://petstore.swagger.io/v2'
|
110
|
+
},
|
111
|
+
Environment::ENVIRONMENT2 => {
|
112
|
+
Server::DEFAULT => 'http://petstore.swagger.io/v2'
|
113
|
+
},
|
114
|
+
Environment::ENVIRONMENT3 => {
|
115
|
+
Server::DEFAULT => 'https://petstore.swagger.io/oauth'
|
87
116
|
}
|
88
117
|
}.freeze
|
89
118
|
|
@@ -92,12 +121,7 @@ module CypressTestApi
|
|
92
121
|
# required.
|
93
122
|
# @return [String] The base URI.
|
94
123
|
def get_base_uri(server = Server::DEFAULT)
|
95
|
-
|
96
|
-
'defaultHost' => { 'value' => default_host, 'encode' => false }
|
97
|
-
}
|
98
|
-
APIHelper.append_url_with_template_parameters(
|
99
|
-
ENVIRONMENTS[environment][server], parameters
|
100
|
-
)
|
124
|
+
ENVIRONMENTS[environment][server].clone
|
101
125
|
end
|
102
126
|
end
|
103
127
|
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
# swagger_petstore
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v3.0
|
4
|
+
# ( https://www.apimatic.io ).
|
5
|
+
|
6
|
+
module SwaggerPetstore
|
7
|
+
# PetController
|
8
|
+
class PetController < BaseController
|
9
|
+
# Returns a single pet
|
10
|
+
# @param [Integer] pet_id Required parameter: ID of pet to return
|
11
|
+
# @return [Pet] Response from the API call.
|
12
|
+
def get_pet_by_id(pet_id)
|
13
|
+
@api_call
|
14
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
15
|
+
'/pet/{petId}',
|
16
|
+
Server::DEFAULT)
|
17
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
18
|
+
.should_encode(true))
|
19
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
20
|
+
.auth(Single.new('api_key')))
|
21
|
+
.response(new_response_handler
|
22
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
23
|
+
.deserialize_into(Pet.method(:from_hash))
|
24
|
+
.local_error('400',
|
25
|
+
'Invalid ID supplied',
|
26
|
+
APIException)
|
27
|
+
.local_error('404',
|
28
|
+
'Pet not found',
|
29
|
+
APIException))
|
30
|
+
.execute
|
31
|
+
end
|
32
|
+
|
33
|
+
# Updates a pet in the store with form data
|
34
|
+
# @param [Integer] pet_id Required parameter: ID of pet that needs to be
|
35
|
+
# updated
|
36
|
+
# @param [ContentTypeEnum] content_type Required parameter: Example:
|
37
|
+
# @param [String] name Optional parameter: Updated name of the pet
|
38
|
+
# @param [String] status Optional parameter: Updated status of the pet
|
39
|
+
# @return [void] Response from the API call.
|
40
|
+
def update_pet_with_form(pet_id,
|
41
|
+
content_type,
|
42
|
+
name: nil,
|
43
|
+
status: nil)
|
44
|
+
@api_call
|
45
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
46
|
+
'/pet/{petId}',
|
47
|
+
Server::DEFAULT)
|
48
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
49
|
+
.should_encode(true))
|
50
|
+
.form_param(new_parameter(name, key: 'name'))
|
51
|
+
.form_param(new_parameter(status, key: 'status'))
|
52
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
53
|
+
.auth(Single.new('petstore_auth')))
|
54
|
+
.response(new_response_handler
|
55
|
+
.is_response_void(true)
|
56
|
+
.local_error('405',
|
57
|
+
'Invalid input',
|
58
|
+
APIException))
|
59
|
+
.execute
|
60
|
+
end
|
61
|
+
|
62
|
+
# Deletes a pet
|
63
|
+
# @param [Integer] pet_id Required parameter: Pet id to delete
|
64
|
+
# @param [String] api_key Optional parameter: Example:
|
65
|
+
# @return [void] Response from the API call.
|
66
|
+
def delete_pet(pet_id,
|
67
|
+
api_key: nil)
|
68
|
+
@api_call
|
69
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
70
|
+
'/pet/{petId}',
|
71
|
+
Server::DEFAULT)
|
72
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
73
|
+
.should_encode(true))
|
74
|
+
.header_param(new_parameter(api_key, key: 'api_key'))
|
75
|
+
.auth(Single.new('petstore_auth')))
|
76
|
+
.response(new_response_handler
|
77
|
+
.is_response_void(true)
|
78
|
+
.local_error('400',
|
79
|
+
'Invalid ID supplied',
|
80
|
+
APIException)
|
81
|
+
.local_error('404',
|
82
|
+
'Pet not found',
|
83
|
+
APIException))
|
84
|
+
.execute
|
85
|
+
end
|
86
|
+
|
87
|
+
# Add a new pet to the store
|
88
|
+
# @param [PetRequest] body Required parameter: Pet object that needs to be
|
89
|
+
# added to the store
|
90
|
+
# @return [void] Response from the API call.
|
91
|
+
def add_pet(body)
|
92
|
+
@api_call
|
93
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
94
|
+
'/pet',
|
95
|
+
Server::DEFAULT)
|
96
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
97
|
+
.body_param(new_parameter(body))
|
98
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
99
|
+
.auth(Single.new('petstore_auth')))
|
100
|
+
.response(new_response_handler
|
101
|
+
.is_response_void(true)
|
102
|
+
.local_error('405',
|
103
|
+
'Invalid input',
|
104
|
+
APIException))
|
105
|
+
.execute
|
106
|
+
end
|
107
|
+
|
108
|
+
# Update an existing pet
|
109
|
+
# @param [PetRequest] body Required parameter: Pet object that needs to be
|
110
|
+
# added to the store
|
111
|
+
# @return [void] Response from the API call.
|
112
|
+
def update_pet(body)
|
113
|
+
@api_call
|
114
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
115
|
+
'/pet',
|
116
|
+
Server::DEFAULT)
|
117
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
118
|
+
.body_param(new_parameter(body))
|
119
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
120
|
+
.auth(Single.new('petstore_auth')))
|
121
|
+
.response(new_response_handler
|
122
|
+
.is_response_void(true)
|
123
|
+
.local_error('400',
|
124
|
+
'Invalid ID supplied',
|
125
|
+
APIException)
|
126
|
+
.local_error('404',
|
127
|
+
'Pet not found',
|
128
|
+
APIException)
|
129
|
+
.local_error('405',
|
130
|
+
'Validation exception',
|
131
|
+
APIException))
|
132
|
+
.execute
|
133
|
+
end
|
134
|
+
|
135
|
+
# Multiple status values can be provided with comma separated strings
|
136
|
+
# @param [Array[Status2Enum]] status Required parameter: Status values that
|
137
|
+
# need to be considered for filter
|
138
|
+
# @return [Array[Pet]] Response from the API call.
|
139
|
+
def find_pets_by_status(status)
|
140
|
+
@api_call
|
141
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
142
|
+
'/pet/findByStatus',
|
143
|
+
Server::DEFAULT)
|
144
|
+
.query_param(new_parameter(status, key: 'status'))
|
145
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
146
|
+
.auth(Single.new('petstore_auth')))
|
147
|
+
.response(new_response_handler
|
148
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
149
|
+
.deserialize_into(Pet.method(:from_hash))
|
150
|
+
.is_response_array(true)
|
151
|
+
.local_error('400',
|
152
|
+
'Invalid status value',
|
153
|
+
APIException))
|
154
|
+
.execute
|
155
|
+
end
|
156
|
+
|
157
|
+
# uploads an image
|
158
|
+
# @param [Integer] pet_id Required parameter: ID of pet to update
|
159
|
+
# @param [String] additional_metadata Optional parameter: Additional data to
|
160
|
+
# pass to server
|
161
|
+
# @param [File | UploadIO] file Optional parameter: file to upload
|
162
|
+
# @return [ApiResponse] Response from the API call.
|
163
|
+
def upload_file(pet_id,
|
164
|
+
additional_metadata: nil,
|
165
|
+
file: nil)
|
166
|
+
@api_call
|
167
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
168
|
+
'/pet/{petId}/uploadImage',
|
169
|
+
Server::DEFAULT)
|
170
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
171
|
+
.should_encode(true))
|
172
|
+
.form_param(new_parameter(additional_metadata, key: 'additionalMetadata'))
|
173
|
+
.multipart_param(new_parameter(file, key: 'file')
|
174
|
+
.default_content_type('application/octet-stream'))
|
175
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
176
|
+
.auth(Single.new('petstore_auth')))
|
177
|
+
.response(new_response_handler
|
178
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
179
|
+
.deserialize_into(ApiResponse.method(:from_hash)))
|
180
|
+
.execute
|
181
|
+
end
|
182
|
+
|
183
|
+
# Multiple tags can be provided with comma separated strings. Use tag1,
|
184
|
+
# tag2, tag3 for testing.
|
185
|
+
# @param [Array[String]] tags Required parameter: Tags to filter by
|
186
|
+
# @return [Array[Pet]] Response from the API call.
|
187
|
+
def find_pets_by_tags(tags)
|
188
|
+
warn 'Endpoint find_pets_by_tags in PetController is deprecated'
|
189
|
+
@api_call
|
190
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
191
|
+
'/pet/findByTags',
|
192
|
+
Server::DEFAULT)
|
193
|
+
.query_param(new_parameter(tags, key: 'tags'))
|
194
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
195
|
+
.auth(Single.new('petstore_auth')))
|
196
|
+
.response(new_response_handler
|
197
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
198
|
+
.deserialize_into(Pet.method(:from_hash))
|
199
|
+
.is_response_array(true)
|
200
|
+
.local_error('400',
|
201
|
+
'Invalid tag value',
|
202
|
+
APIException))
|
203
|
+
.execute
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|