pharmaobservatory 0.1.11 → 0.1.13

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -6
  3. data/docs/CompaniesApi.md +332 -4
  4. data/docs/CompaniesRecordAttributes.md +2 -0
  5. data/docs/CompaniesRow.md +1 -1
  6. data/docs/CompanyAssetsRow.md +5 -1
  7. data/docs/CompanyCompetitorsRow.md +8 -2
  8. data/docs/CompanyCosponsorsResponse.md +58 -0
  9. data/docs/CompanyCosponsorsRow.md +58 -0
  10. data/docs/CompanyPeerProfileResponse.md +58 -0
  11. data/docs/CompanyPeerProfileRow.md +60 -0
  12. data/docs/CompanyPeersResponse.md +58 -0
  13. data/docs/CompanyPeersRow.md +54 -0
  14. data/docs/CompanyProgramsRow.md +4 -0
  15. data/docs/InvestorPortfolioRow.md +41 -11
  16. data/docs/InvestorsApi.md +4 -4
  17. data/docs/InvestorsRow.md +3 -1
  18. data/docs/LegalEntitiesApi.md +80 -0
  19. data/docs/ProgramLicensingCandidatesRow.md +4 -0
  20. data/lib/pharmaobservatory/api/companies_api.rb +366 -2
  21. data/lib/pharmaobservatory/api/investors_api.rb +2 -2
  22. data/lib/pharmaobservatory/api/legal_entities_api.rb +84 -0
  23. data/lib/pharmaobservatory/models/companies_record_attributes.rb +10 -1
  24. data/lib/pharmaobservatory/models/companies_row.rb +1 -1
  25. data/lib/pharmaobservatory/models/company_assets_row.rb +27 -5
  26. data/lib/pharmaobservatory/models/company_competitors_row.rb +40 -7
  27. data/lib/pharmaobservatory/models/company_cosponsors_response.rb +478 -0
  28. data/lib/pharmaobservatory/models/company_cosponsors_row.rb +445 -0
  29. data/lib/pharmaobservatory/models/company_peer_profile_response.rb +478 -0
  30. data/lib/pharmaobservatory/models/company_peer_profile_row.rb +454 -0
  31. data/lib/pharmaobservatory/models/company_peers_response.rb +478 -0
  32. data/lib/pharmaobservatory/models/company_peers_row.rb +421 -0
  33. data/lib/pharmaobservatory/models/company_programs_row.rb +23 -1
  34. data/lib/pharmaobservatory/models/investor_portfolio_row.rb +180 -13
  35. data/lib/pharmaobservatory/models/investors_row.rb +13 -2
  36. data/lib/pharmaobservatory/models/program_licensing_candidates_row.rb +23 -1
  37. data/lib/pharmaobservatory/version.rb +1 -1
  38. data/lib/pharmaobservatory.rb +6 -0
  39. metadata +14 -2
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module PharmaObservatory
17
- # One row of the company_competitors dataset: one row per ordered company pair: a company and one of its top 25 competitors. A grouped request returns the group columns and the measures instead, as additional properties.
17
+ # One row of the company_competitors dataset: one row per ordered company pair: a company and one of the top 25 companies of each competitor_class by program overlap. A grouped request returns the group columns and the measures instead, as additional properties.
18
18
  class CompanyCompetitorsRow
19
19
  # Company level: the company the row is about; the entry key for the companies object type.
20
20
  attr_accessor :company_id
@@ -40,7 +40,13 @@ module PharmaObservatory
40
40
  # Display name of the competitor's group.
41
41
  attr_accessor :competitor_group_name
42
42
 
43
- # The competitor's rank for the company by competitor_score (1 is the highest).
43
+ # The competitor's class: industry, or non_industry (not classed as industry by the sponsor-class rule: academic, hospital, government, nonprofit, and any record the rule does not reach). competitor_rank restarts at 1 within each class, so filter or sort on this column first.
44
+ attr_accessor :competitor_class
45
+
46
+ # How many companies of this competitor_class were candidates (a shared target, or an indication overlap above the similarity floor) before the top 25 were kept. The same value on every row of one company and class.
47
+ attr_accessor :n_class_candidates
48
+
49
+ # The competitor's rank within its competitor_class for the company by competitor_score (1 is the highest).
44
50
  attr_accessor :competitor_rank
45
51
 
46
52
  # 100 times the weighted mean of the four similarities below, rounded to four places.
@@ -91,6 +97,9 @@ module PharmaObservatory
91
97
  # Up to 3 shared mechanisms written as a gene symbol and an action, by combined phase then combined trials. An empty list when none.
