apimaticPetstore 1.0.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 +7 -0
- data/LICENSE +28 -0
- data/README.md +119 -0
- data/lib/swagger_petstore/api_helper.rb +10 -0
- data/lib/swagger_petstore/client.rb +76 -0
- data/lib/swagger_petstore/configuration.rb +125 -0
- data/lib/swagger_petstore/controllers/base_controller.rb +65 -0
- data/lib/swagger_petstore/controllers/pet_controller.rb +221 -0
- data/lib/swagger_petstore/controllers/store_controller.rb +104 -0
- data/lib/swagger_petstore/controllers/user_controller.rb +197 -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/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/add_pet_request.rb +102 -0
- data/lib/swagger_petstore/models/base_model.rb +58 -0
- data/lib/swagger_petstore/models/category.rb +57 -0
- data/lib/swagger_petstore/models/create_user_request.rb +111 -0
- data/lib/swagger_petstore/models/create_users_with_array_input_request.rb +111 -0
- data/lib/swagger_petstore/models/create_users_with_list_input_request.rb +111 -0
- data/lib/swagger_petstore/models/o_auth_provider_error_enum.rb +39 -0
- data/lib/swagger_petstore/models/o_auth_scope_enum.rb +17 -0
- data/lib/swagger_petstore/models/o_auth_token.rb +100 -0
- data/lib/swagger_petstore/models/place_order_request.rb +93 -0
- data/lib/swagger_petstore/models/response200.rb +66 -0
- data/lib/swagger_petstore/models/response2001.rb +102 -0
- data/lib/swagger_petstore/models/response20011.rb +48 -0
- data/lib/swagger_petstore/models/response20012.rb +111 -0
- data/lib/swagger_petstore/models/response2007.rb +93 -0
- data/lib/swagger_petstore/models/tag.rb +66 -0
- data/lib/swagger_petstore/models/update_pet_request.rb +102 -0
- data/lib/swagger_petstore/models/update_user_request.rb +111 -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 +59 -0
- data/test/controllers/controller_test_base.rb +33 -0
- data/test/controllers/test_pet_controller.rb +194 -0
- data/test/controllers/test_store_controller.rb +158 -0
- data/test/controllers/test_user_controller.rb +184 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +161 -0
@@ -0,0 +1,104 @@
|
|
1
|
+
# swagger_petstore
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SwaggerPetstore
|
7
|
+
# StoreController
|
8
|
+
class StoreController < BaseController
|
9
|
+
# Place an order for a pet
|
10
|
+
# @param [String] accept Required parameter: Example:
|
11
|
+
# @param [PlaceOrderRequest] body Required parameter: Example:
|
12
|
+
# @return [Response2007] response from the API call
|
13
|
+
def place_order(accept,
|
14
|
+
body)
|
15
|
+
new_api_call_builder
|
16
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
17
|
+
'/store/order',
|
18
|
+
Server::SERVER_1)
|
19
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
20
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
21
|
+
.body_param(new_parameter(body))
|
22
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
23
|
+
.auth(Single.new('global')))
|
24
|
+
.response(new_response_handler
|
25
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
26
|
+
.deserialize_into(Response2007.method(:from_hash))
|
27
|
+
.local_error('400',
|
28
|
+
'Invalid Order',
|
29
|
+
APIException))
|
30
|
+
.execute
|
31
|
+
end
|
32
|
+
|
33
|
+
# For valid response try integer IDs with value >= 1 and <= 10. Other values
|
34
|
+
# will generated exceptions
|
35
|
+
# @param [Integer] order_id Required parameter: ID of pet that needs to be
|
36
|
+
# fetched
|
37
|
+
# @param [String] accept Required parameter: Example:
|
38
|
+
# @return [Response2007] response from the API call
|
39
|
+
def get_order_by_id(order_id,
|
40
|
+
accept)
|
41
|
+
new_api_call_builder
|
42
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
43
|
+
'/store/order/{orderId}',
|
44
|
+
Server::SERVER_1)
|
45
|
+
.template_param(new_parameter(order_id, key: 'orderId')
|
46
|
+
.should_encode(true))
|
47
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
48
|
+
.auth(Single.new('global')))
|
49
|
+
.response(new_response_handler
|
50
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
51
|
+
.deserialize_into(Response2007.method(:from_hash))
|
52
|
+
.local_error('400',
|
53
|
+
'Invalid ID supplied',
|
54
|
+
APIException)
|
55
|
+
.local_error('404',
|
56
|
+
'Order not found',
|
57
|
+
APIException))
|
58
|
+
.execute
|
59
|
+
end
|
60
|
+
|
61
|
+
# For valid response try integer IDs with positive integer value. Negative
|
62
|
+
# or non-integer values will generate API errors
|
63
|
+
# @param [Integer] order_id Required parameter: ID of the order that needs
|
64
|
+
# to be deleted
|
65
|
+
# @param [String] accept Required parameter: Example:
|
66
|
+
# @return [void] response from the API call
|
67
|
+
def delete_order(order_id,
|
68
|
+
accept)
|
69
|
+
new_api_call_builder
|
70
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
71
|
+
'/store/order/{orderId}',
|
72
|
+
Server::SERVER_1)
|
73
|
+
.template_param(new_parameter(order_id, key: 'orderId')
|
74
|
+
.should_encode(true))
|
75
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
76
|
+
.auth(Single.new('global')))
|
77
|
+
.response(new_response_handler
|
78
|
+
.is_response_void(true)
|
79
|
+
.local_error('400',
|
80
|
+
'Invalid ID supplied',
|
81
|
+
APIException)
|
82
|
+
.local_error('404',
|
83
|
+
'Order not found',
|
84
|
+
APIException))
|
85
|
+
.execute
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns a map of status codes to quantities
|
89
|
+
# @param [String] accept Required parameter: Example:
|
90
|
+
# @return [Response20011] response from the API call
|
91
|
+
def get_inventory(accept)
|
92
|
+
new_api_call_builder
|
93
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
94
|
+
'/store/inventory',
|
95
|
+
Server::SERVER_1)
|
96
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
97
|
+
.auth(Single.new('global')))
|
98
|
+
.response(new_response_handler
|
99
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
100
|
+
.deserialize_into(Response20011.method(:from_hash)))
|
101
|
+
.execute
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
# swagger_petstore
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SwaggerPetstore
|
7
|
+
# UserController
|
8
|
+
class UserController < BaseController
|
9
|
+
# Creates list of users with given input array
|
10
|
+
# @param [String] accept Required parameter: Example:
|
11
|
+
# @param [List of CreateUsersWithArrayInputRequest] body Required parameter:
|
12
|
+
# Example:
|
13
|
+
# @return [Mixed] response from the API call
|
14
|
+
def create_users_with_array_input(accept,
|
15
|
+
body)
|
16
|
+
new_api_call_builder
|
17
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
18
|
+
'/user/createWithArray',
|
19
|
+
Server::SERVER_1)
|
20
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
21
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
22
|
+
.body_param(new_parameter(body))
|
23
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
24
|
+
.auth(Single.new('global')))
|
25
|
+
.response(new_response_handler
|
26
|
+
.deserializer(APIHelper.method(:dynamic_deserializer)))
|
27
|
+
.execute
|
28
|
+
end
|
29
|
+
|
30
|
+
# Creates list of users with given input array
|
31
|
+
# @param [String] accept Required parameter: Example:
|
32
|
+
# @param [List of CreateUsersWithListInputRequest] body Required parameter:
|
33
|
+
# Example:
|
34
|
+
# @return [Mixed] response from the API call
|
35
|
+
def create_users_with_list_input(accept,
|
36
|
+
body)
|
37
|
+
new_api_call_builder
|
38
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
39
|
+
'/user/createWithList',
|
40
|
+
Server::SERVER_1)
|
41
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
42
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
43
|
+
.body_param(new_parameter(body))
|
44
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
45
|
+
.auth(Single.new('global')))
|
46
|
+
.response(new_response_handler
|
47
|
+
.deserializer(APIHelper.method(:dynamic_deserializer)))
|
48
|
+
.execute
|
49
|
+
end
|
50
|
+
|
51
|
+
# Get user by user name
|
52
|
+
# @param [String] username Required parameter: The name that needs to be
|
53
|
+
# fetched. Use user1 for testing.
|
54
|
+
# @param [String] accept Required parameter: Example:
|
55
|
+
# @return [Response20012] response from the API call
|
56
|
+
def get_user_by_name(username,
|
57
|
+
accept)
|
58
|
+
new_api_call_builder
|
59
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
60
|
+
'/user/{username}',
|
61
|
+
Server::SERVER_1)
|
62
|
+
.template_param(new_parameter(username, key: 'username')
|
63
|
+
.should_encode(true))
|
64
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
65
|
+
.auth(Single.new('global')))
|
66
|
+
.response(new_response_handler
|
67
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
68
|
+
.deserialize_into(Response20012.method(:from_hash))
|
69
|
+
.local_error('400',
|
70
|
+
'Invalid username supplied',
|
71
|
+
APIException)
|
72
|
+
.local_error('404',
|
73
|
+
'User not found',
|
74
|
+
APIException))
|
75
|
+
.execute
|
76
|
+
end
|
77
|
+
|
78
|
+
# This can only be done by the logged in user.
|
79
|
+
# @param [String] username Required parameter: name that need to be
|
80
|
+
# updated
|
81
|
+
# @param [String] accept Required parameter: Example:
|
82
|
+
# @param [UpdateUserRequest] body Required parameter: Example:
|
83
|
+
# @return [void] response from the API call
|
84
|
+
def update_user(username,
|
85
|
+
accept,
|
86
|
+
body)
|
87
|
+
new_api_call_builder
|
88
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
89
|
+
'/user/{username}',
|
90
|
+
Server::SERVER_1)
|
91
|
+
.template_param(new_parameter(username, key: 'username')
|
92
|
+
.should_encode(true))
|
93
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
94
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
95
|
+
.body_param(new_parameter(body))
|
96
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
97
|
+
.auth(Single.new('global')))
|
98
|
+
.response(new_response_handler
|
99
|
+
.is_response_void(true)
|
100
|
+
.local_error('400',
|
101
|
+
'Invalid user supplied',
|
102
|
+
APIException)
|
103
|
+
.local_error('404',
|
104
|
+
'User not found',
|
105
|
+
APIException))
|
106
|
+
.execute
|
107
|
+
end
|
108
|
+
|
109
|
+
# This can only be done by the logged in user.
|
110
|
+
# @param [String] username Required parameter: The name that needs to be
|
111
|
+
# deleted
|
112
|
+
# @param [String] accept Required parameter: Example:
|
113
|
+
# @return [void] response from the API call
|
114
|
+
def delete_user(username,
|
115
|
+
accept)
|
116
|
+
new_api_call_builder
|
117
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
118
|
+
'/user/{username}',
|
119
|
+
Server::SERVER_1)
|
120
|
+
.template_param(new_parameter(username, key: 'username')
|
121
|
+
.should_encode(true))
|
122
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
123
|
+
.auth(Single.new('global')))
|
124
|
+
.response(new_response_handler
|
125
|
+
.is_response_void(true)
|
126
|
+
.local_error('400',
|
127
|
+
'Invalid username supplied',
|
128
|
+
APIException)
|
129
|
+
.local_error('404',
|
130
|
+
'User not found',
|
131
|
+
APIException))
|
132
|
+
.execute
|
133
|
+
end
|
134
|
+
|
135
|
+
# Logs user into the system
|
136
|
+
# @param [String] username Required parameter: The user name for login
|
137
|
+
# @param [String] password Required parameter: The password for login in
|
138
|
+
# clear text
|
139
|
+
# @param [String] accept Required parameter: Example:
|
140
|
+
# @return [String] response from the API call
|
141
|
+
def login_user(username,
|
142
|
+
password,
|
143
|
+
accept)
|
144
|
+
new_api_call_builder
|
145
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
146
|
+
'/user/login',
|
147
|
+
Server::SERVER_1)
|
148
|
+
.query_param(new_parameter(username, key: 'username'))
|
149
|
+
.query_param(new_parameter(password, key: 'password'))
|
150
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
151
|
+
.auth(Single.new('global')))
|
152
|
+
.response(new_response_handler
|
153
|
+
.deserializer(APIHelper.method(:deserialize_primitive_types))
|
154
|
+
.deserialize_into(proc do |response| response.to_s end)
|
155
|
+
.is_primitive_response(true)
|
156
|
+
.local_error('400',
|
157
|
+
'Invalid username/password supplied',
|
158
|
+
APIException))
|
159
|
+
.execute
|
160
|
+
end
|
161
|
+
|
162
|
+
# Logs out current logged in user session
|
163
|
+
# @param [String] accept Required parameter: Example:
|
164
|
+
# @return [Mixed] response from the API call
|
165
|
+
def logout_user(accept)
|
166
|
+
new_api_call_builder
|
167
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
168
|
+
'/user/logout',
|
169
|
+
Server::SERVER_1)
|
170
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
171
|
+
.auth(Single.new('global')))
|
172
|
+
.response(new_response_handler
|
173
|
+
.deserializer(APIHelper.method(:dynamic_deserializer)))
|
174
|
+
.execute
|
175
|
+
end
|
176
|
+
|
177
|
+
# This can only be done by the logged in user.
|
178
|
+
# @param [String] accept Required parameter: Example:
|
179
|
+
# @param [CreateUserRequest] body Required parameter: Example:
|
180
|
+
# @return [Mixed] response from the API call
|
181
|
+
def create_user(accept,
|
182
|
+
body)
|
183
|
+
new_api_call_builder
|
184
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
185
|
+
'/user',
|
186
|
+
Server::SERVER_1)
|
187
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
188
|
+
.header_param(new_parameter(accept, key: 'Accept'))
|
189
|
+
.body_param(new_parameter(body))
|
190
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
191
|
+
.auth(Single.new('global')))
|
192
|
+
.response(new_response_handler
|
193
|
+
.deserializer(APIHelper.method(:dynamic_deserializer)))
|
194
|
+
.execute
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
@@ -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
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
8
|
+
class APIException < CoreLibrary::ApiException
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# swagger_petstore
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SwaggerPetstore
|
7
|
+
# OAuth 2 Authorization endpoint exception.
|
8
|
+
class OAuthProviderException < APIException
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# Gets or sets error code.
|
13
|
+
# @return [OAuthProviderErrorEnum]
|
14
|
+
attr_accessor :error
|
15
|
+
|
16
|
+
# Gets or sets human-readable text providing additional information on
|
17
|
+
# error.
|
18
|
+
# Used to assist the client developer in understanding the error that
|
19
|
+
# occurred.
|
20
|
+
# @return [String]
|
21
|
+
attr_accessor :error_description
|
22
|
+
|
23
|
+
# Gets or sets a URI identifying a human-readable web page with information
|
24
|
+
# about the error, used to provide the client developer with additional
|
25
|
+
# information about the error.
|
26
|
+
# @return [String]
|
27
|
+
attr_accessor :error_uri
|
28
|
+
|
29
|
+
# The constructor.
|
30
|
+
# @param [String] The reason for raising an exception.
|
31
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
32
|
+
def initialize(reason, response)
|
33
|
+
super(reason, response)
|
34
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
35
|
+
unbox(hash)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Populates this object by extracting properties from a hash.
|
39
|
+
# @param [Hash] The deserialized response sent by the server in the
|
40
|
+
# response body.
|
41
|
+
def unbox(hash)
|
42
|
+
@error = hash.key?('error') ? hash['error'] : nil
|
43
|
+
@error_description =
|
44
|
+
hash.key?('error_description') ? hash['error_description'] : SKIP
|
45
|
+
@error_uri = hash.key?('error_uri') ? hash['error_uri'] : SKIP
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -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
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# swagger_petstore
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SwaggerPetstore
|
7
|
+
# AddPetRequest Model.
|
8
|
+
class AddPetRequest < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# TODO: Write general description for this method
|
13
|
+
# @return [String]
|
14
|
+
attr_accessor :name
|
15
|
+
|
16
|
+
# TODO: Write general description for this method
|
17
|
+
# @return [List of String]
|
18
|
+
attr_accessor :photo_urls
|
19
|
+
|
20
|
+
# TODO: Write general description for this method
|
21
|
+
# @return [Integer]
|
22
|
+
attr_accessor :id
|
23
|
+
|
24
|
+
# TODO: Write general description for this method
|
25
|
+
# @return [Category]
|
26
|
+
attr_accessor :category
|
27
|
+
|
28
|
+
# TODO: Write general description for this method
|
29
|
+
# @return [List of Tag]
|
30
|
+
attr_accessor :tags
|
31
|
+
|
32
|
+
# TODO: Write general description for this method
|
33
|
+
# @return [String]
|
34
|
+
attr_accessor :status
|
35
|
+
|
36
|
+
# A mapping from model property names to API property names.
|
37
|
+
def self.names
|
38
|
+
@_hash = {} if @_hash.nil?
|
39
|
+
@_hash['name'] = 'name'
|
40
|
+
@_hash['photo_urls'] = 'photoUrls'
|
41
|
+
@_hash['id'] = 'id'
|
42
|
+
@_hash['category'] = 'category'
|
43
|
+
@_hash['tags'] = 'tags'
|
44
|
+
@_hash['status'] = 'status'
|
45
|
+
@_hash
|
46
|
+
end
|
47
|
+
|
48
|
+
# An array for optional fields
|
49
|
+
def self.optionals
|
50
|
+
[]
|
51
|
+
end
|
52
|
+
|
53
|
+
# An array for nullable fields
|
54
|
+
def self.nullables
|
55
|
+
[]
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize(name = nil,
|
59
|
+
photo_urls = nil,
|
60
|
+
id = nil,
|
61
|
+
category = nil,
|
62
|
+
tags = nil,
|
63
|
+
status = nil)
|
64
|
+
@name = name
|
65
|
+
@photo_urls = photo_urls
|
66
|
+
@id = id
|
67
|
+
@category = category
|
68
|
+
@tags = tags
|
69
|
+
@status = status
|
70
|
+
end
|
71
|
+
|
72
|
+
# Creates an instance of the object from a hash.
|
73
|
+
def self.from_hash(hash)
|
74
|
+
return nil unless hash
|
75
|
+
|
76
|
+
# Extract variables from the hash.
|
77
|
+
name = hash.key?('name') ? hash['name'] : nil
|
78
|
+
photo_urls = hash.key?('photoUrls') ? hash['photoUrls'] : nil
|
79
|
+
id = hash.key?('id') ? hash['id'] : nil
|
80
|
+
category = Category.from_hash(hash['category']) if hash['category']
|
81
|
+
# Parameter is an array, so we need to iterate through it
|
82
|
+
tags = nil
|
83
|
+
unless hash['tags'].nil?
|
84
|
+
tags = []
|
85
|
+
hash['tags'].each do |structure|
|
86
|
+
tags << (Tag.from_hash(structure) if structure)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
tags = nil unless hash.key?('tags')
|
91
|
+
status = hash.key?('status') ? hash['status'] : nil
|
92
|
+
|
93
|
+
# Create object from extracted values.
|
94
|
+
AddPetRequest.new(name,
|
95
|
+
photo_urls,
|
96
|
+
id,
|
97
|
+
category,
|
98
|
+
tags,
|
99
|
+
status)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# swagger_petstore
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SwaggerPetstore
|
7
|
+
# Base model.
|
8
|
+
class BaseModel < CoreLibrary::BaseModel
|
9
|
+
# Returns a Hash representation of the current object.
|
10
|
+
def to_hash
|
11
|
+
hash = {}
|
12
|
+
instance_variables.each do |name|
|
13
|
+
value = instance_variable_get(name)
|
14
|
+
name = name[1..]
|
15
|
+
key = self.class.names.key?(name) ? self.class.names[name] : name
|
16
|
+
|
17
|
+
optional_fields = self.class.optionals
|
18
|
+
nullable_fields = self.class.nullables
|
19
|
+
if value.nil?
|
20
|
+
next unless nullable_fields.include?(name)
|
21
|
+
|
22
|
+
if !optional_fields.include?(name) && !nullable_fields.include?(name)
|
23
|
+
raise ArgumentError,
|
24
|
+
"`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
hash[key] = nil
|
29
|
+
unless value.nil?
|
30
|
+
if respond_to?("to_#{name}")
|
31
|
+
if (value.instance_of? Array) || (value.instance_of? Hash)
|
32
|
+
params = [hash, key]
|
33
|
+
hash[key] = send("to_#{name}", *params)
|
34
|
+
else
|
35
|
+
hash[key] = send("to_#{name}")
|
36
|
+
end
|
37
|
+
elsif value.instance_of? Array
|
38
|
+
hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
|
39
|
+
elsif value.instance_of? Hash
|
40
|
+
hash[key] = {}
|
41
|
+
value.each do |k, v|
|
42
|
+
hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
|
43
|
+
end
|
44
|
+
else
|
45
|
+
hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
hash
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns a JSON representation of the curent object.
|
53
|
+
def to_json(options = {})
|
54
|
+
hash = to_hash
|
55
|
+
hash.to_json(options)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# swagger_petstore
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SwaggerPetstore
|
7
|
+
# Category Model.
|
8
|
+
class Category < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# TODO: Write general description for this method
|
13
|
+
# @return [Integer]
|
14
|
+
attr_accessor :id
|
15
|
+
|
16
|
+
# TODO: Write general description for this method
|
17
|
+
# @return [String]
|
18
|
+
attr_accessor :name
|
19
|
+
|
20
|
+
# A mapping from model property names to API property names.
|
21
|
+
def self.names
|
22
|
+
@_hash = {} if @_hash.nil?
|
23
|
+
@_hash['id'] = 'id'
|
24
|
+
@_hash['name'] = 'name'
|
25
|
+
@_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
# An array for optional fields
|
29
|
+
def self.optionals
|
30
|
+
[]
|
31
|
+
end
|
32
|
+
|
33
|
+
# An array for nullable fields
|
34
|
+
def self.nullables
|
35
|
+
[]
|
36
|
+
end
|
37
|
+
|
38
|
+
def initialize(id = nil,
|
39
|
+
name = nil)
|
40
|
+
@id = id
|
41
|
+
@name = name
|
42
|
+
end
|
43
|
+
|
44
|
+
# Creates an instance of the object from a hash.
|
45
|
+
def self.from_hash(hash)
|
46
|
+
return nil unless hash
|
47
|
+
|
48
|
+
# Extract variables from the hash.
|
49
|
+
id = hash.key?('id') ? hash['id'] : nil
|
50
|
+
name = hash.key?('name') ? hash['name'] : nil
|
51
|
+
|
52
|
+
# Create object from extracted values.
|
53
|
+
Category.new(id,
|
54
|
+
name)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|