polar_accesslink 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 (138) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +70 -0
  4. data/README.md +170 -0
  5. data/Rakefile +10 -0
  6. data/docs/Activity.md +33 -0
  7. data/docs/ActivityLog.md +17 -0
  8. data/docs/ActivityStepSample.md +19 -0
  9. data/docs/ActivityStepSamples.md +19 -0
  10. data/docs/ActivityZoneSample.md +19 -0
  11. data/docs/ActivityZoneSamples.md +19 -0
  12. data/docs/AvailableUserData.md +21 -0
  13. data/docs/AvailableUserDatas.md +17 -0
  14. data/docs/CreatedWebhook.md +17 -0
  15. data/docs/CreatedWebhookData.md +23 -0
  16. data/docs/DailyActivityApi.md +339 -0
  17. data/docs/DurationZone.md +19 -0
  18. data/docs/Error.md +25 -0
  19. data/docs/Exercise.md +47 -0
  20. data/docs/ExerciseHashId.md +45 -0
  21. data/docs/Exercises.md +17 -0
  22. data/docs/ExercisesApi.md +163 -0
  23. data/docs/HeartRate.md +19 -0
  24. data/docs/PhysicalInfoApi.md +227 -0
  25. data/docs/PhysicalInformation.md +39 -0
  26. data/docs/PhysicalInformations.md +17 -0
  27. data/docs/PullNotificationsApi.md +58 -0
  28. data/docs/Register.md +17 -0
  29. data/docs/Sample.md +21 -0
  30. data/docs/Samples.md +17 -0
  31. data/docs/TrainingDataApi.md +571 -0
  32. data/docs/TransactionLocation.md +19 -0
  33. data/docs/User.md +35 -0
  34. data/docs/UserExtraInfo.md +21 -0
  35. data/docs/UsersApi.md +166 -0
  36. data/docs/WebhookInfo.md +17 -0
  37. data/docs/WebhookInfoData.md +21 -0
  38. data/docs/WebhookPatch.md +19 -0
  39. data/docs/WebhookPayload.md +25 -0
  40. data/docs/WebhookPing.md +19 -0
  41. data/docs/WebhookRequest.md +19 -0
  42. data/docs/WebhookType.md +16 -0
  43. data/docs/WebhooksApi.md +221 -0
  44. data/docs/Zone.md +23 -0
  45. data/docs/Zones.md +17 -0
  46. data/lib/.DS_Store +0 -0
  47. data/lib/polar_accesslink/.DS_Store +0 -0
  48. data/lib/polar_accesslink/api/daily_activity_api.rb +463 -0
  49. data/lib/polar_accesslink/api/exercises_api.rb +202 -0
  50. data/lib/polar_accesslink/api/physical_info_api.rb +292 -0
  51. data/lib/polar_accesslink/api/pull_notifications_api.rb +78 -0
  52. data/lib/polar_accesslink/api/training_data_api.rb +772 -0
  53. data/lib/polar_accesslink/api/users_api.rb +218 -0
  54. data/lib/polar_accesslink/api/webhooks_api.rb +274 -0
  55. data/lib/polar_accesslink/api_client.rb +386 -0
  56. data/lib/polar_accesslink/api_error.rb +57 -0
  57. data/lib/polar_accesslink/configuration.rb +255 -0
  58. data/lib/polar_accesslink/models/activity.rb +288 -0
  59. data/lib/polar_accesslink/models/activity_log.rb +210 -0
  60. data/lib/polar_accesslink/models/activity_step_sample.rb +218 -0
  61. data/lib/polar_accesslink/models/activity_step_samples.rb +220 -0
  62. data/lib/polar_accesslink/models/activity_zone_sample.rb +220 -0
  63. data/lib/polar_accesslink/models/activity_zone_samples.rb +220 -0
  64. data/lib/polar_accesslink/models/available_user_data.rb +262 -0
  65. data/lib/polar_accesslink/models/available_user_datas.rb +210 -0
  66. data/lib/polar_accesslink/models/created_webhook.rb +206 -0
  67. data/lib/polar_accesslink/models/created_webhook_data.rb +236 -0
  68. data/lib/polar_accesslink/models/duration_zone.rb +218 -0
  69. data/lib/polar_accesslink/models/error.rb +248 -0
  70. data/lib/polar_accesslink/models/exercise.rb +357 -0
  71. data/lib/polar_accesslink/models/exercise_hash_id.rb +347 -0
  72. data/lib/polar_accesslink/models/exercises.rb +210 -0
  73. data/lib/polar_accesslink/models/heart_rate.rb +218 -0
  74. data/lib/polar_accesslink/models/physical_information.rb +352 -0
  75. data/lib/polar_accesslink/models/physical_informations.rb +210 -0
  76. data/lib/polar_accesslink/models/register.rb +213 -0
  77. data/lib/polar_accesslink/models/sample.rb +228 -0
  78. data/lib/polar_accesslink/models/samples.rb +210 -0
  79. data/lib/polar_accesslink/models/transaction_location.rb +218 -0
  80. data/lib/polar_accesslink/models/user.rb +334 -0
  81. data/lib/polar_accesslink/models/user_extra_info.rb +228 -0
  82. data/lib/polar_accesslink/models/webhook_info.rb +206 -0
  83. data/lib/polar_accesslink/models/webhook_info_data.rb +226 -0
  84. data/lib/polar_accesslink/models/webhook_patch.rb +219 -0
  85. data/lib/polar_accesslink/models/webhook_payload.rb +246 -0
  86. data/lib/polar_accesslink/models/webhook_ping.rb +252 -0
  87. data/lib/polar_accesslink/models/webhook_request.rb +229 -0
  88. data/lib/polar_accesslink/models/webhook_type.rb +37 -0
  89. data/lib/polar_accesslink/models/zone.rb +238 -0
  90. data/lib/polar_accesslink/models/zones.rb +210 -0
  91. data/lib/polar_accesslink/version.rb +15 -0
  92. data/lib/polar_accesslink.rb +79 -0
  93. data/polar_accesslink-1.0.0.gem +0 -0
  94. data/polar_accesslink.gemspec +38 -0
  95. data/spec/api/daily_activity_api_spec.rb +114 -0
  96. data/spec/api/exercises_api_spec.rb +70 -0
  97. data/spec/api/physical_info_api_spec.rb +87 -0
  98. data/spec/api/pull_notifications_api_spec.rb +46 -0
  99. data/spec/api/training_data_api_spec.rb +172 -0
  100. data/spec/api/users_api_spec.rb +71 -0
  101. data/spec/api/webhooks_api_spec.rb +83 -0
  102. data/spec/api_client_spec.rb +226 -0
  103. data/spec/configuration_spec.rb +42 -0
  104. data/spec/models/activity_log_spec.rb +41 -0
  105. data/spec/models/activity_spec.rb +89 -0
  106. data/spec/models/activity_step_sample_spec.rb +47 -0
  107. data/spec/models/activity_step_samples_spec.rb +47 -0
  108. data/spec/models/activity_zone_sample_spec.rb +47 -0
  109. data/spec/models/activity_zone_samples_spec.rb +47 -0
  110. data/spec/models/available_user_data_spec.rb +57 -0
  111. data/spec/models/available_user_datas_spec.rb +41 -0
  112. data/spec/models/created_webhook_data_spec.rb +59 -0
  113. data/spec/models/created_webhook_spec.rb +41 -0
  114. data/spec/models/duration_zone_spec.rb +47 -0
  115. data/spec/models/error_spec.rb +65 -0
  116. data/spec/models/exercise_hash_id_spec.rb +125 -0
  117. data/spec/models/exercise_spec.rb +131 -0
  118. data/spec/models/exercises_spec.rb +41 -0
  119. data/spec/models/heart_rate_spec.rb +47 -0
  120. data/spec/models/physical_information_spec.rb +111 -0
  121. data/spec/models/physical_informations_spec.rb +41 -0
  122. data/spec/models/register_spec.rb +41 -0
  123. data/spec/models/sample_spec.rb +53 -0
  124. data/spec/models/samples_spec.rb +41 -0
  125. data/spec/models/transaction_location_spec.rb +47 -0
  126. data/spec/models/user_extra_info_spec.rb +53 -0
  127. data/spec/models/user_spec.rb +99 -0
  128. data/spec/models/webhook_info_data_spec.rb +53 -0
  129. data/spec/models/webhook_info_spec.rb +41 -0
  130. data/spec/models/webhook_patch_spec.rb +47 -0
  131. data/spec/models/webhook_payload_spec.rb +65 -0
  132. data/spec/models/webhook_ping_spec.rb +51 -0
  133. data/spec/models/webhook_request_spec.rb +47 -0
  134. data/spec/models/webhook_type_spec.rb +35 -0
  135. data/spec/models/zone_spec.rb +59 -0
  136. data/spec/models/zones_spec.rb +41 -0
  137. data/spec/spec_helper.rb +111 -0
  138. metadata +282 -0