92
98
  attr_accessor :top_shared_mechanisms
93
99
 
100
+ # Distinct trials on which the company and the competitor are both named as sponsors, counted over their subtrees; 0 when none. A consortium trial (more than 25 sponsor companies) is left out.
101
+ attr_accessor :n_cosponsored_trials
102
+
94
103
  # Attribute mapping from ruby-style variable name to JSON key.
95
104
  def self.attribute_map
96
105
  {
@@ -102,6 +111,8 @@ module PharmaObservatory
102
111
  :'competitor_company_name' => :'competitor_company_name',
103
112
  :'competitor_group_id' => :'competitor_group_id',
104
113
  :'competitor_group_name' => :'competitor_group_name',
114
+ :'competitor_class' => :'competitor_class',
115
+ :'n_class_candidates' => :'n_class_candidates',
105
116
  :'competitor_rank' => :'competitor_rank',
106
117
  :'competitor_score' => :'competitor_score',
107
118
  :'target_sim' => :'target_sim',
@@ -118,7 +129,8 @@ module PharmaObservatory
118
129
  :'n_competitor_indications' => :'n_competitor_indications',
119
130
  :'top_shared_targets' => :'top_shared_targets',
120
131
  :'top_shared_indications' => :'top_shared_indications',
121
- :'top_shared_mechanisms' => :'top_shared_mechanisms'
132
+ :'top_shared_mechanisms' => :'top_shared_mechanisms',
133
+ :'n_cosponsored_trials' => :'n_cosponsored_trials'
122
134
  }
123
135
  end
124
136
 
@@ -143,6 +155,8 @@ module PharmaObservatory
143
155
  :'competitor_company_name' => :'String',
144
156
  :'competitor_group_id' => :'String',
145
157
  :'competitor_group_name' => :'String',
158
+ :'competitor_class' => :'String',
159
+ :'n_class_candidates' => :'Integer',
146
160
  :'competitor_rank' => :'Integer',
147
161
  :'competitor_score' => :'Float',
148
162
  :'target_sim' => :'Float',
@@ -159,7 +173,8 @@ module PharmaObservatory
159
173
  :'n_competitor_indications' => :'Integer',
160
174
  :'top_shared_targets' => :'Array<String>',
161
175
  :'top_shared_indications' => :'Array<String>',
162
- :'top_shared_mechanisms' => :'Array<String>'
176
+ :'top_shared_mechanisms' => :'Array<String>',
177
+ :'n_cosponsored_trials' => :'Integer'
163
178
  }
164
179
  end
165
180
 
@@ -174,6 +189,8 @@ module PharmaObservatory
174
189
  :'competitor_company_name',
175
190
  :'competitor_group_id',
176
191
  :'competitor_group_name',
192
+ :'competitor_class',
193
+ :'n_class_candidates',
177
194
  :'competitor_rank',
178
195
  :'competitor_score',
179
196
  :'target_sim',
@@ -190,7 +207,8 @@ module PharmaObservatory
190
207
  :'n_competitor_indications',
191
208
  :'top_shared_targets',
192
209
  :'top_shared_indications',
193
- :'top_shared_mechanisms'
210
+ :'top_shared_mechanisms',
211
+ :'n_cosponsored_trials'
194
212
  ])
195
213
  end
196
214
 
@@ -242,6 +260,14 @@ module PharmaObservatory
242
260
  self.competitor_group_name = attributes[:'competitor_group_name']
243
261
  end
244
262
 
263
+ if attributes.key?(:'competitor_class')
264
+ self.competitor_class = attributes[:'competitor_class']
265
+ end
266
+
267
+ if attributes.key?(:'n_class_candidates')
268
+ self.n_class_candidates = attributes[:'n_class_candidates']
269
+ end
270
+
245
271
  if attributes.key?(:'competitor_rank')
246
272
  self.competitor_rank = attributes[:'competitor_rank']
247
273
  end
@@ -315,6 +341,10 @@ module PharmaObservatory
315
341
  self.top_shared_mechanisms = value
316
342
  end
317
343
  end
344
+
345
+ if attributes.key?(:'n_cosponsored_trials')
346
+ self.n_cosponsored_trials = attributes[:'n_cosponsored_trials']
347
+ end
318
348
  end
319
349
 
320
350
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -345,6 +375,8 @@ module PharmaObservatory
345
375
  competitor_company_name == o.competitor_company_name &&
