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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +119 -0
  4. data/lib/swagger_petstore/api_helper.rb +10 -0
  5. data/lib/swagger_petstore/client.rb +76 -0
  6. data/lib/swagger_petstore/configuration.rb +125 -0
  7. data/lib/swagger_petstore/controllers/base_controller.rb +65 -0
  8. data/lib/swagger_petstore/controllers/pet_controller.rb +221 -0
  9. data/lib/swagger_petstore/controllers/store_controller.rb +104 -0
  10. data/lib/swagger_petstore/controllers/user_controller.rb +197 -0
  11. data/lib/swagger_petstore/exceptions/api_exception.rb +10 -0
  12. data/lib/swagger_petstore/exceptions/o_auth_provider_exception.rb +48 -0
  13. data/lib/swagger_petstore/http/http_call_back.rb +10 -0
  14. data/lib/swagger_petstore/http/http_method_enum.rb +10 -0
  15. data/lib/swagger_petstore/http/http_request.rb +10 -0
  16. data/lib/swagger_petstore/http/http_response.rb +10 -0
  17. data/lib/swagger_petstore/models/add_pet_request.rb +102 -0
  18. data/lib/swagger_petstore/models/base_model.rb +58 -0
  19. data/lib/swagger_petstore/models/category.rb +57 -0
  20. data/lib/swagger_petstore/models/create_user_request.rb +111 -0
  21. data/lib/swagger_petstore/models/create_users_with_array_input_request.rb +111 -0
  22. data/lib/swagger_petstore/models/create_users_with_list_input_request.rb +111 -0
  23. data/lib/swagger_petstore/models/o_auth_provider_error_enum.rb +39 -0
  24. data/lib/swagger_petstore/models/o_auth_scope_enum.rb +17 -0
  25. data/lib/swagger_petstore/models/o_auth_token.rb +100 -0
  26. data/lib/swagger_petstore/models/place_order_request.rb +93 -0
  27. data/lib/swagger_petstore/models/response200.rb +66 -0
  28. data/lib/swagger_petstore/models/response2001.rb +102 -0
  29. data/lib/swagger_petstore/models/response20011.rb +48 -0
  30. data/lib/swagger_petstore/models/response20012.rb +111 -0
  31. data/lib/swagger_petstore/models/response2007.rb +93 -0
  32. data/lib/swagger_petstore/models/tag.rb +66 -0
  33. data/lib/swagger_petstore/models/update_pet_request.rb +102 -0
  34. data/lib/swagger_petstore/models/update_user_request.rb +111 -0
  35. data/lib/swagger_petstore/utilities/date_time_helper.rb +11 -0
  36. data/lib/swagger_petstore/utilities/file_wrapper.rb +16 -0
  37. data/lib/swagger_petstore.rb +59 -0
  38. data/test/controllers/controller_test_base.rb +33 -0
  39. data/test/controllers/test_pet_controller.rb +194 -0
  40. data/test/controllers/test_store_controller.rb +158 -0
  41. data/test/controllers/test_user_controller.rb +184 -0
  42. data/test/http_response_catcher.rb +19 -0
  43. metadata +161 -0
