vericred_client 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -0
  3. data/README.md +9 -10
  4. data/docs/DrugsApi.md +7 -9
  5. data/docs/NetworksApi.md +4 -6
  6. data/docs/PlansApi.md +4 -72
  7. data/docs/ProvidersApi.md +7 -20
  8. data/docs/RequestProvidersSearch.md +1 -3
  9. data/docs/ZipCountiesApi.md +3 -3
  10. data/git_push.sh +67 -0
  11. data/lib/vericred_client/api/drugs_api.rb +17 -11
  12. data/lib/vericred_client/api/networks_api.rb +18 -12
  13. data/lib/vericred_client/api/plans_api.rb +15 -141
  14. data/lib/vericred_client/api/providers_api.rb +16 -32
  15. data/lib/vericred_client/api/zip_counties_api.rb +14 -4
  16. data/lib/vericred_client/api_client.rb +13 -3
  17. data/lib/vericred_client/api_error.rb +13 -3
  18. data/lib/vericred_client/configuration.rb +130 -0
  19. data/lib/vericred_client/models/applicant.rb +20 -6
  20. data/lib/vericred_client/models/base.rb +20 -6
  21. data/lib/vericred_client/models/carrier.rb +20 -6
  22. data/lib/vericred_client/models/carrier_subsidiary.rb +20 -6
  23. data/lib/vericred_client/models/county.rb +20 -6
  24. data/lib/vericred_client/models/county_bulk.rb +20 -6
  25. data/lib/vericred_client/models/drug.rb +20 -6
  26. data/lib/vericred_client/models/drug_coverage.rb +20 -6
  27. data/lib/vericred_client/models/drug_coverage_response.rb +20 -6
  28. data/lib/vericred_client/models/drug_package.rb +20 -6
  29. data/lib/vericred_client/models/drug_search_response.rb +20 -6
  30. data/lib/vericred_client/models/meta.rb +20 -6
  31. data/lib/vericred_client/models/network.rb +20 -6
  32. data/lib/vericred_client/models/network_search_response.rb +20 -6
  33. data/lib/vericred_client/models/plan.rb +20 -6
  34. data/lib/vericred_client/models/plan_county.rb +20 -6
  35. data/lib/vericred_client/models/plan_county_bulk.rb +20 -6
  36. data/lib/vericred_client/models/plan_search_response.rb +20 -6
  37. data/lib/vericred_client/models/plan_search_result.rb +20 -6
  38. data/lib/vericred_client/models/plan_zip_county.rb +20 -6
  39. data/lib/vericred_client/models/pricing.rb +20 -6
  40. data/lib/vericred_client/models/provider.rb +20 -6
  41. data/lib/vericred_client/models/provider_show_response.rb +20 -6
  42. data/lib/vericred_client/models/providers_search_response.rb +20 -6
  43. data/lib/vericred_client/models/rating_area.rb +20 -6
  44. data/lib/vericred_client/models/request_plan_find.rb +20 -6
  45. data/lib/vericred_client/models/request_plan_find_applicant.rb +20 -6
  46. data/lib/vericred_client/models/request_plan_find_provider.rb +20 -6
  47. data/lib/vericred_client/models/request_providers_search.rb +21 -9
  48. data/lib/vericred_client/models/state.rb +20 -6
  49. data/lib/vericred_client/models/zip_code.rb +20 -6
  50. data/lib/vericred_client/models/zip_counties_response.rb +20 -6
  51. data/lib/vericred_client/models/zip_county.rb +20 -6
  52. data/lib/vericred_client/models/zip_county_bulk.rb +20 -6
  53. data/lib/vericred_client/models/zip_county_response.rb +20 -6
  54. data/lib/vericred_client/version.rb +14 -4
  55. data/lib/vericred_client.rb +13 -3
  56. data/spec/api/drugs_api_spec.rb +17 -17
  57. data/spec/api/networks_api_spec.rb +16 -12
  58. data/spec/api/plans_api_spec.rb +16 -78
  59. data/spec/api/providers_api_spec.rb +17 -28
  60. data/spec/api/zip_counties_api_spec.rb +15 -9
  61. data/spec/api_client_spec.rb +403 -0
  62. data/spec/configuration_spec.rb +155 -0
  63. data/spec/models/applicant_spec.rb +196 -0
  64. data/spec/models/base_spec.rb +160 -0
  65. data/spec/models/carrier_spec.rb +172 -0
  66. data/spec/models/carrier_subsidiary_spec.rb +172 -0
  67. data/spec/models/county_bulk_spec.rb +172 -0
  68. data/spec/models/county_spec.rb +196 -0
  69. data/spec/models/drug_coverage_response_spec.rb +178 -0
  70. data/spec/models/drug_coverage_spec.rb +190 -0
  71. data/spec/models/drug_package_spec.rb +166 -0
  72. data/spec/models/drug_search_response_spec.rb +172 -0
  73. data/spec/models/drug_spec.rb +178 -0
  74. data/spec/models/meta_spec.rb +160 -0
  75. data/spec/models/network_search_response_spec.rb +166 -0
  76. data/spec/models/network_spec.rb +166 -0
  77. data/spec/models/plan_county_bulk_spec.rb +166 -0
  78. data/spec/models/plan_county_spec.rb +166 -0
  79. data/spec/models/plan_search_response_spec.rb +172 -0
  80. data/spec/models/plan_search_result_spec.rb +562 -0
  81. data/spec/models/plan_spec.rb +544 -0
  82. data/spec/models/plan_zip_county_spec.rb +172 -0
  83. data/spec/models/pricing_spec.rb +220 -0
  84. data/spec/models/provider_show_response_spec.rb +160 -0
  85. data/spec/models/provider_spec.rb +322 -0
  86. data/spec/models/providers_search_response_spec.rb +172 -0
  87. data/spec/models/rating_area_spec.rb +166 -0
  88. data/spec/models/request_plan_find_applicant_spec.rb +160 -0
  89. data/spec/models/request_plan_find_provider_spec.rb +160 -0
  90. data/spec/models/request_plan_find_spec.rb +226 -0
  91. data/spec/models/request_providers_search_spec.rb +202 -0
  92. data/spec/models/state_spec.rb +202 -0
  93. data/spec/models/zip_code_spec.rb +166 -0
  94. data/spec/models/zip_counties_response_spec.rb +178 -0
  95. data/spec/models/zip_county_bulk_spec.rb +178 -0
  96. data/spec/models/zip_county_response_spec.rb +178 -0
  97. data/spec/models/zip_county_spec.rb +172 -0
  98. data/spec/spec_helper.rb +229 -0
  99. data/vericred_client.gemspec +131 -0
  100. metadata +80 -2