346
376
  competitor_group_id == o.competitor_group_id &&
347
377
  competitor_group_name == o.competitor_group_name &&
378
+ competitor_class == o.competitor_class &&
379
+ n_class_candidates == o.n_class_candidates &&
348
380
  competitor_rank == o.competitor_rank &&
349
381
  competitor_score == o.competitor_score &&
350
382
  target_sim == o.target_sim &&
@@ -361,7 +393,8 @@ module PharmaObservatory
361
393
  n_competitor_indications == o.n_competitor_indications &&
362
394
  top_shared_targets == o.top_shared_targets &&
363
395
  top_shared_indications == o.top_shared_indications &&
364
- top_shared_mechanisms == o.top_shared_mechanisms
396
+ top_shared_mechanisms == o.top_shared_mechanisms &&
397
+ n_cosponsored_trials == o.n_cosponsored_trials
365
398
  end
366
399
 
367
400
  # @see the `==` method
@@ -373,7 +406,7 @@ module PharmaObservatory
373
406
  # Calculates hash code according to all attributes.
374
407
  # @return [Integer] Hash code
375
408
  def hash
376
- [company_id, company_name, group_id, group_name, competitor_company_id, competitor_company_name, competitor_group_id, competitor_group_name, competitor_rank, competitor_score, target_sim, mechanism_sim, indication_sim, phase_sim, n_shared_targets, n_shared_mechanisms, n_shared_indications, n_phase_overlap_targets, n_company_targets, n_competitor_targets, n_company_indications, n_competitor_indications, top_shared_targets, top_shared_indications, top_shared_mechanisms].hash
409
+ [company_id, company_name, group_id, group_name, competitor_company_id, competitor_company_name, competitor_group_id, competitor_group_name, competitor_class, n_class_candidates, competitor_rank, competitor_score, target_sim, mechanism_sim, indication_sim, phase_sim, n_shared_targets, n_shared_mechanisms, n_shared_indications, n_phase_overlap_targets, n_company_targets, n_competitor_targets, n_company_indications, n_competitor_indications, top_shared_targets, top_shared_indications, top_shared_mechanisms, n_cosponsored_trials].hash
377
410
  end
378
411
 
379
412
  # Builds the object from hash
