pharmaobservatory 0.1.13 → 0.1.15

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -5
  3. data/docs/BiomarkerValidationRow.md +1 -1
  4. data/docs/ChangesList200Response.md +26 -0
  5. data/docs/ChangesList200ResponseBuildState.md +20 -0
  6. data/docs/ChangesList200ResponseItemsInner.md +48 -0
  7. data/docs/ChangesList200ResponseItemsInnerEntryKeys.md +18 -0
  8. data/docs/CompaniesApi.md +86 -4
  9. data/docs/CompanyAssetCollisionsResponse.md +58 -0
  10. data/docs/CompanyAssetCollisionsRow.md +68 -0
  11. data/docs/CompanyCompetitorsRow.md +16 -32
  12. data/docs/CompanyFinancialsRow.md +18 -0
  13. data/docs/ConditionAdverseEventsRow.md +5 -1
  14. data/docs/SubscriptionsApi.md +282 -0
  15. data/docs/SubscriptionsCreate201Response.md +22 -0
  16. data/docs/SubscriptionsCreate201ResponseSubscription.md +28 -0
  17. data/docs/SubscriptionsCreate201ResponseSubscriptionTarget.md +22 -0
  18. data/docs/SubscriptionsCreateRequest.md +20 -0
  19. data/docs/SubscriptionsDelete200Response.md +24 -0
  20. data/docs/SubscriptionsList200Response.md +22 -0
  21. data/docs/SubscriptionsList200ResponseSubscriptionsInner.md +28 -0
  22. data/docs/SubscriptionsList200ResponseSubscriptionsInnerTarget.md +26 -0
  23. data/docs/SubscriptionsList200ResponseSubscriptionsInnerTargetFilters.md +18 -0
  24. data/lib/pharmaobservatory/api/companies_api.rb +93 -2
  25. data/lib/pharmaobservatory/api/subscriptions_api.rb +261 -0
  26. data/lib/pharmaobservatory/models/biomarker_validation_row.rb +1 -1
  27. data/lib/pharmaobservatory/models/changes_list200_response.rb +343 -0
  28. data/lib/pharmaobservatory/models/changes_list200_response_build_state.rb +263 -0
  29. data/lib/pharmaobservatory/models/changes_list200_response_items_inner.rb +627 -0
  30. data/lib/pharmaobservatory/models/changes_list200_response_items_inner_entry_keys.rb +237 -0
  31. data/lib/pharmaobservatory/models/company_asset_collisions_response.rb +478 -0
  32. data/lib/pharmaobservatory/models/company_asset_collisions_row.rb +502 -0
  33. data/lib/pharmaobservatory/models/company_competitors_row.rb +61 -153
  34. data/lib/pharmaobservatory/models/company_financials_row.rb +100 -1
  35. data/lib/pharmaobservatory/models/condition_adverse_events_row.rb +27 -5
  36. data/lib/pharmaobservatory/models/subscriptions_create201_response.rb +289 -0
  37. data/lib/pharmaobservatory/models/subscriptions_create201_response_subscription.rb +369 -0
  38. data/lib/pharmaobservatory/models/subscriptions_create201_response_subscription_target.rb +289 -0
  39. data/lib/pharmaobservatory/models/subscriptions_create_request.rb +263 -0
  40. data/lib/pharmaobservatory/models/subscriptions_delete200_response.rb +315 -0
  41. data/lib/pharmaobservatory/models/subscriptions_list200_response.rb +291 -0
  42. data/lib/pharmaobservatory/models/subscriptions_list200_response_subscriptions_inner.rb +369 -0
  43. data/lib/pharmaobservatory/models/subscriptions_list200_response_subscriptions_inner_target.rb +277 -0
  44. data/lib/pharmaobservatory/models/subscriptions_list200_response_subscriptions_inner_target_filters.rb +237 -0
  45. data/lib/pharmaobservatory/version.rb +1 -1
  46. data/lib/pharmaobservatory.rb +16 -0
  47. metadata +34 -2