@@ -0,0 +1,59 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'date'
7
+ require 'json'
8
+ require 'apimatic_core_interfaces'
9
+ require 'apimatic_core'
10
+ require 'apimatic_faraday_client_adapter'
11
+ # rubocop:disable Style/MixinUsage
12
+ include CoreLibrary
13
+ # rubocop:enable Style/MixinUsage
14
+
15
+ require_relative 'swagger_petstore/api_helper'
16
+ require_relative 'swagger_petstore/client'
17
+
18
+ # Utilities
19
+ require_relative 'swagger_petstore/utilities/file_wrapper'
20
+ require_relative 'swagger_petstore/utilities/date_time_helper'
21
+
22
+ # Http
23
+ require_relative 'swagger_petstore/http/http_call_back'
24
+ require_relative 'swagger_petstore/http/http_method_enum'
25
+ require_relative 'swagger_petstore/http/http_request'
26
+ require_relative 'swagger_petstore/http/http_response'
27
+ require_relative 'swagger_petstore/http/auth/o_auth2'
28
+
29
+ # Models
30
+ require_relative 'swagger_petstore/models/base_model'
31
+ require_relative 'swagger_petstore/models/response200'
32
+ require_relative 'swagger_petstore/models/add_pet_request'
33
+ require_relative 'swagger_petstore/models/category'
34
+ require_relative 'swagger_petstore/models/tag'
35
+ require_relative 'swagger_petstore/models/update_pet_request'
36
+ require_relative 'swagger_petstore/models/response2001'
37
+ require_relative 'swagger_petstore/models/place_order_request'
38
+ require_relative 'swagger_petstore/models/response2007'
39
+ require_relative 'swagger_petstore/models/response20011'
40
+ require_relative 'swagger_petstore/models/create_users_with_array_input_request'
41
+ require_relative 'swagger_petstore/models/create_users_with_list_input_request'
42
+ require_relative 'swagger_petstore/models/response20012'
43
+ require_relative 'swagger_petstore/models/update_user_request'
44
+ require_relative 'swagger_petstore/models/create_user_request'
45
+ require_relative 'swagger_petstore/models/o_auth_token'
46
+ require_relative 'swagger_petstore/models/o_auth_scope_enum'
47
+ require_relative 'swagger_petstore/models/o_auth_provider_error_enum'
48
+
49
+ # Exceptions
50
+ require_relative 'swagger_petstore/exceptions/api_exception'
51
+ require_relative 'swagger_petstore/exceptions/o_auth_provider_exception'
52
+
53
+ require_relative 'swagger_petstore/configuration'
54
+
55
+ # Controllers
56
+ require_relative 'swagger_petstore/controllers/base_controller'
57
+ require_relative 'swagger_petstore/controllers/pet_controller'
58
+ require_relative 'swagger_petstore/controllers/store_controller'
59
+ require_relative 'swagger_petstore/controllers/user_controller'
@@ -0,0 +1,33 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'json'
7
+ require 'minitest/autorun'
8
+ require 'minitest/hell'
9
+ require 'minitest/pride'
10
+ require 'minitest/proveit'
11
+ require 'swagger_petstore'
12
+ require_relative '../http_response_catcher'
13
+
14
+ class ControllerTestBase < Minitest::Test
15
+ parallelize_me!
16
+ include SwaggerPetstore
17
+
18
+ # Create configuration and set any test parameters
19
+ def create_configuration
20
+ Configuration.new(http_callback: HttpResponseCatcher.new)
21
+ end
22
+
23
+ # Initializes the base test controller
24
+ def setup_class
25
+ _config = create_configuration
26
+ @client = Client.new(config: _config)
27
+ _auth_managers = @client.auth_managers
28
+
29
+ token = _auth_managers['global'].fetch_token()
30
+ _config = _config.clone_with(o_auth_token: token)
31
+ @client = Client.new(config: _config)
32
+ end
33
+ end
@@ -0,0 +1,194 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class PetControllerTests < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.pet
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Multiple status values can be provided with comma separated strings
17
+ def test_find_pets_by_status()
18
+ # Parameters for the API call
19
+ status = APIHelper.json_deserialize(
20
+ '["pending"]', false)
21
+ accept = 'application/json,application/xml'
22
+
23
+ # Perform the API call through the SDK function
24
+ result = @controller.find_pets_by_status(status, accept)
25
+
26
+ # Test response code
27
+ assert_equal(200, @response_catcher.response.status_code)
28
+
29
+ # Test headers
30
+ expected_headers = {}
31
+ expected_headers['content-type'] = nil
32
+
33
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
34
+
35
+ # Test whether the captured response is as we expected
36
+ refute_nil(result)
37
+ expected_body = JSON.parse(
38
+ '[{"name":"name53","photoUrls":["photoUrls43"],"id":206,"category":{"id"'\
39
+ ':35,"name":"name36"},"tags":[{"photoUrls":["photoUrls18"],"id":134,"nam'\
40
+ 'e":"name97"}],"status":"available"}]'
41
+ )
42
+ received_body = JSON.parse(@response_catcher.response.raw_body)
43
+ assert(ComparisonHelper.match_body(expected_body, received_body))
44
+ end
45
+
46
+ # Multiple status values can be provided with comma separated strings
47
+ def test_find_pets_by_status1()
48
+ # Parameters for the API call
49
+ status = APIHelper.json_deserialize(
50
+ '["pending"]', false)
51
+ accept = 'application/json,application/xml'
52
+
53
+ # Perform the API call through the SDK function
54
+ result = @controller.find_pets_by_status(status, accept)
55
+
56
+ # Test response code
57
+ assert_equal(200, @response_catcher.response.status_code)
58
+
59
+ # Test headers
60
+ expected_headers = {}
61
+ expected_headers['content-type'] = nil
62
+
63
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
64
+
65
+ # Test whether the captured response is as we expected
66
+ refute_nil(result)
67
+ expected_body = JSON.parse(
68
+ '[{"name":"name53","photoUrls":["photoUrls43"],"id":206,"category":{"id"'\
69
+ ':35,"name":"name36"},"tags":[{"photoUrls":["photoUrls18"],"id":134,"nam'\
70
+ 'e":"name97"}],"status":"available"}]'
71
+ )
72
+ received_body = JSON.parse(@response_catcher.response.raw_body)
73
+ assert(ComparisonHelper.match_body(expected_body, received_body))
74
+ end
75
+
76
+ # Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
77
+ def test_find_pets_by_tags()
78
+ # Parameters for the API call
79
+ tags = APIHelper.json_deserialize(
80
+ '["tags53"]', false)
81
+ accept = 'application/json,application/xml'
82
+
83
+ # Perform the API call through the SDK function
84
+ result = @controller.find_pets_by_tags(tags, accept)
85
+
86
+ # Test response code
87
+ assert_equal(200, @response_catcher.response.status_code)
88
+
89
+ # Test headers
90
+ expected_headers = {}
91
+ expected_headers['content-type'] = nil
92
+
93
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
94
+
95
+ # Test whether the captured response is as we expected
96
+ refute_nil(result)
97
+ expected_body = JSON.parse(
98
+ '[{"name":"name53","photoUrls":["photoUrls43"],"id":206,"category":{"id"'\
99
+ ':35,"name":"name36"},"tags":[{"photoUrls":["photoUrls18"],"id":134,"nam'\
100
+ 'e":"name97"}],"status":"available"}]'
101
+ )
102
+ received_body = JSON.parse(@response_catcher.response.raw_body)
103
+ assert(ComparisonHelper.match_body(expected_body, received_body))
104
+ end
105
+
106
+ # Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
107
+ def test_find_pets_by_tags1()
108
+ # Parameters for the API call
109
+ tags = APIHelper.json_deserialize(
110
+ '["tags53"]', false)
111
+ accept = 'application/json,application/xml'
112
+
113
+ # Perform the API call through the SDK function
114
+ result = @controller.find_pets_by_tags(tags, accept)
115
+
116
+ # Test response code
117
+ assert_equal(200, @response_catcher.response.status_code)
118
+
119
+ # Test headers
120
+ expected_headers = {}
121
+ expected_headers['content-type'] = nil
122
+
123
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
124
+
125
+ # Test whether the captured response is as we expected
126
+ refute_nil(result)
127
+ expected_body = JSON.parse(
128
+ '[{"name":"name53","photoUrls":["photoUrls43"],"id":206,"category":{"id"'\
129
+ ':35,"name":"name36"},"tags":[{"photoUrls":["photoUrls18"],"id":134,"nam'\
130
+ 'e":"name97"}],"status":"available"}]'
131
+ )
132
+ received_body = JSON.parse(@response_catcher.response.raw_body)
133
+ assert(ComparisonHelper.match_body(expected_body, received_body))
134
+ end
135
+
136
+ # Returns a single pet
137
+ def test_get_pet_by_id()
138
+ # Parameters for the API call
139
+ pet_id = 136
140
+ accept = 'application/json,application/xml'
141
+
142
+ # Perform the API call through the SDK function
143
+ result = @controller.get_pet_by_id(pet_id, accept)
144
+
145
+ # Test response code
146
+ assert_equal(200, @response_catcher.response.status_code)
147
+
148
+ # Test headers
149
+ expected_headers = {}
150
+ expected_headers['content-type'] = nil
151
+
152
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
153
+
154
+ # Test whether the captured response is as we expected
155
+ refute_nil(result)
156
+ expected_body = JSON.parse(
157
+ '{"name":"name53","photoUrls":["photoUrls43"],"id":206,"category":{"id":'\
158
+ '35,"name":"name36"},"tags":[{"photoUrls":["photoUrls18"],"id":134,"name'\
159
+ '":"name97"}],"status":"available"}'
160
+ )
161
+ received_body = JSON.parse(@response_catcher.response.raw_body)
162
+ assert(ComparisonHelper.match_body(expected_body, received_body))
163
+ end
164
+
165
+ # Returns a single pet
166
+ def test_get_pet_by_id1()
167
+ # Parameters for the API call
168
+ pet_id = 136
169
+ accept = 'application/json,application/xml'
170
+
171
+ # Perform the API call through the SDK function
172
+ result = @controller.get_pet_by_id(pet_id, accept)
173
+
174
+ # Test response code
175
+ assert_equal(200, @response_catcher.response.status_code)
176
+
177
+ # Test headers
178
+ expected_headers = {}
179
+ expected_headers['content-type'] = nil
180
+
181
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
182
+
183
+ # Test whether the captured response is as we expected
184
+ refute_nil(result)
185
+ expected_body = JSON.parse(
186
+ '{"name":"name53","photoUrls":["photoUrls43"],"id":206,"category":{"id":'\
187
+ '35,"name":"name36"},"tags":[{"photoUrls":["photoUrls18"],"id":134,"name'\
188
+ '":"name97"}],"status":"available"}'
189
+ )
190
+ received_body = JSON.parse(@response_catcher.response.raw_body)
191
+ assert(ComparisonHelper.match_body(expected_body, received_body))
192
+ end
193
+
194
+ end
@@ -0,0 +1,158 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class StoreControllerTests < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.store
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Place an order for a pet
17
+ def test_place_order()
18
+ # Parameters for the API call
19
+ accept = 'application/json,application/xml'
20
+ body = PlaceOrderRequest.from_hash(APIHelper.json_deserialize(
21
+ '{"id":136,"petId":112,"quantity":206,"shipDate":"2023-02-05T11:55:43.44'\
22
+ '10057Z","status":"approved","complete":false}', false))
23
+
24
+ # Perform the API call through the SDK function
25
+ result = @controller.place_order(accept, body)
26
+
27
+ # Test response code
28
+ assert_equal(200, @response_catcher.response.status_code)
29
+
30
+ # Test headers
31
+ expected_headers = {}
32
+ expected_headers['content-type'] = nil
33
+
34
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
35
+
36
+ # Test whether the captured response is as we expected
37
+ refute_nil(result)
38
+ expected_body = JSON.parse(
39
+ '{"id":58,"petId":218,"quantity":201,"shipDate":"2023-02-08T11:55:43.441'\
40
+ '0057Z","status":"approved","complete":false}'
41
+ )
42
+ received_body = JSON.parse(@response_catcher.response.raw_body)
43
+ assert(ComparisonHelper.match_body(expected_body, received_body))
44
+ end
45
+
46
+ # Place an order for a pet
47
+ def test_place_order1()
48
+ # Parameters for the API call
49
+ accept = 'application/json,application/xml'
50
+ body = PlaceOrderRequest.from_hash(APIHelper.json_deserialize(
51
+ '{"id":136,"petId":112,"quantity":206,"shipDate":"2023-02-05T11:55:43.44'\
52
+ '10057Z","status":"approved","complete":false}', false))
53
+
54
+ # Perform the API call through the SDK function
55
+ result = @controller.place_order(accept, body)
56
+
57
+ # Test response code
58
+ assert_equal(200, @response_catcher.response.status_code)
59
+
60
+ # Test headers
61
+ expected_headers = {}
62
+ expected_headers['content-type'] = nil
63
+
64
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
65
+
66
+ # Test whether the captured response is as we expected
67
+ refute_nil(result)
68
+ expected_body = JSON.parse(
69
+ '{"id":58,"petId":218,"quantity":201,"shipDate":"2023-02-08T11:55:43.441'\
70
+ '0057Z","status":"approved","complete":false}'
71
+ )
72
+ received_body = JSON.parse(@response_catcher.response.raw_body)
73
+ assert(ComparisonHelper.match_body(expected_body, received_body))
74
+ end
75
+
76
+ # For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions
77
+ def test_get_order_by_id()
78
+ # Parameters for the API call
79
+ order_id = 2
80
+ accept = 'application/json,application/xml'
81
+
82
+ # Perform the API call through the SDK function
83
+ result = @controller.get_order_by_id(order_id, accept)
84
+
85
+ # Test response code
86
+ assert_equal(200, @response_catcher.response.status_code)
87
+
88
+ # Test headers
89
+ expected_headers = {}
90
+ expected_headers['content-type'] = nil
91
+
92
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
93
+
94
+ # Test whether the captured response is as we expected
95
+ refute_nil(result)
96
+ expected_body = JSON.parse(
97
+ '{"id":58,"petId":218,"quantity":201,"shipDate":"2023-02-08T11:55:43.441'\
98
+ '0057Z","status":"approved","complete":false}'
99
+ )
100
+ received_body = JSON.parse(@response_catcher.response.raw_body)
101
+ assert(ComparisonHelper.match_body(expected_body, received_body))
102
+ end
103
+
104
+ # For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions
105
+ def test_get_order_by_id1()
106
+ # Parameters for the API call
107
+ order_id = 2
108
+ accept = 'application/json,application/xml'
109
+
110
+ # Perform the API call through the SDK function
111
+ result = @controller.get_order_by_id(order_id, accept)
112
+
113
+ # Test response code
114
+ assert_equal(200, @response_catcher.response.status_code)
115
+
116
+ # Test headers
117
+ expected_headers = {}
118
+ expected_headers['content-type'] = nil
119
+
120
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
121
+
122
+ # Test whether the captured response is as we expected
123
+ refute_nil(result)
124
+ expected_body = JSON.parse(
125
+ '{"id":58,"petId":218,"quantity":201,"shipDate":"2023-02-08T11:55:43.441'\
126
+ '0057Z","status":"approved","complete":false}'
127
+ )
128
+ received_body = JSON.parse(@response_catcher.response.raw_body)
129
+ assert(ComparisonHelper.match_body(expected_body, received_body))
130
+ end
131
+
132
+ # Returns a map of status codes to quantities
133
+ def test_get_inventory()
134
+ # Parameters for the API call
135
+ accept = 'application/json'
136
+
137
+ # Perform the API call through the SDK function
138
+ result = @controller.get_inventory(accept)
139
+
140
+ # Test response code
141
+ assert_equal(200, @response_catcher.response.status_code)
142
+
143
+ # Test headers
144
+ expected_headers = {}
145
+ expected_headers['content-type'] = nil
146
+
147
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
148
+
149
+ # Test whether the captured response is as we expected
150
+ refute_nil(result)
151
+ expected_body = JSON.parse(
152
+ '{"key1":58}'
153
+ )
154
+ received_body = JSON.parse(@response_catcher.response.raw_body)
155
+ assert(ComparisonHelper.match_body(expected_body, received_body))
156
+ end
157
+
158
+ end
@@ -0,0 +1,184 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class UserControllerTests < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.user
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Creates list of users with given input array
17
+ def test_create_users_with_array_input()
18
+ # Parameters for the API call
19
+ accept = '*/*'
20
+ body = APIHelper.json_deserialize(
21
+ '[{"id":58,"username":"username84","firstName":"firstName78","lastName":'\
22
+ '"lastName16","email":"email26","password":"password67","phone":"phone84'\
23
+ '","userStatus":247}]', false).map { |element| CreateUsersWithArrayInputRequest.from_hash(element) }
24
+
25
+ # Perform the API call through the SDK function
26
+ result = @controller.create_users_with_array_input(accept, body)
27
+
28
+ # Test response code
29
+ assert_equal(200, @response_catcher.response.status_code)
30
+ end
31
+
32
+ # Creates list of users with given input array
33
+ def test_create_users_with_list_input()
34
+ # Parameters for the API call
35
+ accept = '*/*'
36
+ body = APIHelper.json_deserialize(
37
+ '[{"id":58,"username":"username84","firstName":"firstName78","lastName":'\
38
+ '"lastName16","email":"email26","password":"password67","phone":"phone84'\
39
+ '","userStatus":247}]', false).map { |element| CreateUsersWithListInputRequest.from_hash(element) }
40
+
41
+ # Perform the API call through the SDK function
42
+ result = @controller.create_users_with_list_input(accept, body)
43
+
44
+ # Test response code
45
+ assert_equal(200, @response_catcher.response.status_code)
46
+ end
47
+
48
+ # Get user by user name
49
+ def test_get_user_by_name()
50
+ # Parameters for the API call
51
+ username = 'username22'
52
+ accept = 'application/json,application/xml'
53
+
54
+ # Perform the API call through the SDK function
55
+ result = @controller.get_user_by_name(username, accept)
56
+
57
+ # Test response code
58
+ assert_equal(200, @response_catcher.response.status_code)
59
+
60
+ # Test headers
61
+ expected_headers = {}
62
+ expected_headers['content-type'] = nil
63
+
64
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
65
+
66
+ # Test whether the captured response is as we expected
67
+ refute_nil(result)
68
+ expected_body = JSON.parse(
69
+ '{"id":58,"username":"username84","firstName":"firstName78","lastName":"'\
70
+ 'lastName16","email":"email26","password":"password67","phone":"phone84"'\
71
+ ',"userStatus":247}'
72
+ )
73
+ received_body = JSON.parse(@response_catcher.response.raw_body)
74
+ assert(ComparisonHelper.match_body(expected_body, received_body))
75
+ end
76
+
77
+ # Get user by user name
78
+ def test_get_user_by_name1()
79
+ # Parameters for the API call
80
+ username = 'username22'
81
+ accept = 'application/json,application/xml'
82
+
83
+ # Perform the API call through the SDK function
84
+ result = @controller.get_user_by_name(username, accept)
85
+
86
+ # Test response code
87
+ assert_equal(200, @response_catcher.response.status_code)
88
+
89
+ # Test headers
90
+ expected_headers = {}
91
+ expected_headers['content-type'] = nil
92
+
93
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
94
+
95
+ # Test whether the captured response is as we expected
96
+ refute_nil(result)
97
+ expected_body = JSON.parse(
98
+ '{"id":58,"username":"username84","firstName":"firstName78","lastName":"'\
99
+ 'lastName16","email":"email26","password":"password67","phone":"phone84"'\
100
+ ',"userStatus":247}'
101
+ )
102
+ received_body = JSON.parse(@response_catcher.response.raw_body)
103
+ assert(ComparisonHelper.match_body(expected_body, received_body))
104
+ end
105
+
106
+ # Logs user into the system
107
+ def test_login_user()
108
+ # Parameters for the API call
109
+ username = 'username22'
110
+ password = 'password22'
111
+ accept = 'application/json,application/xml'
112
+
113
+ # Perform the API call through the SDK function
114
+ result = @controller.login_user(username, password, accept)
115
+
116
+ # Test response code
117
+ assert_equal(200, @response_catcher.response.status_code)
118
+
119
+ # Test headers
120
+ expected_headers = {}
121
+ expected_headers['content-type'] = nil
122
+ expected_headers['x-expires-after'] = nil
123
+ expected_headers['x-rate-limit'] = nil
124
+
125
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
126
+
127
+ # Test whether the captured response is as we expected
128
+ refute_nil(result)
129
+ assert_equal('response20022', @response_catcher.response.raw_body)
130
+ end
131
+
132
+ # Logs user into the system
133
+ def test_login_user1()
134
+ # Parameters for the API call
135
+ username = 'username22'
136
+ password = 'password22'
137
+ accept = 'application/json,application/xml'
138
+
139
+ # Perform the API call through the SDK function
140
+ result = @controller.login_user(username, password, accept)
141
+
142
+ # Test response code
143
+ assert_equal(200, @response_catcher.response.status_code)
144
+
145
+ # Test headers
146
+ expected_headers = {}
147
+ expected_headers['content-type'] = nil
148
+
149
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
150
+
151
+ # Test whether the captured response is as we expected
152
+ refute_nil(result)
153
+ assert_equal('response20022', @response_catcher.response.raw_body)
154
+ end
155
+
156
+ # Logs out current logged in user session
157
+ def test_logout_user()
158
+ # Parameters for the API call
159
+ accept = '*/*'
160
+
161
+ # Perform the API call through the SDK function
162
+ result = @controller.logout_user(accept)
163
+
164
+ # Test response code
165
+ assert_equal(200, @response_catcher.response.status_code)
166
+ end
167
+
168
+ # This can only be done by the logged in user.
169
+ def test_create_user()
170
+ # Parameters for the API call
171
+ accept = '*/*'
172
+ body = CreateUserRequest.from_hash(APIHelper.json_deserialize(
173
+ '{"id":58,"username":"username84","firstName":"firstName78","lastName":"'\
174
+ 'lastName16","email":"email26","password":"password67","phone":"phone84"'\
175
+ ',"userStatus":247}', false))
176
+
177
+ # Perform the API call through the SDK function
178
+ result = @controller.create_user(accept, body)
179
+
180
+ # Test response code
181
+ assert_equal(200, @response_catcher.response.status_code)
182
+ end
183
+
184
+ end
@@ -0,0 +1,19 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ class HttpResponseCatcher < SwaggerPetstore::HttpCallBack
7
+ attr_accessor :response
8
+
9
+ def on_before_request(request)
10
+ end
11
+
12
+ # Catching the response
13
+ def on_after_response(response)
14
+ @response = response
15
+ end
16
+ end
17
+
18
+
19
+