@@ -0,0 +1,478 @@
1
+ =begin
2
+ #Pharma Observatory Public REST API
3
+
4
+ #Read-only REST API over the Pharma Observatory biomedical data platform. Reference: https://pharmaobservatory.com/api-reference
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PharmaObservatory
17
+ class CompanyCosponsorsResponse
18
+ attr_accessor :dataset
19
+
20
+ attr_accessor :grain
21
+
22
+ attr_accessor :object_type
23
+
24
+ attr_accessor :id
25
+
26
+ attr_accessor :scope
27
+
28
+ attr_accessor :columns
29
+
30
+ attr_accessor :rows
31
+
32
+ # The exact count of the filtered rows on an ungrouped read, carried by the cursor; null when grouped.
33
+ attr_accessor :total
34
+
35
+ attr_accessor :next_cursor
36
+
37
+ attr_accessor :sort
38
+
39
+ attr_accessor :filters
40
+
41
+ attr_accessor :group_by
42
+
43
+ attr_accessor :measures
44
+
45
+ attr_accessor :attribution
46
+
47
+ attr_accessor :source_credit
48
+
49
+ attr_accessor :withheld_tiers
50
+
51
+ attr_accessor :withheld_columns
52
+
53
+ attr_accessor :freshness
54
+
55
+ attr_accessor :build
56
+
57
+ attr_accessor :build_state
58
+
59
+ attr_accessor :restriction
60
+
61
+ # Attribute mapping from ruby-style variable name to JSON key.
62
+ def self.attribute_map
63
+ {
64
+ :'dataset' => :'dataset',
65
+ :'grain' => :'grain',
66
+ :'object_type' => :'object_type',
67
+ :'id' => :'id',
68
+ :'scope' => :'scope',
69
+ :'columns' => :'columns',
70
+ :'rows' => :'rows',
71
+ :'total' => :'total',
72
+ :'next_cursor' => :'next_cursor',
73
+ :'sort' => :'sort',
74
+ :'filters' => :'filters',
75
+ :'group_by' => :'group_by',
76
+ :'measures' => :'measures',
77
+ :'attribution' => :'attribution',
78
+ :'source_credit' => :'source_credit',
79
+ :'withheld_tiers' => :'withheld_tiers',
80
+ :'withheld_columns' => :'withheld_columns',
81
+ :'freshness' => :'freshness',
82
+ :'build' => :'build',
83
+ :'build_state' => :'build_state',
84
+ :'restriction' => :'restriction'
85
+ }
86
+ end
87
+
88
+ # Returns attribute mapping this model knows about
89
+ def self.acceptable_attribute_map
90
+ attribute_map
91
+ end
92
+
93
+ # Returns all the JSON keys this model knows about
94
+ def self.acceptable_attributes
95
+ acceptable_attribute_map.values
96
+ end
97
+
98
+ # Attribute type mapping.
99
+ def self.openapi_types
100
+ {
101
+ :'dataset' => :'String',
102
+ :'grain' => :'String',
103
+ :'object_type' => :'String',
104
+ :'id' => :'String',
105
+ :'scope' => :'AnimalWelfareAssurancesResponseScope',
106
+ :'columns' => :'Array<DatasetColumn>',
107
+ :'rows' => :'Array<CompanyCosponsorsRow>',
108
+ :'total' => :'Integer',
109
+ :'next_cursor' => :'String',
110
+ :'sort' => :'Array<String>',
111
+ :'filters' => :'Array<Hash<String, Object>>',
112
+ :'group_by' => :'Array<String>',
113
+ :'measures' => :'Array<String>',
114
+ :'attribution' => :'Array<DatasetAttribution>',
115
+ :'source_credit' => :'String',
116
+ :'withheld_tiers' => :'Array<String>',
117
+ :'withheld_columns' => :'Array<String>',
118
+ :'freshness' => :'AnimalWelfareAssurancesResponseFreshness',
119
+ :'build' => :'AnimalWelfareAssurancesResponseBuild',
120
+ :'build_state' => :'DatasetBuildState',
121
+ :'restriction' => :'Hash<String, Object>'
122
+ }
123
+ end
124
+
125
+ # List of attributes with nullable: true
126
+ def self.openapi_nullable
127
+ Set.new([
128
+ :'object_type',
129
+ :'id',
130
+ :'scope',
131
+ :'total',
132
+ :'next_cursor',
133
+ :'restriction'
134
+ ])
135
+ end
136
+
137
+ # Initializes the object
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ def initialize(attributes = {})
140
+ if (!attributes.is_a?(Hash))
141
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PharmaObservatory::CompanyCosponsorsResponse` initialize method"
142
+ end
143
+
144
+ # check to see if the attribute exists and convert string to symbol for hash key
145
+ acceptable_attribute_map = self.class.acceptable_attribute_map
146
+ attributes = attributes.each_with_object({}) { |(k, v), h|
147
+ if (!acceptable_attribute_map.key?(k.to_sym))
148
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PharmaObservatory::CompanyCosponsorsResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
149
+ end
150
+ h[k.to_sym] = v
151
+ }
152
+
153
+ if attributes.key?(:'dataset')
154
+ self.dataset = attributes[:'dataset']
155
+ else
156
+ self.dataset = nil
157
+ end
158
+
159
+ if attributes.key?(:'grain')
160
+ self.grain = attributes[:'grain']
161
+ end
162
+
163
+ if attributes.key?(:'object_type')
164
+ self.object_type = attributes[:'object_type']
165
+ end
166
+
167
+ if attributes.key?(:'id')
168
+ self.id = attributes[:'id']
169
+ end
170
+
171
+ if attributes.key?(:'scope')
172
+ self.scope = attributes[:'scope']
173
+ end
174
+
175
+ if attributes.key?(:'columns')
176
+ if (value = attributes[:'columns']).is_a?(Array)
177
+ self.columns = value
178
+ end
179
+ else
180
+ self.columns = nil
181
+ end
182
+
183
+ if attributes.key?(:'rows')
184
+ if (value = attributes[:'rows']).is_a?(Array)
185
+ self.rows = value
186
+ end
187
+ else
188
+ self.rows = nil
189
+ end
190
+
191
+ if attributes.key?(:'total')
192
+ self.total = attributes[:'total']
193
+ end
194
+
195
+ if attributes.key?(:'next_cursor')
196
+ self.next_cursor = attributes[:'next_cursor']
197
+ end
198
+
199
+ if attributes.key?(:'sort')
200
+ if (value = attributes[:'sort']).is_a?(Array)
201
+ self.sort = value
202
+ end
203
+ end
204
+
205
+ if attributes.key?(:'filters')
206
+ if (value = attributes[:'filters']).is_a?(Array)
207
+ self.filters = value
208
+ end
209
+ end
210
+
211
+ if attributes.key?(:'group_by')
212
+ if (value = attributes[:'group_by']).is_a?(Array)
213
+ self.group_by = value
214
+ end
215
+ end
216
+
217
+ if attributes.key?(:'measures')
218
+ if (value = attributes[:'measures']).is_a?(Array)
219
+ self.measures = value
220
+ end
221
+ end
222
+
223
+ if attributes.key?(:'attribution')
224
+ if (value = attributes[:'attribution']).is_a?(Array)
225
+ self.attribution = value
226
+ end
227
+ end
228
+
229
+ if attributes.key?(:'source_credit')
230
+ self.source_credit = attributes[:'source_credit']
231
+ end
232
+
233
+ if attributes.key?(:'withheld_tiers')
234
+ if (value = attributes[:'withheld_tiers']).is_a?(Array)
235
+ self.withheld_tiers = value
236
+ end
237
+ end
238
+
239
+ if attributes.key?(:'withheld_columns')
240
+ if (value = attributes[:'withheld_columns']).is_a?(Array)
241
+ self.withheld_columns = value
242
+ end
243
+ end
244
+
245
+ if attributes.key?(:'freshness')
246
+ self.freshness = attributes[:'freshness']
247
+ end
248
+
249
+ if attributes.key?(:'build')
250
+ self.build = attributes[:'build']
251
+ end
252
+
253
+ if attributes.key?(:'build_state')
254
+ self.build_state = attributes[:'build_state']
255
+ end
256
+
257
+ if attributes.key?(:'restriction')
258
+ if (value = attributes[:'restriction']).is_a?(Hash)
259
+ self.restriction = value
260
+ end
261
+ end
262
+ end
263
+
264
+ # Show invalid properties with the reasons. Usually used together with valid?
265
+ # @return Array for valid properties with the reasons
266
+ def list_invalid_properties
267
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
268
+ invalid_properties = Array.new
269
+ if @dataset.nil?
270
+ invalid_properties.push('invalid value for "dataset", dataset cannot be nil.')
271
+ end
272
+
273
+ if @columns.nil?
274
+ invalid_properties.push('invalid value for "columns", columns cannot be nil.')
275
+ end
276
+
277
+ if @rows.nil?
278
+ invalid_properties.push('invalid value for "rows", rows cannot be nil.')
279
+ end
280
+
281
+ invalid_properties
282
+ end
283
+
284
+ # Check to see if the all the properties in the model are valid
285
+ # @return true if the model is valid
286
+ def valid?
287
+ warn '[DEPRECATED] the `valid?` method is obsolete'
288
+ return false if @dataset.nil?
289
+ return false if @columns.nil?
290
+ return false if @rows.nil?
291
+ true
292
+ end
293
+
294
+ # Custom attribute writer method with validation
295
+ # @param [Object] dataset Value to be assigned
296
+ def dataset=(dataset)
297
+ if dataset.nil?
298
+ fail ArgumentError, 'dataset cannot be nil'
299
+ end
300
+
301
+ @dataset = dataset
302
+ end
303
+
304
+ # Custom attribute writer method with validation
305
+ # @param [Object] columns Value to be assigned
306
+ def columns=(columns)
307
+ if columns.nil?
308
+ fail ArgumentError, 'columns cannot be nil'
309
+ end
310
+
311
+ @columns = columns
312
+ end
313
+
314
+ # Custom attribute writer method with validation
315
+ # @param [Object] rows Value to be assigned
316
+ def rows=(rows)
317
+ if rows.nil?
318
+ fail ArgumentError, 'rows cannot be nil'
319
+ end
320
+
321
+ @rows = rows
322
+ end
323
+
324
+ # Checks equality by comparing each attribute.
325
+ # @param [Object] Object to be compared
326
+ def ==(o)
327
+ return true if self.equal?(o)
328
+ self.class == o.class &&
329
+ dataset == o.dataset &&
330
+ grain == o.grain &&
331
+ object_type == o.object_type &&
332
+ id == o.id &&
333
+ scope == o.scope &&
334
+ columns == o.columns &&
335
+ rows == o.rows &&
336
+ total == o.total &&
337
+ next_cursor == o.next_cursor &&
338
+ sort == o.sort &&
339
+ filters == o.filters &&
340
+ group_by == o.group_by &&
341
+ measures == o.measures &&
342
+ attribution == o.attribution &&
343
+ source_credit == o.source_credit &&
344
+ withheld_tiers == o.withheld_tiers &&
345
+ withheld_columns == o.withheld_columns &&
346
+ freshness == o.freshness &&
347
+ build == o.build &&
348
+ build_state == o.build_state &&
349
+ restriction == o.restriction
350
+ end
351
+
352
+ # @see the `==` method
353
+ # @param [Object] Object to be compared
354
+ def eql?(o)
355
+ self == o
356
+ end
357
+
358
+ # Calculates hash code according to all attributes.
359
+ # @return [Integer] Hash code
360
+ def hash
361
+ [dataset, grain, object_type, id, scope, columns, rows, total, next_cursor, sort, filters, group_by, measures, attribution, source_credit, withheld_tiers, withheld_columns, freshness, build, build_state, restriction].hash
362
+ end
363
+
364
+ # Builds the object from hash
365
+ # @param [Hash] attributes Model attributes in the form of hash
366
+ # @return [Object] Returns the model itself
367
+ def self.build_from_hash(attributes)
368
+ return nil unless attributes.is_a?(Hash)
369
+ attributes = attributes.transform_keys(&:to_sym)
370
+ transformed_hash = {}
371
+ openapi_types.each_pair do |key, type|
372
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
373
+ transformed_hash["#{key}"] = nil
374
+ elsif type =~ /\AArray<(.*)>/i
375
+ # check to ensure the input is an array given that the attribute
376
+ # is documented as an array but the input is not
377
+ if attributes[attribute_map[key]].is_a?(Array)
378
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
379
+ end
380
+ elsif !attributes[attribute_map[key]].nil?
381
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
382
+ end
383
+ end
384
+ new(transformed_hash)
385
+ end
386
+
387
+ # Deserializes the data based on type
388
+ # @param string type Data type
389
+ # @param string value Value to be deserialized
390
+ # @return [Object] Deserialized data
391
+ def self._deserialize(type, value)
392
+ case type.to_sym
393
+ when :Time
394
+ Time.parse(value)
395
+ when :Date
396
+ Date.parse(value)
397
+ when :String
398
+ value.to_s
399
+ when :Integer
400
+ value.to_i
401
+ when :Float
402
+ value.to_f
403
+ when :Boolean
404
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
405
+ true
406
+ else
407
+ false
408
+ end
409
+ when :Object
410
+ # generic object (usually a Hash), return directly
411
+ value
412
+ when /\AArray<(?<inner_type>.+)>\z/
413
+ inner_type = Regexp.last_match[:inner_type]
414
+ value.map { |v| _deserialize(inner_type, v) }
415
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
416
+ k_type = Regexp.last_match[:k_type]
417
+ v_type = Regexp.last_match[:v_type]
418
+ {}.tap do |hash|
419
+ value.each do |k, v|
420
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
421
+ end
422
+ end
423
+ else # model
424
+ # models (e.g. Pet) or oneOf
425
+ klass = PharmaObservatory.const_get(type)
426
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
427
+ end
428
+ end
429
+
430
+ # Returns the string representation of the object
431
+ # @return [String] String presentation of the object
432
+ def to_s
433
+ to_hash.to_s
434
+ end
435
+
436
+ # to_body is an alias to to_hash (backward compatibility)
437
+ # @return [Hash] Returns the object in the form of hash
438
+ def to_body
439
+ to_hash
440
+ end
441
+
442
+ # Returns the object in the form of hash
443
+ # @return [Hash] Returns the object in the form of hash
444
+ def to_hash
445
+ hash = {}
446
+ self.class.attribute_map.each_pair do |attr, param|
447
+ value = self.send(attr)
448
+ if value.nil?
449
+ is_nullable = self.class.openapi_nullable.include?(attr)
450
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
451
+ end
452
+
453
+ hash[param] = _to_hash(value)
454
+ end
455
+ hash
456
+ end
457
+
458
+ # Outputs non-array value in the form of hash
459
+ # For object, use to_hash. Otherwise, just return the value
460
+ # @param [Object] value Any valid value
461
+ # @return [Hash] Returns the value in the form of hash
462
+ def _to_hash(value)
463
+ if value.is_a?(Array)
464
+ value.compact.map { |v| _to_hash(v) }
465
+ elsif value.is_a?(Hash)
466
+ {}.tap do |hash|
467
+ value.each { |k, v| hash[k] = _to_hash(v) }
468
+ end
469
+ elsif value.respond_to? :to_hash
470
+ value.to_hash
471
+ else
472
+ value
473
+ end
474
+ end
475
+
476
+ end
477
+
478
+ end