@@ -0,0 +1,237 @@
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 ChangesList200ResponseItemsInnerEntryKeys
18
+ attr_accessor :trials
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'trials' => :'trials'
24
+ }
25
+ end
26
+
27
+ # Returns attribute mapping this model knows about
28
+ def self.acceptable_attribute_map
29
+ attribute_map
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ acceptable_attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'trials' => :'String'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PharmaObservatory::ChangesList200ResponseItemsInnerEntryKeys` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ acceptable_attribute_map = self.class.acceptable_attribute_map
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!acceptable_attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PharmaObservatory::ChangesList200ResponseItemsInnerEntryKeys`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'trials')
67
+ self.trials = attributes[:'trials']
68
+ else
69
+ self.trials = nil
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
77
+ invalid_properties = Array.new
78
+ if @trials.nil?
79
+ invalid_properties.push('invalid value for "trials", trials cannot be nil.')
80
+ end
81
+
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ warn '[DEPRECATED] the `valid?` method is obsolete'
89
+ return false if @trials.nil?
90
+ true
91
+ end
92
+
93
+ # Custom attribute writer method with validation
94
+ # @param [Object] trials Value to be assigned
95
+ def trials=(trials)
96
+ if trials.nil?
97
+ fail ArgumentError, 'trials cannot be nil'
98
+ end
99
+
100
+ @trials = trials
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ trials == o.trials
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [trials].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ attributes = attributes.transform_keys(&:to_sym)
129
+ transformed_hash = {}
130
+ openapi_types.each_pair do |key, type|
131
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = nil
133
+ elsif type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[attribute_map[key]].is_a?(Array)
137
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
138
+ end
139
+ elsif !attributes[attribute_map[key]].nil?
140
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
141
+ end
142
+ end
143
+ new(transformed_hash)
144
+ end
145
+
146
+ # Deserializes the data based on type
147
+ # @param string type Data type
148
+ # @param string value Value to be deserialized
149
+ # @return [Object] Deserialized data
150
+ def self._deserialize(type, value)
151
+ case type.to_sym
152
+ when :Time
153
+ Time.parse(value)
154
+ when :Date
155
+ Date.parse(value)
156
+ when :String
157
+ value.to_s
158
+ when :Integer
159
+ value.to_i
160
+ when :Float
161
+ value.to_f
162
+ when :Boolean
163
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
164
+ true
165
+ else
166
+ false
167
+ end
168
+ when :Object
169
+ # generic object (usually a Hash), return directly
170
+ value
171
+ when /\AArray<(?<inner_type>.+)>\z/
172
+ inner_type = Regexp.last_match[:inner_type]
173
+ value.map { |v| _deserialize(inner_type, v) }
174
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
175
+ k_type = Regexp.last_match[:k_type]
176
+ v_type = Regexp.last_match[:v_type]
177
+ {}.tap do |hash|
178
+ value.each do |k, v|
179
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
180
+ end
181
+ end
182
+ else # model
183
+ # models (e.g. Pet) or oneOf
184
+ klass = PharmaObservatory.const_get(type)
185
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
186
+ end
187
+ end
188
+
189
+ # Returns the string representation of the object
190
+ # @return [String] String presentation of the object
191
+ def to_s
192
+ to_hash.to_s
193
+ end
194
+
195
+ # to_body is an alias to to_hash (backward compatibility)
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_body
198
+ to_hash
199
+ end
200
+
201
+ # Returns the object in the form of hash
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_hash
204
+ hash = {}
205
+ self.class.attribute_map.each_pair do |attr, param|
206
+ value = self.send(attr)
207
+ if value.nil?
208
+ is_nullable = self.class.openapi_nullable.include?(attr)
209
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
210
+ end
211
+
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+
235
+ end
236
+
237
+ end
@@ -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 CompanyAssetCollisionsResponse
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<CompanyAssetCollisionsRow>',
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::CompanyAssetCollisionsResponse` 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::CompanyAssetCollisionsResponse`. 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