@@ -1,7 +1,7 @@
1
1
  =begin
2
- Vericred API
2
+ #Vericred API
3
3
 
4
- Vericred's API allows you to search for Health Plans that a specific doctor
4
+ #Vericred's API allows you to search for Health Plans that a specific doctor
5
5
  accepts.
6
6
 
7
7
  ## Getting Started
@@ -37,7 +37,6 @@ namely `Total`, `Per-Page`, `Link`, and `Page` as described in [RFC-5988](https:
37
37
 
38
38
  For example, to display 5 results per page and view the second page of a
39
39
  `GET` to `/networks`, your final request would be `GET /networks?....page=2&per_page=5`.
40
- ```
41
40
 
42
41
  ## Sideloading
43
42
 
@@ -115,6 +114,17 @@ OpenAPI spec version: 1.0.0
115
114
 
116
115
  Generated by: https://github.com/swagger-api/swagger-codegen.git
117
116
 
117
+ Licensed under the Apache License, Version 2.0 (the "License");
118
+ you may not use this file except in compliance with the License.
119
+ You may obtain a copy of the License at
120
+
121
+ http://www.apache.org/licenses/LICENSE-2.0
122
+
123
+ Unless required by applicable law or agreed to in writing, software
124
+ distributed under the License is distributed on an "AS IS" BASIS,
125
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126
+ See the License for the specific language governing permissions and
127
+ limitations under the License.
118
128
 
119
129
  =end
120
130
 
@@ -136,7 +146,7 @@ describe 'ProvidersApi' do
136
146
 
137
147
  describe 'test an instance of ProvidersApi' do
138
148
  it 'should create an instact of ProvidersApi' do
139
- @instance.should be_a(VericredClient::ProvidersApi)
149
+ expect(@instance).to be_instance_of(VericredClient::ProvidersApi)
140
150
  end
141
151
  end
142
152
 
@@ -148,40 +158,19 @@ describe 'ProvidersApi' do
148
158
  # @return [ProviderShowResponse]
149
159
  describe 'get_provider test' do
150
160
  it "should work" do
151
- # assertion here
152
- # should be_a()
153
- # should be_nil
154
- # should ==
155
- # should_not ==
161
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
156
162
  end
157
163
  end
158
164
 
159
165
  # unit tests for get_providers
160
166
  # Find Providers
161
- # All `Provider` searches require a `zip_code`, which we use for weighting
162
- the search results to favor `Provider`s that are near the user. For example,
163
- we would want "Dr. John Smith" who is 5 miles away to appear before
164
- "Dr. John Smith" who is 100 miles away.
165
-
166
- The weighting also allows for non-exact matches. In our prior example, we
167
- would want "Dr. Jon Smith" who is 2 miles away to appear before the exact
168
- match "Dr. John Smith" who is 100 miles away because it is more likely that
169
- the user just entered an incorrect name.
170
-
171
- The free text search also supports Specialty name search and "body part"
172
- Specialty name search. So, searching "John Smith nose" would return
173
- "Dr. John Smith", the ENT Specialist before "Dr. John Smith" the Internist.
174
-
167
+ # All `Provider` searches require a `zip_code`, which we use for weighting the search results to favor `Provider`s that are near the user. For example, we would want \"Dr. John Smith\" who is 5 miles away to appear before \"Dr. John Smith\" who is 100 miles away. The weighting also allows for non-exact matches. In our prior example, we would want \"Dr. Jon Smith\" who is 2 miles away to appear before the exact match \"Dr. John Smith\" who is 100 miles away because it is more likely that the user just entered an incorrect name. The free text search also supports Specialty name search and \"body part\" Specialty name search. So, searching \"John Smith nose\" would return \"Dr. John Smith\", the ENT Specialist before \"Dr. John Smith\" the Internist.
175
168
  # @param [Hash] opts the optional parameters
176
169
  # @option opts [RequestProvidersSearch] :body
177
170
  # @return [ProvidersSearchResponse]
178
171
  describe 'get_providers test' do
179
172
  it "should work" do
180
- # assertion here
181
- # should be_a()
182
- # should be_nil
183
- # should ==
184
- # should_not ==
173
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
185
174
  end
186
175
  end
187
176
 
@@ -1,7 +1,7 @@
1
1
  =begin
2
- Vericred API
2
+ #Vericred API
3
3
 
4
- Vericred's API allows you to search for Health Plans that a specific doctor
4
+ #Vericred's API allows you to search for Health Plans that a specific doctor
5
5
  accepts.
6
6
 
7
7
  ## Getting Started
@@ -37,7 +37,6 @@ namely `Total`, `Per-Page`, `Link`, and `Page` as described in [RFC-5988](https:
37
37
 
38
38
  For example, to display 5 results per page and view the second page of a
39
39
  `GET` to `/networks`, your final request would be `GET /networks?....page=2&per_page=5`.
40
- ```
41
40
 
42
41
  ## Sideloading
43
42
 
@@ -115,6 +114,17 @@ OpenAPI spec version: 1.0.0
115
114
 
116
115
  Generated by: https://github.com/swagger-api/swagger-codegen.git
117
116
 
117
+ Licensed under the Apache License, Version 2.0 (the "License");
118
+ you may not use this file except in compliance with the License.
119
+ You may obtain a copy of the License at
120
+
121
+ http://www.apache.org/licenses/LICENSE-2.0
122
+
123
+ Unless required by applicable law or agreed to in writing, software
124
+ distributed under the License is distributed on an "AS IS" BASIS,
125
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126
+ See the License for the specific language governing permissions and
127
+ limitations under the License.
118
128
 
119
129
  =end
120
130
 
@@ -136,7 +146,7 @@ describe 'ZipCountiesApi' do
136
146
 
137
147
  describe 'test an instance of ZipCountiesApi' do
138
148
  it 'should create an instact of ZipCountiesApi' do
139
- @instance.should be_a(VericredClient::ZipCountiesApi)
149
+ expect(@instance).to be_instance_of(VericredClient::ZipCountiesApi)
140
150
  end
141
151
  end
142
152
 
@@ -148,11 +158,7 @@ describe 'ZipCountiesApi' do
148
158
  # @return [ZipCountyResponse]
149
159
  describe 'get_zip_counties test' do
150
160
  it "should work" do
151
- # assertion here
152
- # should be_a()
153
- # should be_nil
154
- # should ==
155
- # should_not ==
161
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
156
162
  end
157
163
  end
158
164
 
@@ -0,0 +1,403 @@
1
+ =begin
2
+ #Vericred API
3
+
4
+ #Vericred's API allows you to search for Health Plans that a specific doctor
5
+ accepts.
6
+
7
+ ## Getting Started
8
+
9
+ Visit our [Developer Portal](https://vericred.3scale.net) to
10
+ create an account.
11
+
12
+ Once you have created an account, you can create one Application for
13
+ Production and another for our Sandbox (select the appropriate Plan when
14
+ you create the Application).
15
+
16
+ ## Authentication
17
+
18
+ To authenticate, pass the API Key you created in the Developer Portal as
19
+ a `Vericred-Api-Key` header.
20
+
21
+ `curl -H 'Vericred-Api-Key: YOUR_KEY' "https://api.vericred.com/providers?search_term=Foo&zip_code=11215"`
22
+
23
+ ## Versioning
24
+
25
+ Vericred's API default to the latest version. However, if you need a specific
26
+ version, you can request it with an `Accept-Version` header.
27
+
28
+ The current version is `v3`. Previous versions are `v1` and `v2`.
29
+
30
+ `curl -H 'Vericred-Api-Key: YOUR_KEY' -H 'Accept-Version: v2' "https://api.vericred.com/providers?search_term=Foo&zip_code=11215"`
31
+
32
+ ## Pagination
33
+
34
+ Endpoints that accept `page` and `per_page` parameters are paginated. They expose
35
+ four additional fields that contain data about your position in the response,
36
+ namely `Total`, `Per-Page`, `Link`, and `Page` as described in [RFC-5988](https://tools.ietf.org/html/rfc5988).
37
+
38
+ For example, to display 5 results per page and view the second page of a
39
+ `GET` to `/networks`, your final request would be `GET /networks?....page=2&per_page=5`.
40
+
41
+ ## Sideloading
42
+
43
+ When we return multiple levels of an object graph (e.g. `Provider`s and their `State`s
44
+ we sideload the associated data. In this example, we would provide an Array of
45
+ `State`s and a `state_id` for each provider. This is done primarily to reduce the
46
+ payload size since many of the `Provider`s will share a `State`
47
+
48
+ ```
49
+ {
50
+ providers: [{ id: 1, state_id: 1}, { id: 2, state_id: 1 }],
51
+ states: [{ id: 1, code: 'NY' }]
52
+ }
53
+ ```
54
+
55
+ If you need the second level of the object graph, you can just match the
56
+ corresponding id.
57
+
58
+ ## Selecting specific data
59
+
60
+ All endpoints allow you to specify which fields you would like to return.
61
+ This allows you to limit the response to contain only the data you need.
62
+
63
+ For example, let's take a request that returns the following JSON by default
64
+
65
+ ```
66
+ {
67
+ provider: {
68
+ id: 1,
69
+ name: 'John',
70
+ phone: '1234567890',
71
+ field_we_dont_care_about: 'value_we_dont_care_about'
72
+ },
73
+ states: [{
74
+ id: 1,
75
+ name: 'New York',
76
+ code: 'NY',
77
+ field_we_dont_care_about: 'value_we_dont_care_about'
78
+ }]
79
+ }
80
+ ```
81
+
82
+ To limit our results to only return the fields we care about, we specify the
83
+ `select` query string parameter for the corresponding fields in the JSON
84
+ document.
85
+
86
+ In this case, we want to select `name` and `phone` from the `provider` key,
87
+ so we would add the parameters `select=provider.name,provider.phone`.
88
+ We also want the `name` and `code` from the `states` key, so we would
89
+ add the parameters `select=states.name,staes.code`. The id field of
90
+ each document is always returned whether or not it is requested.
91
+
92
+ Our final request would be `GET /providers/12345?select=provider.name,provider.phone,states.name,states.code`
93
+
94
+ The response would be
95
+
96
+ ```
97
+ {
98
+ provider: {
99
+ id: 1,
100
+ name: 'John',
101
+ phone: '1234567890'
102
+ },
103
+ states: [{
104
+ id: 1,
105
+ name: 'New York',
106
+ code: 'NY'
107
+ }]
108
+ }
109
+ ```
110
+
111
+
112
+
113
+ OpenAPI spec version: 1.0.0
114
+
115
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
116
+
117
+ Licensed under the Apache License, Version 2.0 (the "License");
118
+ you may not use this file except in compliance with the License.
119
+ You may obtain a copy of the License at
120
+
121
+ http://www.apache.org/licenses/LICENSE-2.0
122
+
123
+ Unless required by applicable law or agreed to in writing, software
124
+ distributed under the License is distributed on an "AS IS" BASIS,
125
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126
+ See the License for the specific language governing permissions and
127
+ limitations under the License.
128
+
129
+ =end
130
+
131
+ require 'spec_helper'
132
+
133
+ describe VericredClient::ApiClient do
134
+ context 'initialization' do
135
+ context 'URL stuff' do
136
+ context 'host' do
137
+ it 'removes http from host' do
138
+ VericredClient.configure { |c| c.host = 'http://example.com' }
139
+ expect(VericredClient::Configuration.default.host).to eq('example.com')
140
+ end
141
+
142
+ it 'removes https from host' do
143
+ VericredClient.configure { |c| c.host = 'https://wookiee.com' }
144
+ expect(VericredClient::ApiClient.default.config.host).to eq('wookiee.com')
145
+ end
146
+
147
+ it 'removes trailing path from host' do
148
+ VericredClient.configure { |c| c.host = 'hobo.com/v4' }
149
+ expect(VericredClient::Configuration.default.host).to eq('hobo.com')
150
+ end
151
+ end
152
+
153
+ context 'base_path' do
154
+ it "prepends a slash to base_path" do
155
+ VericredClient.configure { |c| c.base_path = 'v4/dog' }
156
+ expect(VericredClient::Configuration.default.base_path).to eq('/v4/dog')
157
+ end
158
+
159
+ it "doesn't prepend a slash if one is already there" do
160
+ VericredClient.configure { |c| c.base_path = '/v4/dog' }
161
+ expect(VericredClient::Configuration.default.base_path).to eq('/v4/dog')
162
+ end
163
+
164
+ it "ends up as a blank string if nil" do
165
+ VericredClient.configure { |c| c.base_path = nil }
166
+ expect(VericredClient::Configuration.default.base_path).to eq('')
167
+ end
168
+ end
169
+ end
170
+ end
171
+
172
+ describe "#update_params_for_auth!" do
173
+ it "sets header api-key parameter with prefix" do
174
+ VericredClient.configure do |c|
175
+ c.api_key_prefix['api_key'] = 'PREFIX'
176
+ c.api_key['api_key'] = 'special-key'
177
+ end
178
+
179
+ api_client = VericredClient::ApiClient.new
180
+
181
+ config2 = VericredClient::Configuration.new do |c|
182
+ c.api_key_prefix['api_key'] = 'PREFIX2'
183
+ c.api_key['api_key'] = 'special-key2'
184
+ end
185
+ api_client2 = VericredClient::ApiClient.new(config2)
186
+
187
+ auth_names = ['api_key', 'unknown']
188
+
189
+ header_params = {}
190
+ query_params = {}
191
+ api_client.update_params_for_auth! header_params, query_params, auth_names
192
+ expect(header_params).to eq({'api_key' => 'PREFIX special-key'})
193
+ expect(query_params).to eq({})
194
+
195
+ header_params = {}
196
+ query_params = {}
197
+ api_client2.update_params_for_auth! header_params, query_params, auth_names
198
+ expect(header_params).to eq({'api_key' => 'PREFIX2 special-key2'})
199
+ expect(query_params).to eq({})
200
+ end
201
+
202
+ it "sets header api-key parameter without prefix" do
203
+ VericredClient.configure do |c|
204
+ c.api_key_prefix['api_key'] = nil
205
+ c.api_key['api_key'] = 'special-key'
206
+ end
207
+
208
+ api_client = VericredClient::ApiClient.new
209
+
210
+ header_params = {}
211
+ query_params = {}
212
+ auth_names = ['api_key', 'unknown']
213
+ api_client.update_params_for_auth! header_params, query_params, auth_names
214
+ expect(header_params).to eq({'api_key' => 'special-key'})
215
+ expect(query_params).to eq({})
216
+ end
217
+ end
218
+
219
+ describe "timeout in #build_request" do
220
+ let(:config) { VericredClient::Configuration.new }
221
+ let(:api_client) { VericredClient::ApiClient.new(config) }
222
+
223
+ it "defaults to 0" do
224
+ expect(VericredClient::Configuration.default.timeout).to eq(0)
225
+ expect(config.timeout).to eq(0)
226
+
227
+ request = api_client.build_request(:get, '/test')
228
+ expect(request.options[:timeout]).to eq(0)
229
+ end
230
+
231
+ it "can be customized" do
232
+ config.timeout = 100
233
+ request = api_client.build_request(:get, '/test')
234
+ expect(request.options[:timeout]).to eq(100)
235
+ end
236
+ end
237
+
238
+ describe "#deserialize" do
239
+ it "handles Array<Integer>" do
240
+ api_client = VericredClient::ApiClient.new
241
+ headers = {'Content-Type' => 'application/json'}
242
+ response = double('response', headers: headers, body: '[12, 34]')
243
+ data = api_client.deserialize(response, 'Array<Integer>')
244
+ expect(data).to be_instance_of(Array)
245
+ expect(data).to eq([12, 34])
246
+ end
247
+
248
+ it "handles Array<Array<Integer>>" do
249
+ api_client = VericredClient::ApiClient.new
250
+ headers = {'Content-Type' => 'application/json'}
251
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
252
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
253
+ expect(data).to be_instance_of(Array)
254
+ expect(data).to eq([[12, 34], [56]])
255
+ end
256
+
257
+ it "handles Hash<String, String>" do
258
+ api_client = VericredClient::ApiClient.new
259
+ headers = {'Content-Type' => 'application/json'}
260
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
261
+ data = api_client.deserialize(response, 'Hash<String, String>')
262
+ expect(data).to be_instance_of(Hash)
263
+ expect(data).to eq({:message => 'Hello'})
264
+ end
265
+
266
+ it "handles Hash<String, Pet>" do
267
+ api_client = VericredClient::ApiClient.new
268
+ headers = {'Content-Type' => 'application/json'}
269
+ response = double('response', headers: headers, body: '{"pet": {"id": 1}}')
270
+ data = api_client.deserialize(response, 'Hash<String, Pet>')
271
+ expect(data).to be_instance_of(Hash)
272
+ expect(data.keys).to eq([:pet])
273
+
274
+ pet = data[:pet]
275
+ expect(pet).to be_instance_of(VericredClient::Pet)
276
+ expect(pet.id).to eq(1)
277
+ end
278
+
279
+ it "handles Hash<String, Hash<String, Pet>>" do
280
+ api_client = VericredClient::ApiClient.new
281
+ headers = {'Content-Type' => 'application/json'}
282
+ response = double('response', headers: headers, body: '{"data": {"pet": {"id": 1}}}')
283
+ result = api_client.deserialize(response, 'Hash<String, Hash<String, Pet>>')
284
+ expect(result).to be_instance_of(Hash)
285
+ expect(result.keys).to match_array([:data])
286
+
287
+ data = result[:data]
288
+ expect(data).to be_instance_of(Hash)
289
+ expect(data.keys).to match_array([:pet])
290
+
291
+ pet = data[:pet]
292
+ expect(pet).to be_instance_of(VericredClient::Pet)
293
+ expect(pet.id).to eq(1)
294
+ end
295
+ end
296
+
297
+ describe "#object_to_hash" do
298
+ it "ignores nils and includes empty arrays" do
299
+ api_client = VericredClient::ApiClient.new
300
+ pet = VericredClient::Pet.new
301
+ pet.id = 1
302
+ pet.name = ''
303
+ pet.status = nil
304
+ pet.photo_urls = nil
305
+ pet.tags = []
306
+ expected = {id: 1, name: '', tags: []}
307
+ expect(api_client.object_to_hash(pet)).to eq(expected)
308
+ end
309
+ end
310
+
311
+ describe "#build_collection_param" do
312
+ let(:param) { ['aa', 'bb', 'cc'] }
313
+ let(:api_client) { VericredClient::ApiClient.new }
314
+
315
+ it "works for csv" do
316
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
317
+ end
318
+
319
+ it "works for ssv" do
320
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
321
+ end
322
+
323
+ it "works for tsv" do
324
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
325
+ end
326
+
327
+ it "works for pipes" do
328
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
329
+ end
330
+
331
+ it "works for multi" do
332
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
333
+ end
334
+
335
+ it "fails for invalid collection format" do
336
+ expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
337
+ end
338
+ end
339
+
340
+ describe "#json_mime?" do
341
+ let(:api_client) { VericredClient::ApiClient.new }
342
+
343
+ it "works" do
344
+ expect(api_client.json_mime?(nil)).to eq false
345
+ expect(api_client.json_mime?('')).to eq false
346
+
347
+ expect(api_client.json_mime?('application/json')).to eq true
348
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
349
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
350
+
351
+ expect(api_client.json_mime?('application/xml')).to eq false
352
+ expect(api_client.json_mime?('text/plain')).to eq false
353
+ expect(api_client.json_mime?('application/jsonp')).to eq false
354
+ end
355
+ end
356
+
357
+ describe "#select_header_accept" do
358
+ let(:api_client) { VericredClient::ApiClient.new }
359
+
360
+ it "works" do
361
+ expect(api_client.select_header_accept(nil)).to be_nil
362
+ expect(api_client.select_header_accept([])).to be_nil
363
+
364
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
365
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
366
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
367
+
368
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
369
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
370
+ end
371
+ end
372
+
373
+ describe "#select_header_content_type" do
374
+ let(:api_client) { VericredClient::ApiClient.new }
375
+
376
+ it "works" do
377
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
378
+ expect(api_client.select_header_content_type([])).to eq('application/json')
379
+
380
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
381
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
382
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
383
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
384
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
385
+ end
386
+ end
387
+
388
+ describe "#sanitize_filename" do
389
+ let(:api_client) { VericredClient::ApiClient.new }
390
+
391
+ it "works" do
392
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
393
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
394
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
395
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
396
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
397
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
398
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
399
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
400
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
401
+ end
402
+ end
403
+ end