package-test-ruby 1.0.3
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 +174 -0
- data/bin/console +15 -0
- data/lib/swagger_petstore_open_api30/api_helper.rb +10 -0
- data/lib/swagger_petstore_open_api30/client.rb +90 -0
- data/lib/swagger_petstore_open_api30/configuration.rb +173 -0
- data/lib/swagger_petstore_open_api30/controllers/base_controller.rb +60 -0
- data/lib/swagger_petstore_open_api30/controllers/pet_controller.rb +271 -0
- data/lib/swagger_petstore_open_api30/controllers/store_controller.rb +125 -0
- data/lib/swagger_petstore_open_api30/controllers/user_controller.rb +223 -0
- data/lib/swagger_petstore_open_api30/exceptions/api_exception.rb +21 -0
- data/lib/swagger_petstore_open_api30/exceptions/o_auth_provider_exception.rb +64 -0
- data/lib/swagger_petstore_open_api30/http/auth/api_key.rb +52 -0
- data/lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb +113 -0
- data/lib/swagger_petstore_open_api30/http/http_call_back.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/http_method_enum.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/http_request.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/http_response.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/proxy_settings.rb +22 -0
- data/lib/swagger_petstore_open_api30/models/api_response.rb +101 -0
- data/lib/swagger_petstore_open_api30/models/base_model.rb +110 -0
- data/lib/swagger_petstore_open_api30/models/category.rb +88 -0
- data/lib/swagger_petstore_open_api30/models/o_auth_provider_error_enum.rb +62 -0
- data/lib/swagger_petstore_open_api30/models/o_auth_scope_petstore_auth_enum.rb +36 -0
- data/lib/swagger_petstore_open_api30/models/o_auth_token.rb +125 -0
- data/lib/swagger_petstore_open_api30/models/order.rb +151 -0
- data/lib/swagger_petstore_open_api30/models/pet.rb +151 -0
- data/lib/swagger_petstore_open_api30/models/status1_enum.rb +40 -0
- data/lib/swagger_petstore_open_api30/models/status2_enum.rb +40 -0
- data/lib/swagger_petstore_open_api30/models/status_enum.rb +40 -0
- data/lib/swagger_petstore_open_api30/models/tag.rb +88 -0
- data/lib/swagger_petstore_open_api30/models/user.rb +167 -0
- data/lib/swagger_petstore_open_api30/utilities/date_time_helper.rb +11 -0
- data/lib/swagger_petstore_open_api30/utilities/file_wrapper.rb +28 -0
- data/lib/swagger_petstore_open_api30/utilities/xml_utilities.rb +12 -0
- data/lib/swagger_petstore_open_api30.rb +59 -0
- data/test/controllers/controller_test_base.rb +28 -0
- data/test/controllers/test_pet_controller.rb +50 -0
- data/test/controllers/test_store_controller.rb +55 -0
- data/test/controllers/test_user_controller.rb +156 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +153 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# PetController
|
|
8
|
+
class PetController < BaseController
|
|
9
|
+
# Update an existing pet by Id.
|
|
10
|
+
# @param [String] name Required parameter: TODO: type description here
|
|
11
|
+
# @param [Array[String]] photo_urls Required parameter: TODO: type
|
|
12
|
+
# description here
|
|
13
|
+
# @param [Integer] id Optional parameter: TODO: type description here
|
|
14
|
+
# @param [Category] category Optional parameter: TODO: type description
|
|
15
|
+
# here
|
|
16
|
+
# @param [Array[Tag]] tags Optional parameter: TODO: type description here
|
|
17
|
+
# @param [Status1Enum] status Optional parameter: pet status in the store
|
|
18
|
+
# @return [Pet] Response from the API call.
|
|
19
|
+
def update_pet(name,
|
|
20
|
+
photo_urls,
|
|
21
|
+
id: nil,
|
|
22
|
+
category: nil,
|
|
23
|
+
tags: nil,
|
|
24
|
+
status: nil)
|
|
25
|
+
@api_call
|
|
26
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
|
27
|
+
'/pet',
|
|
28
|
+
Server::DEFAULT)
|
|
29
|
+
.form_param(new_parameter(name, key: 'name'))
|
|
30
|
+
.form_param(new_parameter(photo_urls, key: 'photoUrls'))
|
|
31
|
+
.form_param(new_parameter(id, key: 'id'))
|
|
32
|
+
.form_param(new_parameter(category, key: 'category'))
|
|
33
|
+
.form_param(new_parameter(tags, key: 'tags'))
|
|
34
|
+
.form_param(new_parameter(status, key: 'status'))
|
|
35
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
|
36
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
37
|
+
.auth(Single.new('petstore_auth')))
|
|
38
|
+
.response(new_response_handler
|
|
39
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
40
|
+
.deserialize_into(Pet.method(:from_hash))
|
|
41
|
+
.local_error('400',
|
|
42
|
+
'Invalid ID supplied',
|
|
43
|
+
APIException)
|
|
44
|
+
.local_error('404',
|
|
45
|
+
'Pet not found',
|
|
46
|
+
APIException)
|
|
47
|
+
.local_error('422',
|
|
48
|
+
'Validation exception',
|
|
49
|
+
APIException)
|
|
50
|
+
.local_error('default',
|
|
51
|
+
'Unexpected error',
|
|
52
|
+
APIException))
|
|
53
|
+
.execute
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Add a new pet to the store.
|
|
57
|
+
# @param [String] name Required parameter: TODO: type description here
|
|
58
|
+
# @param [Array[String]] photo_urls Required parameter: TODO: type
|
|
59
|
+
# description here
|
|
60
|
+
# @param [Integer] id Optional parameter: TODO: type description here
|
|
61
|
+
# @param [Category] category Optional parameter: TODO: type description
|
|
62
|
+
# here
|
|
63
|
+
# @param [Array[Tag]] tags Optional parameter: TODO: type description here
|
|
64
|
+
# @param [Status1Enum] status Optional parameter: pet status in the store
|
|
65
|
+
# @return [Pet] Response from the API call.
|
|
66
|
+
def add_pet(name,
|
|
67
|
+
photo_urls,
|
|
68
|
+
id: nil,
|
|
69
|
+
category: nil,
|
|
70
|
+
tags: nil,
|
|
71
|
+
status: nil)
|
|
72
|
+
@api_call
|
|
73
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
74
|
+
'/pet',
|
|
75
|
+
Server::DEFAULT)
|
|
76
|
+
.form_param(new_parameter(name, key: 'name'))
|
|
77
|
+
.form_param(new_parameter(photo_urls, key: 'photoUrls'))
|
|
78
|
+
.form_param(new_parameter(id, key: 'id'))
|
|
79
|
+
.form_param(new_parameter(category, key: 'category'))
|
|
80
|
+
.form_param(new_parameter(tags, key: 'tags'))
|
|
81
|
+
.form_param(new_parameter(status, key: 'status'))
|
|
82
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
|
83
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
84
|
+
.auth(Single.new('petstore_auth')))
|
|
85
|
+
.response(new_response_handler
|
|
86
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
87
|
+
.deserialize_into(Pet.method(:from_hash))
|
|
88
|
+
.local_error('400',
|
|
89
|
+
'Invalid input',
|
|
90
|
+
APIException)
|
|
91
|
+
.local_error('422',
|
|
92
|
+
'Validation exception',
|
|
93
|
+
APIException)
|
|
94
|
+
.local_error('default',
|
|
95
|
+
'Unexpected error',
|
|
96
|
+
APIException))
|
|
97
|
+
.execute
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Multiple status values can be provided with comma separated strings.
|
|
101
|
+
# @param [Status2Enum] status Required parameter: Status values that need to
|
|
102
|
+
# be considered for filter
|
|
103
|
+
# @return [Array[Pet]] Response from the API call.
|
|
104
|
+
def find_pets_by_status(status)
|
|
105
|
+
@api_call
|
|
106
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
107
|
+
'/pet/findByStatus',
|
|
108
|
+
Server::DEFAULT)
|
|
109
|
+
.query_param(new_parameter(status, key: 'status'))
|
|
110
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
111
|
+
.auth(Single.new('petstore_auth')))
|
|
112
|
+
.response(new_response_handler
|
|
113
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
114
|
+
.deserialize_into(Pet.method(:from_hash))
|
|
115
|
+
.is_response_array(true)
|
|
116
|
+
.local_error('400',
|
|
117
|
+
'Invalid status value',
|
|
118
|
+
APIException)
|
|
119
|
+
.local_error('default',
|
|
120
|
+
'Unexpected error',
|
|
121
|
+
APIException))
|
|
122
|
+
.execute
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Multiple tags can be provided with comma separated strings. Use tag1,
|
|
126
|
+
# tag2, tag3 for testing.
|
|
127
|
+
# @param [Array[String]] tags Required parameter: Tags to filter by
|
|
128
|
+
# @return [Array[Pet]] Response from the API call.
|
|
129
|
+
def find_pets_by_tags(tags)
|
|
130
|
+
@api_call
|
|
131
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
132
|
+
'/pet/findByTags',
|
|
133
|
+
Server::DEFAULT)
|
|
134
|
+
.query_param(new_parameter(tags, key: 'tags'))
|
|
135
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
136
|
+
.auth(Single.new('petstore_auth')))
|
|
137
|
+
.response(new_response_handler
|
|
138
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
139
|
+
.deserialize_into(Pet.method(:from_hash))
|
|
140
|
+
.is_response_array(true)
|
|
141
|
+
.local_error('400',
|
|
142
|
+
'Invalid tag value',
|
|
143
|
+
APIException)
|
|
144
|
+
.local_error('default',
|
|
145
|
+
'Unexpected error',
|
|
146
|
+
APIException))
|
|
147
|
+
.execute
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Returns a single pet.
|
|
151
|
+
# @param [Integer] pet_id Required parameter: ID of pet to return
|
|
152
|
+
# @return [Pet] Response from the API call.
|
|
153
|
+
def get_pet_by_id(pet_id)
|
|
154
|
+
@api_call
|
|
155
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
156
|
+
'/pet/{petId}',
|
|
157
|
+
Server::DEFAULT)
|
|
158
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
|
159
|
+
.should_encode(true))
|
|
160
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
161
|
+
.auth(Or.new('api_key', 'petstore_auth')))
|
|
162
|
+
.response(new_response_handler
|
|
163
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
164
|
+
.deserialize_into(Pet.method(:from_hash))
|
|
165
|
+
.local_error('400',
|
|
166
|
+
'Invalid ID supplied',
|
|
167
|
+
APIException)
|
|
168
|
+
.local_error('404',
|
|
169
|
+
'Pet not found',
|
|
170
|
+
APIException)
|
|
171
|
+
.local_error('default',
|
|
172
|
+
'Unexpected error',
|
|
173
|
+
APIException))
|
|
174
|
+
.execute
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Updates a pet resource based on the form data.
|
|
178
|
+
# @param [Integer] pet_id Required parameter: ID of pet that needs to be
|
|
179
|
+
# updated
|
|
180
|
+
# @param [String] name Optional parameter: Name of pet that needs to be
|
|
181
|
+
# updated
|
|
182
|
+
# @param [String] status Optional parameter: Status of pet that needs to be
|
|
183
|
+
# updated
|
|
184
|
+
# @return [Pet] Response from the API call.
|
|
185
|
+
def update_pet_with_form(pet_id,
|
|
186
|
+
name: nil,
|
|
187
|
+
status: nil)
|
|
188
|
+
@api_call
|
|
189
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
190
|
+
'/pet/{petId}',
|
|
191
|
+
Server::DEFAULT)
|
|
192
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
|
193
|
+
.should_encode(true))
|
|
194
|
+
.query_param(new_parameter(name, key: 'name'))
|
|
195
|
+
.query_param(new_parameter(status, key: 'status'))
|
|
196
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
197
|
+
.auth(Single.new('petstore_auth')))
|
|
198
|
+
.response(new_response_handler
|
|
199
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
200
|
+
.deserialize_into(Pet.method(:from_hash))
|
|
201
|
+
.local_error('400',
|
|
202
|
+
'Invalid input',
|
|
203
|
+
APIException)
|
|
204
|
+
.local_error('default',
|
|
205
|
+
'Unexpected error',
|
|
206
|
+
APIException))
|
|
207
|
+
.execute
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# Delete a pet.
|
|
211
|
+
# @param [Integer] pet_id Required parameter: Pet id to delete
|
|
212
|
+
# @param [String] api_key Optional parameter: TODO: type description here
|
|
213
|
+
# @return [void] Response from the API call.
|
|
214
|
+
def delete_pet(pet_id,
|
|
215
|
+
api_key: nil)
|
|
216
|
+
@api_call
|
|
217
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
|
218
|
+
'/pet/{petId}',
|
|
219
|
+
Server::DEFAULT)
|
|
220
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
|
221
|
+
.should_encode(true))
|
|
222
|
+
.header_param(new_parameter(api_key, key: 'api_key'))
|
|
223
|
+
.auth(Single.new('petstore_auth')))
|
|
224
|
+
.response(new_response_handler
|
|
225
|
+
.is_response_void(true)
|
|
226
|
+
.local_error('400',
|
|
227
|
+
'Invalid pet value',
|
|
228
|
+
APIException)
|
|
229
|
+
.local_error('default',
|
|
230
|
+
'Unexpected error',
|
|
231
|
+
APIException))
|
|
232
|
+
.execute
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# Upload image of the pet.
|
|
236
|
+
# @param [Integer] pet_id Required parameter: ID of pet to update
|
|
237
|
+
# @param [String] additional_metadata Optional parameter: Additional
|
|
238
|
+
# Metadata
|
|
239
|
+
# @param [File | UploadIO] body Optional parameter: TODO: type description
|
|
240
|
+
# here
|
|
241
|
+
# @return [ApiResponse] Response from the API call.
|
|
242
|
+
def upload_file(pet_id,
|
|
243
|
+
additional_metadata: nil,
|
|
244
|
+
body: nil)
|
|
245
|
+
@api_call
|
|
246
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
247
|
+
'/pet/{petId}/uploadImage',
|
|
248
|
+
Server::DEFAULT)
|
|
249
|
+
.template_param(new_parameter(pet_id, key: 'petId')
|
|
250
|
+
.should_encode(true))
|
|
251
|
+
.query_param(new_parameter(additional_metadata, key: 'additionalMetadata'))
|
|
252
|
+
.multipart_param(new_parameter(body, key: 'body')
|
|
253
|
+
.default_content_type('application/octet-stream'))
|
|
254
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
255
|
+
.auth(Single.new('petstore_auth')))
|
|
256
|
+
.response(new_response_handler
|
|
257
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
258
|
+
.deserialize_into(ApiResponse.method(:from_hash))
|
|
259
|
+
.local_error('400',
|
|
260
|
+
'No file uploaded',
|
|
261
|
+
APIException)
|
|
262
|
+
.local_error('404',
|
|
263
|
+
'Pet not found',
|
|
264
|
+
APIException)
|
|
265
|
+
.local_error('default',
|
|
266
|
+
'Unexpected error',
|
|
267
|
+
APIException))
|
|
268
|
+
.execute
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# StoreController
|
|
8
|
+
class StoreController < BaseController
|
|
9
|
+
# Returns a map of status codes to quantities.
|
|
10
|
+
# @return [Hash[String, Integer]] Response from the API call.
|
|
11
|
+
def get_inventory
|
|
12
|
+
@api_call
|
|
13
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
14
|
+
'/store/inventory',
|
|
15
|
+
Server::DEFAULT)
|
|
16
|
+
.auth(Single.new('api_key')))
|
|
17
|
+
.response(new_response_handler
|
|
18
|
+
.deserializer(APIHelper.method(:deserialize_primitive_types))
|
|
19
|
+
.deserialize_into(proc do |response| response&.to_i end)
|
|
20
|
+
.is_primitive_response(true)
|
|
21
|
+
.local_error('default',
|
|
22
|
+
'Unexpected error',
|
|
23
|
+
APIException))
|
|
24
|
+
.execute
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Place a new order in the store.
|
|
28
|
+
# @param [Integer] id Optional parameter: TODO: type description here
|
|
29
|
+
# @param [Integer] pet_id Optional parameter: TODO: type description here
|
|
30
|
+
# @param [Integer] quantity Optional parameter: TODO: type description
|
|
31
|
+
# here
|
|
32
|
+
# @param [DateTime] ship_date Optional parameter: TODO: type description
|
|
33
|
+
# here
|
|
34
|
+
# @param [StatusEnum] status Optional parameter: Order Status
|
|
35
|
+
# @param [TrueClass | FalseClass] complete Optional parameter: TODO: type
|
|
36
|
+
# description here
|
|
37
|
+
# @return [Order] Response from the API call.
|
|
38
|
+
def place_order(id: nil,
|
|
39
|
+
pet_id: nil,
|
|
40
|
+
quantity: nil,
|
|
41
|
+
ship_date: nil,
|
|
42
|
+
status: nil,
|
|
43
|
+
complete: nil)
|
|
44
|
+
@api_call
|
|
45
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
46
|
+
'/store/order',
|
|
47
|
+
Server::DEFAULT)
|
|
48
|
+
.form_param(new_parameter(id, key: 'id'))
|
|
49
|
+
.form_param(new_parameter(pet_id, key: 'petId'))
|
|
50
|
+
.form_param(new_parameter(quantity, key: 'quantity'))
|
|
51
|
+
.form_param(new_parameter(ship_date, key: 'shipDate'))
|
|
52
|
+
.form_param(new_parameter(status, key: 'status'))
|
|
53
|
+
.form_param(new_parameter(complete, key: 'complete'))
|
|
54
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
|
55
|
+
.header_param(new_parameter('application/json', key: 'accept')))
|
|
56
|
+
.response(new_response_handler
|
|
57
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
58
|
+
.deserialize_into(Order.method(:from_hash))
|
|
59
|
+
.local_error('400',
|
|
60
|
+
'Invalid input',
|
|
61
|
+
APIException)
|
|
62
|
+
.local_error('422',
|
|
63
|
+
'Validation exception',
|
|
64
|
+
APIException)
|
|
65
|
+
.local_error('default',
|
|
66
|
+
'Unexpected error',
|
|
67
|
+
APIException))
|
|
68
|
+
.execute
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# For valid response try integer IDs with value <= 5 or > 10. Other values
|
|
72
|
+
# will generate exceptions.
|
|
73
|
+
# @param [Integer] order_id Required parameter: ID of order that needs to be
|
|
74
|
+
# fetched
|
|
75
|
+
# @return [Order] Response from the API call.
|
|
76
|
+
def get_order_by_id(order_id)
|
|
77
|
+
@api_call
|
|
78
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
79
|
+
'/store/order/{orderId}',
|
|
80
|
+
Server::DEFAULT)
|
|
81
|
+
.template_param(new_parameter(order_id, key: 'orderId')
|
|
82
|
+
.should_encode(true))
|
|
83
|
+
.header_param(new_parameter('application/json', key: 'accept')))
|
|
84
|
+
.response(new_response_handler
|
|
85
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
86
|
+
.deserialize_into(Order.method(:from_hash))
|
|
87
|
+
.local_error('400',
|
|
88
|
+
'Invalid ID supplied',
|
|
89
|
+
APIException)
|
|
90
|
+
.local_error('404',
|
|
91
|
+
'Order not found',
|
|
92
|
+
APIException)
|
|
93
|
+
.local_error('default',
|
|
94
|
+
'Unexpected error',
|
|
95
|
+
APIException))
|
|
96
|
+
.execute
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# For valid response try integer IDs with value < 1000. Anything above 1000
|
|
100
|
+
# or non-integers will generate API errors.
|
|
101
|
+
# @param [Integer] order_id Required parameter: ID of the order that needs
|
|
102
|
+
# to be deleted
|
|
103
|
+
# @return [void] Response from the API call.
|
|
104
|
+
def delete_order(order_id)
|
|
105
|
+
@api_call
|
|
106
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
|
107
|
+
'/store/order/{orderId}',
|
|
108
|
+
Server::DEFAULT)
|
|
109
|
+
.template_param(new_parameter(order_id, key: 'orderId')
|
|
110
|
+
.should_encode(true)))
|
|
111
|
+
.response(new_response_handler
|
|
112
|
+
.is_response_void(true)
|
|
113
|
+
.local_error('400',
|
|
114
|
+
'Invalid ID supplied',
|
|
115
|
+
APIException)
|
|
116
|
+
.local_error('404',
|
|
117
|
+
'Order not found',
|
|
118
|
+
APIException)
|
|
119
|
+
.local_error('default',
|
|
120
|
+
'Unexpected error',
|
|
121
|
+
APIException))
|
|
122
|
+
.execute
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# UserController
|
|
8
|
+
class UserController < BaseController
|
|
9
|
+
# This can only be done by the logged in user.
|
|
10
|
+
# @param [Integer] id Optional parameter: TODO: type description here
|
|
11
|
+
# @param [String] username Optional parameter: TODO: type description here
|
|
12
|
+
# @param [String] first_name Optional parameter: TODO: type description
|
|
13
|
+
# here
|
|
14
|
+
# @param [String] last_name Optional parameter: TODO: type description
|
|
15
|
+
# here
|
|
16
|
+
# @param [String] email Optional parameter: TODO: type description here
|
|
17
|
+
# @param [String] password Optional parameter: TODO: type description here
|
|
18
|
+
# @param [String] phone Optional parameter: TODO: type description here
|
|
19
|
+
# @param [Integer] user_status Optional parameter: User Status
|
|
20
|
+
# @return [User] Response from the API call.
|
|
21
|
+
def create_user(id: nil,
|
|
22
|
+
username: nil,
|
|
23
|
+
first_name: nil,
|
|
24
|
+
last_name: nil,
|
|
25
|
+
email: nil,
|
|
26
|
+
password: nil,
|
|
27
|
+
phone: nil,
|
|
28
|
+
user_status: nil)
|
|
29
|
+
@api_call
|
|
30
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
31
|
+
'/user',
|
|
32
|
+
Server::DEFAULT)
|
|
33
|
+
.form_param(new_parameter(id, key: 'id'))
|
|
34
|
+
.form_param(new_parameter(username, key: 'username'))
|
|
35
|
+
.form_param(new_parameter(first_name, key: 'firstName'))
|
|
36
|
+
.form_param(new_parameter(last_name, key: 'lastName'))
|
|
37
|
+
.form_param(new_parameter(email, key: 'email'))
|
|
38
|
+
.form_param(new_parameter(password, key: 'password'))
|
|
39
|
+
.form_param(new_parameter(phone, key: 'phone'))
|
|
40
|
+
.form_param(new_parameter(user_status, key: 'userStatus'))
|
|
41
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
|
42
|
+
.header_param(new_parameter('application/json', key: 'accept')))
|
|
43
|
+
.response(new_response_handler
|
|
44
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
45
|
+
.deserialize_into(User.method(:from_hash))
|
|
46
|
+
.local_error('default',
|
|
47
|
+
'Unexpected error',
|
|
48
|
+
APIException))
|
|
49
|
+
.execute
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Creates list of users with given input array.
|
|
53
|
+
# @param [Array[User]] body Optional parameter: TODO: type description
|
|
54
|
+
# here
|
|
55
|
+
# @return [User] Response from the API call.
|
|
56
|
+
def create_users_with_list_input(body: nil)
|
|
57
|
+
@api_call
|
|
58
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
59
|
+
'/user/createWithList',
|
|
60
|
+
Server::DEFAULT)
|
|
61
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
|
62
|
+
.body_param(new_parameter(body))
|
|
63
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
|
64
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end))
|
|
65
|
+
.response(new_response_handler
|
|
66
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
67
|
+
.deserialize_into(User.method(:from_hash))
|
|
68
|
+
.local_error('default',
|
|
69
|
+
'Unexpected error',
|
|
70
|
+
APIException))
|
|
71
|
+
.execute
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Log into the system.
|
|
75
|
+
# @param [String] username Optional parameter: The user name for login
|
|
76
|
+
# @param [String] password Optional parameter: The password for login in
|
|
77
|
+
# clear text
|
|
78
|
+
# @return [String] Response from the API call.
|
|
79
|
+
def login_user(username: nil,
|
|
80
|
+
password: nil)
|
|
81
|
+
@api_call
|
|
82
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
83
|
+
'/user/login',
|
|
84
|
+
Server::DEFAULT)
|
|
85
|
+
.query_param(new_parameter(username, key: 'username'))
|
|
86
|
+
.query_param(new_parameter(password, key: 'password'))
|
|
87
|
+
.header_param(new_parameter('application/xml', key: 'accept')))
|
|
88
|
+
.response(new_response_handler
|
|
89
|
+
.deserializer(XmlUtilities.method(:deserialize_xml))
|
|
90
|
+
.deserialize_into(String)
|
|
91
|
+
.is_xml_response(true)
|
|
92
|
+
.xml_attribute(XmlAttributes.new
|
|
93
|
+
.root_element_name('response'))
|
|
94
|
+
.is_primitive_response(true)
|
|
95
|
+
.local_error('400',
|
|
96
|
+
'Invalid username/password supplied',
|
|
97
|
+
APIException)
|
|
98
|
+
.local_error('default',
|
|
99
|
+
'Unexpected error',
|
|
100
|
+
APIException))
|
|
101
|
+
.execute
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Log user out of the system.
|
|
105
|
+
# @return [void] Response from the API call.
|
|
106
|
+
def logout_user
|
|
107
|
+
@api_call
|
|
108
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
109
|
+
'/user/logout',
|
|
110
|
+
Server::DEFAULT))
|
|
111
|
+
.response(new_response_handler
|
|
112
|
+
.is_response_void(true)
|
|
113
|
+
.local_error('default',
|
|
114
|
+
'Unexpected error',
|
|
115
|
+
APIException))
|
|
116
|
+
.execute
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Get user detail based on username.
|
|
120
|
+
# @param [String] username Required parameter: The name that needs to be
|
|
121
|
+
# fetched. Use user1 for testing
|
|
122
|
+
# @return [User] Response from the API call.
|
|
123
|
+
def get_user_by_name(username)
|
|
124
|
+
@api_call
|
|
125
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
|
126
|
+
'/user/{username}',
|
|
127
|
+
Server::DEFAULT)
|
|
128
|
+
.template_param(new_parameter(username, key: 'username')
|
|
129
|
+
.should_encode(true))
|
|
130
|
+
.header_param(new_parameter('application/json', key: 'accept')))
|
|
131
|
+
.response(new_response_handler
|
|
132
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
133
|
+
.deserialize_into(User.method(:from_hash))
|
|
134
|
+
.local_error('400',
|
|
135
|
+
'Invalid username supplied',
|
|
136
|
+
APIException)
|
|
137
|
+
.local_error('404',
|
|
138
|
+
'User not found',
|
|
139
|
+
APIException)
|
|
140
|
+
.local_error('default',
|
|
141
|
+
'Unexpected error',
|
|
142
|
+
APIException))
|
|
143
|
+
.execute
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# This can only be done by the logged in user.
|
|
147
|
+
# @param [String] username_template Required parameter: name that need to be
|
|
148
|
+
# deleted
|
|
149
|
+
# @param [Integer] id Optional parameter: TODO: type description here
|
|
150
|
+
# @param [String] username Optional parameter: TODO: type description here
|
|
151
|
+
# @param [String] first_name Optional parameter: TODO: type description
|
|
152
|
+
# here
|
|
153
|
+
# @param [String] last_name Optional parameter: TODO: type description
|
|
154
|
+
# here
|
|
155
|
+
# @param [String] email Optional parameter: TODO: type description here
|
|
156
|
+
# @param [String] password Optional parameter: TODO: type description here
|
|
157
|
+
# @param [String] phone Optional parameter: TODO: type description here
|
|
158
|
+
# @param [Integer] user_status Optional parameter: User Status
|
|
159
|
+
# @return [void] Response from the API call.
|
|
160
|
+
def update_user(username_template,
|
|
161
|
+
id: nil,
|
|
162
|
+
username: nil,
|
|
163
|
+
first_name: nil,
|
|
164
|
+
last_name: nil,
|
|
165
|
+
email: nil,
|
|
166
|
+
password: nil,
|
|
167
|
+
phone: nil,
|
|
168
|
+
user_status: nil)
|
|
169
|
+
@api_call
|
|
170
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
|
171
|
+
'/user/{username}',
|
|
172
|
+
Server::DEFAULT)
|
|
173
|
+
.template_param(new_parameter(username_template, key: 'username')
|
|
174
|
+
.should_encode(true))
|
|
175
|
+
.form_param(new_parameter(id, key: 'id'))
|
|
176
|
+
.form_param(new_parameter(username, key: 'username'))
|
|
177
|
+
.form_param(new_parameter(first_name, key: 'firstName'))
|
|
178
|
+
.form_param(new_parameter(last_name, key: 'lastName'))
|
|
179
|
+
.form_param(new_parameter(email, key: 'email'))
|
|
180
|
+
.form_param(new_parameter(password, key: 'password'))
|
|
181
|
+
.form_param(new_parameter(phone, key: 'phone'))
|
|
182
|
+
.form_param(new_parameter(user_status, key: 'userStatus'))
|
|
183
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')))
|
|
184
|
+
.response(new_response_handler
|
|
185
|
+
.is_response_void(true)
|
|
186
|
+
.local_error('400',
|
|
187
|
+
'bad request',
|
|
188
|
+
APIException)
|
|
189
|
+
.local_error('404',
|
|
190
|
+
'user not found',
|
|
191
|
+
APIException)
|
|
192
|
+
.local_error('default',
|
|
193
|
+
'Unexpected error',
|
|
194
|
+
APIException))
|
|
195
|
+
.execute
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# This can only be done by the logged in user.
|
|
199
|
+
# @param [String] username Required parameter: The name that needs to be
|
|
200
|
+
# deleted
|
|
201
|
+
# @return [void] Response from the API call.
|
|
202
|
+
def delete_user(username)
|
|
203
|
+
@api_call
|
|
204
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
|
205
|
+
'/user/{username}',
|
|
206
|
+
Server::DEFAULT)
|
|
207
|
+
.template_param(new_parameter(username, key: 'username')
|
|
208
|
+
.should_encode(true)))
|
|
209
|
+
.response(new_response_handler
|
|
210
|
+
.is_response_void(true)
|
|
211
|
+
.local_error('400',
|
|
212
|
+
'Invalid username supplied',
|
|
213
|
+
APIException)
|
|
214
|
+
.local_error('404',
|
|
215
|
+
'User not found',
|
|
216
|
+
APIException)
|
|
217
|
+
.local_error('default',
|
|
218
|
+
'Unexpected error',
|
|
219
|
+
APIException))
|
|
220
|
+
.execute
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
|
8
|
+
class APIException < CoreLibrary::ApiException
|
|
9
|
+
# Provides a human-readable string representation of the object.
|
|
10
|
+
def to_s
|
|
11
|
+
class_name = self.class.name.split('::').last
|
|
12
|
+
"<#{class_name} status_code: #{@response_code}, reason: #{@reason}>"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
16
|
+
def inspect
|
|
17
|
+
class_name = self.class.name.split('::').last
|
|
18
|
+
"<#{class_name} status_code: #{@response_code.inspect}, reason: #{@reason.inspect}>"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|