@@ -0,0 +1,352 @@
1
+ =begin
2
+ #Polar Accesslink API
3
+
4
+ #Polar Accesslink API documentation
5
+
6
+ The version of the OpenAPI document: 3.40.0
7
+ Contact: b2bhelpdesk@polar.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PolarAccesslink
16
+ # User's physical information
17
+ class PhysicalInformation
18
+ # Physical information id
19
+ attr_accessor :id
20
+
21
+ # Id of the physical-information-transaction this training was transferred in
22
+ attr_accessor :transaction_id
23
+
24
+ # The time physical information was created in Accesslink, in format YYYY-MM-DDTHH:mm:ss.SSS
25
+ attr_accessor :created
26
+
27
+ # Absolute link to user owning the activity
28
+ attr_accessor :polar_user
29
+
30
+ # Height
31
+ attr_accessor :weight
32
+
33
+ # Height
34
+ attr_accessor :height
35
+
36
+ # Maximum heart rate
37
+ attr_accessor :maximum_heart_rate
38
+
39
+ # Resting hear rate
40
+ attr_accessor :resting_heart_rate
41
+
42
+ # Aerobic threshold
43
+ attr_accessor :aerobic_threshold
44
+
45
+ # Anaerobic threshold
46
+ attr_accessor :anaerobic_threshold
47
+
48
+ # VO2 max
49
+ attr_accessor :vo2_max
50
+
51
+ # Weight source
52
+ attr_accessor :weight_source
53
+
54
+ class EnumAttributeValidator
55
+ attr_reader :datatype
56
+ attr_reader :allowable_values
57
+
58
+ def initialize(datatype, allowable_values)
59
+ @allowable_values = allowable_values.map do |value|
60
+ case datatype.to_s
61
+ when /Integer/i
62
+ value.to_i
63
+ when /Float/i
64
+ value.to_f
65
+ else
66
+ value
67
+ end
68
+ end
69
+ end
70
+
71
+ def valid?(value)
72
+ !value || allowable_values.include?(value)
73
+ end
74
+ end
75
+
76
+ # Attribute mapping from ruby-style variable name to JSON key.
77
+ def self.attribute_map
78
+ {
79
+ :'id' => :'id',
80
+ :'transaction_id' => :'transaction-id',
81
+ :'created' => :'created',
82
+ :'polar_user' => :'polar-user',
83
+ :'weight' => :'weight',
84
+ :'height' => :'height',
85
+ :'maximum_heart_rate' => :'maximum-heart-rate',
86
+ :'resting_heart_rate' => :'resting-heart-rate',
87
+ :'aerobic_threshold' => :'aerobic-threshold',
88
+ :'anaerobic_threshold' => :'anaerobic-threshold',
89
+ :'vo2_max' => :'vo2-max',
90
+ :'weight_source' => :'weight-source'
91
+ }
92
+ end
93
+
94
+ # Attribute type mapping.
95
+ def self.openapi_types
96
+ {
97
+ :'id' => :'Integer',
98
+ :'transaction_id' => :'Integer',
99
+ :'created' => :'String',
100
+ :'polar_user' => :'String',
101
+ :'weight' => :'Float',
102
+ :'height' => :'Float',
103
+ :'maximum_heart_rate' => :'Integer',
104
+ :'resting_heart_rate' => :'Integer',
105
+ :'aerobic_threshold' => :'Integer',
106
+ :'anaerobic_threshold' => :'Integer',
107
+ :'vo2_max' => :'Integer',
108
+ :'weight_source' => :'String'
109
+ }
110
+ end
111
+
112
+ # List of attributes with nullable: true
113
+ def self.openapi_nullable
114
+ Set.new([
115
+ ])
116
+ end
117
+
118
+ # Initializes the object
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ def initialize(attributes = {})
121
+ if (!attributes.is_a?(Hash))
122
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslink::PhysicalInformation` initialize method"
123
+ end
124
+
125
+ # check to see if the attribute exists and convert string to symbol for hash key
126
+ attributes = attributes.each_with_object({}) { |(k, v), h|
127
+ if (!self.class.attribute_map.key?(k.to_sym))
128
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslink::PhysicalInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
129
+ end
130
+ h[k.to_sym] = v
131
+ }
132
+
133
+ if attributes.key?(:'id')
134
+ self.id = attributes[:'id']
135
+ end
136
+
137
+ if attributes.key?(:'transaction_id')
138
+ self.transaction_id = attributes[:'transaction_id']
139
+ end
140
+
141
+ if attributes.key?(:'created')
142
+ self.created = attributes[:'created']
143
+ end
144
+
145
+ if attributes.key?(:'polar_user')
146
+ self.polar_user = attributes[:'polar_user']
147
+ end
148
+
149
+ if attributes.key?(:'weight')
150
+ self.weight = attributes[:'weight']
151
+ end
152
+
153
+ if attributes.key?(:'height')
154
+ self.height = attributes[:'height']
155
+ end
156
+
157
+ if attributes.key?(:'maximum_heart_rate')
158
+ self.maximum_heart_rate = attributes[:'maximum_heart_rate']
159
+ end
160
+
161
+ if attributes.key?(:'resting_heart_rate')
162
+ self.resting_heart_rate = attributes[:'resting_heart_rate']
163
+ end
164
+
165
+ if attributes.key?(:'aerobic_threshold')
166
+ self.aerobic_threshold = attributes[:'aerobic_threshold']
167
+ end
168
+
169
+ if attributes.key?(:'anaerobic_threshold')
170
+ self.anaerobic_threshold = attributes[:'anaerobic_threshold']
171
+ end
172
+
173
+ if attributes.key?(:'vo2_max')
174
+ self.vo2_max = attributes[:'vo2_max']
175
+ end
176
+
177
+ if attributes.key?(:'weight_source')
178
+ self.weight_source = attributes[:'weight_source']
179
+ end
180
+ end
181
+
182
+ # Show invalid properties with the reasons. Usually used together with valid?
183
+ # @return Array for valid properties with the reasons
184
+ def list_invalid_properties
185
+ invalid_properties = Array.new
186
+ invalid_properties
187
+ end
188
+
189
+ # Check to see if the all the properties in the model are valid
190
+ # @return true if the model is valid
191
+ def valid?
192
+ weight_source_validator = EnumAttributeValidator.new('String', ["SOURCE_MEASURED", "SOURCE_USER"])
193
+ return false unless weight_source_validator.valid?(@weight_source)
194
+ true
195
+ end
196
+
197
+ # Custom attribute writer method checking allowed values (enum).
198
+ # @param [Object] weight_source Object to be assigned
199
+ def weight_source=(weight_source)
200
+ validator = EnumAttributeValidator.new('String', ["SOURCE_MEASURED", "SOURCE_USER"])
201
+ unless validator.valid?(weight_source)
202
+ fail ArgumentError, "invalid value for \"weight_source\", must be one of #{validator.allowable_values}."
203
+ end
204
+ @weight_source = weight_source
205
+ end
206
+
207
+ # Checks equality by comparing each attribute.
208
+ # @param [Object] Object to be compared
209
+ def ==(o)
210
+ return true if self.equal?(o)
211
+ self.class == o.class &&
212
+ id == o.id &&
213
+ transaction_id == o.transaction_id &&
214
+ created == o.created &&
215
+ polar_user == o.polar_user &&
216
+ weight == o.weight &&
217
+ height == o.height &&
218
+ maximum_heart_rate == o.maximum_heart_rate &&
219
+ resting_heart_rate == o.resting_heart_rate &&
220
+ aerobic_threshold == o.aerobic_threshold &&
221
+ anaerobic_threshold == o.anaerobic_threshold &&
222
+ vo2_max == o.vo2_max &&
223
+ weight_source == o.weight_source
224
+ end
225
+
226
+ # @see the `==` method
227
+ # @param [Object] Object to be compared
228
+ def eql?(o)
229
+ self == o
230
+ end
231
+
232
+ # Calculates hash code according to all attributes.
233
+ # @return [Integer] Hash code
234
+ def hash
235
+ [id, transaction_id, created, polar_user, weight, height, maximum_heart_rate, resting_heart_rate, aerobic_threshold, anaerobic_threshold, vo2_max, weight_source].hash
236
+ end
237
+
238
+ # Builds the object from hash
239
+ # @param [Hash] attributes Model attributes in the form of hash
240
+ # @return [Object] Returns the model itself
241
+ def self.build_from_hash(attributes)
242
+ new.build_from_hash(attributes)
243
+ end
244
+
245
+ # Builds the object from hash
246
+ # @param [Hash] attributes Model attributes in the form of hash
247
+ # @return [Object] Returns the model itself
248
+ def build_from_hash(attributes)
249
+ return nil unless attributes.is_a?(Hash)
250
+ self.class.openapi_types.each_pair do |key, type|
251
+ if type =~ /\AArray<(.*)>/i
252
+ # check to ensure the input is an array given that the attribute
253
+ # is documented as an array but the input is not
254
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
255
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
256
+ end
257
+ elsif !attributes[self.class.attribute_map[key]].nil?
258
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
259
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
260
+ end
261
+
262
+ self
263
+ end
264
+
265
+ # Deserializes the data based on type
266
+ # @param string type Data type
267
+ # @param string value Value to be deserialized
268
+ # @return [Object] Deserialized data
269
+ def _deserialize(type, value)
270
+ case type.to_sym
271
+ when :DateTime
272
+ DateTime.parse(value)
273
+ when :Date
274
+ Date.parse(value)
275
+ when :String
276
+ value.to_s
277
+ when :Integer
278
+ value.to_i
279
+ when :Float
280
+ value.to_f
281
+ when :Boolean
282
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
283
+ true
284
+ else
285
+ false
286
+ end
287
+ when :Object
288
+ # generic object (usually a Hash), return directly
289
+ value
290
+ when /\AArray<(?<inner_type>.+)>\z/
291
+ inner_type = Regexp.last_match[:inner_type]
292
+ value.map { |v| _deserialize(inner_type, v) }
293
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
294
+ k_type = Regexp.last_match[:k_type]
295
+ v_type = Regexp.last_match[:v_type]
296
+ {}.tap do |hash|
297
+ value.each do |k, v|
298
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
299
+ end
300
+ end
301
+ else # model
302
+ OpenapiClient.const_get(type).build_from_hash(value)
303
+ end
304
+ end
305
+
306
+ # Returns the string representation of the object
307
+ # @return [String] String presentation of the object
308
+ def to_s
309
+ to_hash.to_s
310
+ end
311
+
312
+ # to_body is an alias to to_hash (backward compatibility)
313
+ # @return [Hash] Returns the object in the form of hash
314
+ def to_body
315
+ to_hash
316
+ end
317
+
318
+ # Returns the object in the form of hash
319
+ # @return [Hash] Returns the object in the form of hash
320
+ def to_hash
321
+ hash = {}
322
+ self.class.attribute_map.each_pair do |attr, param|
323
+ value = self.send(attr)
324
+ if value.nil?
325
+ is_nullable = self.class.openapi_nullable.include?(attr)
326
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
327
+ end
328
+
329
+ hash[param] = _to_hash(value)
330
+ end
331
+ hash
332
+ end
333
+
334
+ # Outputs non-array value in the form of hash
335
+ # For object, use to_hash. Otherwise, just return the value
336
+ # @param [Object] value Any valid value
337
+ # @return [Hash] Returns the value in the form of hash
338
+ def _to_hash(value)
339
+ if value.is_a?(Array)
340
+ value.compact.map { |v| _to_hash(v) }
341
+ elsif value.is_a?(Hash)
342
+ {}.tap do |hash|
343
+ value.each { |k, v| hash[k] = _to_hash(v) }
344
+ end
345
+ elsif value.respond_to? :to_hash
346
+ value.to_hash
347
+ else
348
+ value
349
+ end
350
+ end
351
+ end
352
+ end
@@ -0,0 +1,210 @@
1
+ =begin
2
+ #Polar Accesslink API
3
+
4
+ #Polar Accesslink API documentation
5
+
6
+ The version of the OpenAPI document: 3.40.0
7
+ Contact: b2bhelpdesk@polar.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module PolarAccesslink
16
+ # Physical information transaction container
17
+ class PhysicalInformations
18
+ # Absolute links to individual physical informations within the transaction
19
+ attr_accessor :physical_informations
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'physical_informations' => :'physical-informations'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'physical_informations' => :'Array<String>'
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new([
38
+ ])
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ if (!attributes.is_a?(Hash))
45
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslink::PhysicalInformations` initialize method"
46
+ end
47
+
48
+ # check to see if the attribute exists and convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h|
50
+ if (!self.class.attribute_map.key?(k.to_sym))
51
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslink::PhysicalInformations`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
52
+ end
53
+ h[k.to_sym] = v
54
+ }
55
+
56
+ if attributes.key?(:'physical_informations')
57
+ if (value = attributes[:'physical_informations']).is_a?(Array)
58
+ self.physical_informations = value
59
+ end
60
+ end
61
+ end
62
+
63
+ # Show invalid properties with the reasons. Usually used together with valid?
64
+ # @return Array for valid properties with the reasons
65
+ def list_invalid_properties
66
+ invalid_properties = Array.new
67
+ invalid_properties
68
+ end
69
+
70
+ # Check to see if the all the properties in the model are valid
71
+ # @return true if the model is valid
72
+ def valid?
73
+ true
74
+ end
75
+
76
+ # Checks equality by comparing each attribute.
77
+ # @param [Object] Object to be compared
78
+ def ==(o)
79
+ return true if self.equal?(o)
80
+ self.class == o.class &&
81
+ physical_informations == o.physical_informations
82
+ end
83
+
84
+ # @see the `==` method
85
+ # @param [Object] Object to be compared
86
+ def eql?(o)
87
+ self == o
88
+ end
89
+
90
+ # Calculates hash code according to all attributes.
91
+ # @return [Integer] Hash code
92
+ def hash
93
+ [physical_informations].hash
94
+ end
95
+
96
+ # Builds the object from hash
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ # @return [Object] Returns the model itself
99
+ def self.build_from_hash(attributes)
100
+ new.build_from_hash(attributes)
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def build_from_hash(attributes)
107
+ return nil unless attributes.is_a?(Hash)
108
+ self.class.openapi_types.each_pair do |key, type|
109
+ if type =~ /\AArray<(.*)>/i
110
+ # check to ensure the input is an array given that the attribute
111
+ # is documented as an array but the input is not
112
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
113
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
114
+ end
115
+ elsif !attributes[self.class.attribute_map[key]].nil?
116
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
117
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
118
+ end
119
+
120
+ self
121
+ end
122
+
123
+ # Deserializes the data based on type
124
+ # @param string type Data type
125
+ # @param string value Value to be deserialized
126
+ # @return [Object] Deserialized data
127
+ def _deserialize(type, value)
128
+ case type.to_sym
129
+ when :DateTime
130
+ DateTime.parse(value)
131
+ when :Date
132
+ Date.parse(value)
133
+ when :String
134
+ value.to_s
135
+ when :Integer
136
+ value.to_i
137
+ when :Float
138
+ value.to_f
139
+ when :Boolean
140
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
141
+ true
142
+ else
143
+ false
144
+ end
145
+ when :Object
146
+ # generic object (usually a Hash), return directly
147
+ value
148
+ when /\AArray<(?<inner_type>.+)>\z/
149
+ inner_type = Regexp.last_match[:inner_type]
150
+ value.map { |v| _deserialize(inner_type, v) }
151
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
152
+ k_type = Regexp.last_match[:k_type]
153
+ v_type = Regexp.last_match[:v_type]
154
+ {}.tap do |hash|
155
+ value.each do |k, v|
156
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
157
+ end
158
+ end
159
+ else # model
160
+ OpenapiClient.const_get(type).build_from_hash(value)
161
+ end
162
+ end
163
+
164
+ # Returns the string representation of the object
165
+ # @return [String] String presentation of the object
166
+ def to_s
167
+ to_hash.to_s
168
+ end
169
+
170
+ # to_body is an alias to to_hash (backward compatibility)
171
+ # @return [Hash] Returns the object in the form of hash
172
+ def to_body
173
+ to_hash
174
+ end
175
+
176
+ # Returns the object in the form of hash
177
+ # @return [Hash] Returns the object in the form of hash
178
+ def to_hash
179
+ hash = {}
180
+ self.class.attribute_map.each_pair do |attr, param|
181
+ value = self.send(attr)
182
+ if value.nil?
183
+ is_nullable = self.class.openapi_nullable.include?(attr)
184
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
185
+ end
186
+
187
+ hash[param] = _to_hash(value)
188
+ end
189
+ hash
190
+ end
191
+
192
+ # Outputs non-array value in the form of hash
193
+ # For object, use to_hash. Otherwise, just return the value
194
+ # @param [Object] value Any valid value
195
+ # @return [Hash] Returns the value in the form of hash
196
+ def _to_hash(value)
197
+ if value.is_a?(Array)
198
+ value.compact.map { |v| _to_hash(v) }
199
+ elsif value.is_a?(Hash)
200
+ {}.tap do |hash|
201
+ value.each { |k, v| hash[k] = _to_hash(v) }
202
+ end
203
+ elsif value.respond_to? :to_hash
204
+ value.to_hash
205
+ else
206
+ value
207
+ end
208
+ end
209
+ end
210
+ end