polar-accesslink-api-gem 0.1.0

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 (162) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +182 -0
  4. data/Rakefile +10 -0
  5. data/docs/Activity.md +34 -0
  6. data/docs/ActivityLog.md +18 -0
  7. data/docs/ActivityStepSample.md +20 -0
  8. data/docs/ActivityStepSamples.md +20 -0
  9. data/docs/ActivityZoneSample.md +20 -0
  10. data/docs/ActivityZoneSamples.md +20 -0
  11. data/docs/AvailableSleep.md +22 -0
  12. data/docs/AvailableSleeps.md +18 -0
  13. data/docs/AvailableUserData.md +22 -0
  14. data/docs/AvailableUserDatas.md +18 -0
  15. data/docs/CreatedWebhook.md +18 -0
  16. data/docs/CreatedWebhookData.md +24 -0
  17. data/docs/DailyActivityApi.md +440 -0
  18. data/docs/DurationZone.md +20 -0
  19. data/docs/Error.md +26 -0
  20. data/docs/Exercise.md +54 -0
  21. data/docs/ExerciseHashId.md +52 -0
  22. data/docs/Exercises.md +18 -0
  23. data/docs/ExercisesApi.md +214 -0
  24. data/docs/HeartRate.md +20 -0
  25. data/docs/NightlyRecharge.md +38 -0
  26. data/docs/NightlyRechargeApi.md +144 -0
  27. data/docs/Nights.md +18 -0
  28. data/docs/PhysicalInfoApi.md +294 -0
  29. data/docs/PhysicalInformation.md +40 -0
  30. data/docs/PhysicalInformations.md +18 -0
  31. data/docs/PullNotificationsApi.md +75 -0
  32. data/docs/Recharges.md +18 -0
  33. data/docs/Register.md +18 -0
  34. data/docs/Sample.md +22 -0
  35. data/docs/Samples.md +18 -0
  36. data/docs/Sleep.md +64 -0
  37. data/docs/SleepApi.md +211 -0
  38. data/docs/TrainingDataApi.md +744 -0
  39. data/docs/TransactionLocation.md +20 -0
  40. data/docs/User.md +36 -0
  41. data/docs/UserExtraInfo.md +22 -0
  42. data/docs/UsersApi.md +216 -0
  43. data/docs/WebhookInfo.md +18 -0
  44. data/docs/WebhookInfoData.md +22 -0
  45. data/docs/WebhookPatch.md +20 -0
  46. data/docs/WebhookPayloadExercise.md +26 -0
  47. data/docs/WebhookPayloadSleep.md +26 -0
  48. data/docs/WebhookPing.md +20 -0
  49. data/docs/WebhookRequest.md +20 -0
  50. data/docs/WebhookType.md +15 -0
  51. data/docs/WebhooksApi.md +289 -0
  52. data/docs/Zone.md +24 -0
  53. data/docs/Zones.md +18 -0
  54. data/git_push.sh +58 -0
  55. data/lib/polar-accesslink-api-gem/api/daily_activity_api.rb +469 -0
  56. data/lib/polar-accesslink-api-gem/api/exercises_api.rb +205 -0
  57. data/lib/polar-accesslink-api-gem/api/nightly_recharge_api.rb +142 -0
  58. data/lib/polar-accesslink-api-gem/api/physical_info_api.rb +296 -0
  59. data/lib/polar-accesslink-api-gem/api/pull_notifications_api.rb +79 -0
  60. data/lib/polar-accesslink-api-gem/api/sleep_api.rb +199 -0
  61. data/lib/polar-accesslink-api-gem/api/training_data_api.rb +785 -0
  62. data/lib/polar-accesslink-api-gem/api/users_api.rb +221 -0
  63. data/lib/polar-accesslink-api-gem/api/webhooks_api.rb +278 -0
  64. data/lib/polar-accesslink-api-gem/api_client.rb +390 -0
  65. data/lib/polar-accesslink-api-gem/api_error.rb +57 -0
  66. data/lib/polar-accesslink-api-gem/configuration.rb +284 -0
  67. data/lib/polar-accesslink-api-gem/models/activity.rb +300 -0
  68. data/lib/polar-accesslink-api-gem/models/activity_log.rb +222 -0
  69. data/lib/polar-accesslink-api-gem/models/activity_step_sample.rb +230 -0
  70. data/lib/polar-accesslink-api-gem/models/activity_step_samples.rb +232 -0
  71. data/lib/polar-accesslink-api-gem/models/activity_zone_sample.rb +232 -0
  72. data/lib/polar-accesslink-api-gem/models/activity_zone_samples.rb +232 -0
  73. data/lib/polar-accesslink-api-gem/models/available_sleep.rb +239 -0
  74. data/lib/polar-accesslink-api-gem/models/available_sleeps.rb +221 -0
  75. data/lib/polar-accesslink-api-gem/models/available_user_data.rb +274 -0
  76. data/lib/polar-accesslink-api-gem/models/available_user_datas.rb +222 -0
  77. data/lib/polar-accesslink-api-gem/models/created_webhook.rb +218 -0
  78. data/lib/polar-accesslink-api-gem/models/created_webhook_data.rb +248 -0
  79. data/lib/polar-accesslink-api-gem/models/duration_zone.rb +230 -0
  80. data/lib/polar-accesslink-api-gem/models/error.rb +260 -0
  81. data/lib/polar-accesslink-api-gem/models/exercise.rb +399 -0
  82. data/lib/polar-accesslink-api-gem/models/exercise_hash_id.rb +389 -0
  83. data/lib/polar-accesslink-api-gem/models/exercises.rb +222 -0
  84. data/lib/polar-accesslink-api-gem/models/heart_rate.rb +230 -0
  85. data/lib/polar-accesslink-api-gem/models/nightly_recharge.rb +319 -0
  86. data/lib/polar-accesslink-api-gem/models/nights.rb +222 -0
  87. data/lib/polar-accesslink-api-gem/models/physical_information.rb +364 -0
  88. data/lib/polar-accesslink-api-gem/models/physical_informations.rb +222 -0
  89. data/lib/polar-accesslink-api-gem/models/recharges.rb +222 -0
  90. data/lib/polar-accesslink-api-gem/models/register.rb +225 -0
  91. data/lib/polar-accesslink-api-gem/models/sample.rb +240 -0
  92. data/lib/polar-accesslink-api-gem/models/samples.rb +222 -0
  93. data/lib/polar-accesslink-api-gem/models/sleep.rb +449 -0
  94. data/lib/polar-accesslink-api-gem/models/transaction_location.rb +230 -0
  95. data/lib/polar-accesslink-api-gem/models/user.rb +346 -0
  96. data/lib/polar-accesslink-api-gem/models/user_extra_info.rb +240 -0
  97. data/lib/polar-accesslink-api-gem/models/webhook_info.rb +218 -0
  98. data/lib/polar-accesslink-api-gem/models/webhook_info_data.rb +238 -0
  99. data/lib/polar-accesslink-api-gem/models/webhook_patch.rb +231 -0
  100. data/lib/polar-accesslink-api-gem/models/webhook_payload_exercise.rb +260 -0
  101. data/lib/polar-accesslink-api-gem/models/webhook_payload_sleep.rb +260 -0
  102. data/lib/polar-accesslink-api-gem/models/webhook_ping.rb +264 -0
  103. data/lib/polar-accesslink-api-gem/models/webhook_request.rb +241 -0
  104. data/lib/polar-accesslink-api-gem/models/webhook_type.rb +36 -0
  105. data/lib/polar-accesslink-api-gem/models/zone.rb +250 -0
  106. data/lib/polar-accesslink-api-gem/models/zones.rb +222 -0
  107. data/lib/polar-accesslink-api-gem/version.rb +15 -0
  108. data/lib/polar-accesslink-api-gem.rb +88 -0
  109. data/polar-accesslink-api-gem.gemspec +38 -0
  110. data/spec/api/daily_activity_api_spec.rb +114 -0
  111. data/spec/api/exercises_api_spec.rb +70 -0
  112. data/spec/api/nightly_recharge_api_spec.rb +58 -0
  113. data/spec/api/physical_info_api_spec.rb +87 -0
  114. data/spec/api/pull_notifications_api_spec.rb +46 -0
  115. data/spec/api/sleep_api_spec.rb +69 -0
  116. data/spec/api/training_data_api_spec.rb +173 -0
  117. data/spec/api/users_api_spec.rb +71 -0
  118. data/spec/api/webhooks_api_spec.rb +83 -0
  119. data/spec/api_client_spec.rb +226 -0
  120. data/spec/configuration_spec.rb +42 -0
  121. data/spec/models/activity_log_spec.rb +34 -0
  122. data/spec/models/activity_spec.rb +82 -0
  123. data/spec/models/activity_step_sample_spec.rb +40 -0
  124. data/spec/models/activity_step_samples_spec.rb +40 -0
  125. data/spec/models/activity_zone_sample_spec.rb +40 -0
  126. data/spec/models/activity_zone_samples_spec.rb +40 -0
  127. data/spec/models/available_sleep_spec.rb +46 -0
  128. data/spec/models/available_sleeps_spec.rb +34 -0
  129. data/spec/models/available_user_data_spec.rb +50 -0
  130. data/spec/models/available_user_datas_spec.rb +34 -0
  131. data/spec/models/created_webhook_data_spec.rb +52 -0
  132. data/spec/models/created_webhook_spec.rb +34 -0
  133. data/spec/models/duration_zone_spec.rb +40 -0
  134. data/spec/models/error_spec.rb +58 -0
  135. data/spec/models/exercise_hash_id_spec.rb +136 -0
  136. data/spec/models/exercise_spec.rb +142 -0
  137. data/spec/models/exercises_spec.rb +34 -0
  138. data/spec/models/heart_rate_spec.rb +40 -0
  139. data/spec/models/nightly_recharge_spec.rb +94 -0
  140. data/spec/models/nights_spec.rb +34 -0
  141. data/spec/models/physical_information_spec.rb +104 -0
  142. data/spec/models/physical_informations_spec.rb +34 -0
  143. data/spec/models/recharges_spec.rb +34 -0
  144. data/spec/models/register_spec.rb +34 -0
  145. data/spec/models/sample_spec.rb +46 -0
  146. data/spec/models/samples_spec.rb +34 -0
  147. data/spec/models/sleep_spec.rb +172 -0
  148. data/spec/models/transaction_location_spec.rb +40 -0
  149. data/spec/models/user_extra_info_spec.rb +46 -0
  150. data/spec/models/user_spec.rb +92 -0
  151. data/spec/models/webhook_info_data_spec.rb +46 -0
  152. data/spec/models/webhook_info_spec.rb +34 -0
  153. data/spec/models/webhook_patch_spec.rb +40 -0
  154. data/spec/models/webhook_payload_exercise_spec.rb +58 -0
  155. data/spec/models/webhook_payload_sleep_spec.rb +58 -0
  156. data/spec/models/webhook_ping_spec.rb +44 -0
  157. data/spec/models/webhook_request_spec.rb +40 -0
  158. data/spec/models/webhook_type_spec.rb +28 -0
  159. data/spec/models/zone_spec.rb +52 -0
  160. data/spec/models/zones_spec.rb +34 -0
  161. data/spec/spec_helper.rb +111 -0
  162. metadata +295 -0
@@ -0,0 +1,399 @@
1
+ =begin
2
+ #Polar Accesslink API
3
+
4
+ #Polar Accesslink API documentation
5
+
6
+ The version of the OpenAPI document: 3.78.0
7
+ Contact: b2bhelpdesk@polar.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PolarAccesslinkApiGem
17
+ # Training session summary data
18
+ class Exercise
19
+ # Id of the trainining session
20
+ attr_accessor :id
21
+
22
+ # Time of the transfer from wrist unit to Polar database
23
+ attr_accessor :upload_time
24
+
25
+ # Absolute link to Polar user owning the training
26
+ attr_accessor :polar_user
27
+
28
+ # Id of the exercise-transaction this training was transferred in
29
+ attr_accessor :transaction_id
30
+
31
+ # Polar product used in training
32
+ attr_accessor :device
33
+
34
+ # Start time of the training session in local time
35
+ attr_accessor :start_time
36
+
37
+ # The duration of the training session as specified in ISO8601
38
+ attr_accessor :duration
39
+
40
+ # Expended calories during training in kilocalories
41
+ attr_accessor :calories
42
+
43
+ # Distance in meters travelled during training
44
+ attr_accessor :distance
45
+
46
+ attr_accessor :heart_rate
47
+
48
+ # Training load effect to user
49
+ attr_accessor :training_load
50
+
51
+ # Sport name
52
+ attr_accessor :sport
53
+
54
+ # Boolean indicating if the exercise has route data
55
+ attr_accessor :has_route
56
+
57
+ # Has value if the exercise is from \"Flow For Club\", otherwise not printed. Value -1 indicates that there were errors finding the club
58
+ attr_accessor :club_id
59
+
60
+ # Has value if the exercise is from \"Flow For Club\", otherwise not printed. Value \"Ambiguous club location. Please contact support.\" is printed in case of error (and the club-id is -1).
61
+ attr_accessor :club_name
62
+
63
+ # String containing the name of a Polar Flow-compatible sport, if one is set for the exercise.
64
+ attr_accessor :detailed_sport_info
65
+
66
+ # Fat percentage of exercise calories. Has value if the exercise is from training device supporting Energy sources, otherwise not printed.
67
+ attr_accessor :fat_percentage
68
+
69
+ # Carbohydrate percentage of exercise calories. Has value if the exercise is from training device supporting Energy sources, otherwise not printed.
70
+ attr_accessor :carbohydrate_percentage
71
+
72
+ # Protein percentage of exercise calories. Has value if the exercise is from training device supporting Energy sources, otherwise not printed.
73
+ attr_accessor :protein_percentage
74
+
75
+ # Attribute mapping from ruby-style variable name to JSON key.
76
+ def self.attribute_map
77
+ {
78
+ :'id' => :'id',
79
+ :'upload_time' => :'upload-time',
80
+ :'polar_user' => :'polar-user',
81
+ :'transaction_id' => :'transaction-id',
82
+ :'device' => :'device',
83
+ :'start_time' => :'start-time',
84
+ :'duration' => :'duration',
85
+ :'calories' => :'calories',
86
+ :'distance' => :'distance',
87
+ :'heart_rate' => :'heart-rate',
88
+ :'training_load' => :'training-load',
89
+ :'sport' => :'sport',
90
+ :'has_route' => :'has-route',
91
+ :'club_id' => :'club-id',
92
+ :'club_name' => :'club-name',
93
+ :'detailed_sport_info' => :'detailed-sport-info',
94
+ :'fat_percentage' => :'fat-percentage',
95
+ :'carbohydrate_percentage' => :'carbohydrate-percentage',
96
+ :'protein_percentage' => :'protein-percentage'
97
+ }
98
+ end
99
+
100
+ # Returns all the JSON keys this model knows about
101
+ def self.acceptable_attributes
102
+ attribute_map.values
103
+ end
104
+
105
+ # Attribute type mapping.
106
+ def self.openapi_types
107
+ {
108
+ :'id' => :'Integer',
109
+ :'upload_time' => :'String',
110
+ :'polar_user' => :'String',
111
+ :'transaction_id' => :'Integer',
112
+ :'device' => :'String',
113
+ :'start_time' => :'String',
114
+ :'duration' => :'String',
115
+ :'calories' => :'Integer',
116
+ :'distance' => :'Float',
117
+ :'heart_rate' => :'HeartRate',
118
+ :'training_load' => :'Float',
119
+ :'sport' => :'String',
120
+ :'has_route' => :'Boolean',
121
+ :'club_id' => :'Integer',
122
+ :'club_name' => :'String',
123
+ :'detailed_sport_info' => :'String',
124
+ :'fat_percentage' => :'Integer',
125
+ :'carbohydrate_percentage' => :'Integer',
126
+ :'protein_percentage' => :'Integer'
127
+ }
128
+ end
129
+
130
+ # List of attributes with nullable: true
131
+ def self.openapi_nullable
132
+ Set.new([
133
+ ])
134
+ end
135
+
136
+ # Initializes the object
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ def initialize(attributes = {})
139
+ if (!attributes.is_a?(Hash))
140
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslinkApiGem::Exercise` initialize method"
141
+ end
142
+
143
+ # check to see if the attribute exists and convert string to symbol for hash key
144
+ attributes = attributes.each_with_object({}) { |(k, v), h|
145
+ if (!self.class.attribute_map.key?(k.to_sym))
146
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslinkApiGem::Exercise`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
147
+ end
148
+ h[k.to_sym] = v
149
+ }
150
+
151
+ if attributes.key?(:'id')
152
+ self.id = attributes[:'id']
153
+ end
154
+
155
+ if attributes.key?(:'upload_time')
156
+ self.upload_time = attributes[:'upload_time']
157
+ end
158
+
159
+ if attributes.key?(:'polar_user')
160
+ self.polar_user = attributes[:'polar_user']
161
+ end
162
+
163
+ if attributes.key?(:'transaction_id')
164
+ self.transaction_id = attributes[:'transaction_id']
165
+ end
166
+
167
+ if attributes.key?(:'device')
168
+ self.device = attributes[:'device']
169
+ end
170
+
171
+ if attributes.key?(:'start_time')
172
+ self.start_time = attributes[:'start_time']
173
+ end
174
+
175
+ if attributes.key?(:'duration')
176
+ self.duration = attributes[:'duration']
177
+ end
178
+
179
+ if attributes.key?(:'calories')
180
+ self.calories = attributes[:'calories']
181
+ end
182
+
183
+ if attributes.key?(:'distance')
184
+ self.distance = attributes[:'distance']
185
+ end
186
+
187
+ if attributes.key?(:'heart_rate')
188
+ self.heart_rate = attributes[:'heart_rate']
189
+ end
190
+
191
+ if attributes.key?(:'training_load')
192
+ self.training_load = attributes[:'training_load']
193
+ end
194
+
195
+ if attributes.key?(:'sport')
196
+ self.sport = attributes[:'sport']
197
+ end
198
+
199
+ if attributes.key?(:'has_route')
200
+ self.has_route = attributes[:'has_route']
201
+ end
202
+
203
+ if attributes.key?(:'club_id')
204
+ self.club_id = attributes[:'club_id']
205
+ end
206
+
207
+ if attributes.key?(:'club_name')
208
+ self.club_name = attributes[:'club_name']
209
+ end
210
+
211
+ if attributes.key?(:'detailed_sport_info')
212
+ self.detailed_sport_info = attributes[:'detailed_sport_info']
213
+ end
214
+
215
+ if attributes.key?(:'fat_percentage')
216
+ self.fat_percentage = attributes[:'fat_percentage']
217
+ end
218
+
219
+ if attributes.key?(:'carbohydrate_percentage')
220
+ self.carbohydrate_percentage = attributes[:'carbohydrate_percentage']
221
+ end
222
+
223
+ if attributes.key?(:'protein_percentage')
224
+ self.protein_percentage = attributes[:'protein_percentage']
225
+ end
226
+ end
227
+
228
+ # Show invalid properties with the reasons. Usually used together with valid?
229
+ # @return Array for valid properties with the reasons
230
+ def list_invalid_properties
231
+ invalid_properties = Array.new
232
+ invalid_properties
233
+ end
234
+
235
+ # Check to see if the all the properties in the model are valid
236
+ # @return true if the model is valid
237
+ def valid?
238
+ true
239
+ end
240
+
241
+ # Checks equality by comparing each attribute.
242
+ # @param [Object] Object to be compared
243
+ def ==(o)
244
+ return true if self.equal?(o)
245
+ self.class == o.class &&
246
+ id == o.id &&
247
+ upload_time == o.upload_time &&
248
+ polar_user == o.polar_user &&
249
+ transaction_id == o.transaction_id &&
250
+ device == o.device &&
251
+ start_time == o.start_time &&
252
+ duration == o.duration &&
253
+ calories == o.calories &&
254
+ distance == o.distance &&
255
+ heart_rate == o.heart_rate &&
256
+ training_load == o.training_load &&
257
+ sport == o.sport &&
258
+ has_route == o.has_route &&
259
+ club_id == o.club_id &&
260
+ club_name == o.club_name &&
261
+ detailed_sport_info == o.detailed_sport_info &&
262
+ fat_percentage == o.fat_percentage &&
263
+ carbohydrate_percentage == o.carbohydrate_percentage &&
264
+ protein_percentage == o.protein_percentage
265
+ end
266
+
267
+ # @see the `==` method
268
+ # @param [Object] Object to be compared
269
+ def eql?(o)
270
+ self == o
271
+ end
272
+
273
+ # Calculates hash code according to all attributes.
274
+ # @return [Integer] Hash code
275
+ def hash
276
+ [id, upload_time, polar_user, transaction_id, device, start_time, duration, calories, distance, heart_rate, training_load, sport, has_route, club_id, club_name, detailed_sport_info, fat_percentage, carbohydrate_percentage, protein_percentage].hash
277
+ end
278
+
279
+ # Builds the object from hash
280
+ # @param [Hash] attributes Model attributes in the form of hash
281
+ # @return [Object] Returns the model itself
282
+ def self.build_from_hash(attributes)
283
+ new.build_from_hash(attributes)
284
+ end
285
+
286
+ # Builds the object from hash
287
+ # @param [Hash] attributes Model attributes in the form of hash
288
+ # @return [Object] Returns the model itself
289
+ def build_from_hash(attributes)
290
+ return nil unless attributes.is_a?(Hash)
291
+ self.class.openapi_types.each_pair do |key, type|
292
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
293
+ self.send("#{key}=", nil)
294
+ elsif type =~ /\AArray<(.*)>/i
295
+ # check to ensure the input is an array given that the attribute
296
+ # is documented as an array but the input is not
297
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
298
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
299
+ end
300
+ elsif !attributes[self.class.attribute_map[key]].nil?
301
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
302
+ end
303
+ end
304
+
305
+ self
306
+ end
307
+
308
+ # Deserializes the data based on type
309
+ # @param string type Data type
310
+ # @param string value Value to be deserialized
311
+ # @return [Object] Deserialized data
312
+ def _deserialize(type, value)
313
+ case type.to_sym
314
+ when :Time
315
+ Time.parse(value)
316
+ when :Date
317
+ Date.parse(value)
318
+ when :String
319
+ value.to_s
320
+ when :Integer
321
+ value.to_i
322
+ when :Float
323
+ value.to_f
324
+ when :Boolean
325
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
326
+ true
327
+ else
328
+ false
329
+ end
330
+ when :Object
331
+ # generic object (usually a Hash), return directly
332
+ value
333
+ when /\AArray<(?<inner_type>.+)>\z/
334
+ inner_type = Regexp.last_match[:inner_type]
335
+ value.map { |v| _deserialize(inner_type, v) }
336
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
337
+ k_type = Regexp.last_match[:k_type]
338
+ v_type = Regexp.last_match[:v_type]
339
+ {}.tap do |hash|
340
+ value.each do |k, v|
341
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
342
+ end
343
+ end
344
+ else # model
345
+ # models (e.g. Pet) or oneOf
346
+ klass = PolarAccesslinkApiGem.const_get(type)
347
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
348
+ end
349
+ end
350
+
351
+ # Returns the string representation of the object
352
+ # @return [String] String presentation of the object
353
+ def to_s
354
+ to_hash.to_s
355
+ end
356
+
357
+ # to_body is an alias to to_hash (backward compatibility)
358
+ # @return [Hash] Returns the object in the form of hash
359
+ def to_body
360
+ to_hash
361
+ end
362
+
363
+ # Returns the object in the form of hash
364
+ # @return [Hash] Returns the object in the form of hash
365
+ def to_hash
366
+ hash = {}
367
+ self.class.attribute_map.each_pair do |attr, param|
368
+ value = self.send(attr)
369
+ if value.nil?
370
+ is_nullable = self.class.openapi_nullable.include?(attr)
371
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
372
+ end
373
+
374
+ hash[param] = _to_hash(value)
375
+ end
376
+ hash
377
+ end
378
+
379
+ # Outputs non-array value in the form of hash
380
+ # For object, use to_hash. Otherwise, just return the value
381
+ # @param [Object] value Any valid value
382
+ # @return [Hash] Returns the value in the form of hash
383
+ def _to_hash(value)
384
+ if value.is_a?(Array)
385
+ value.compact.map { |v| _to_hash(v) }
386
+ elsif value.is_a?(Hash)
387
+ {}.tap do |hash|
388
+ value.each { |k, v| hash[k] = _to_hash(v) }
389
+ end
390
+ elsif value.respond_to? :to_hash
391
+ value.to_hash
392
+ else
393
+ value
394
+ end
395
+ end
396
+
397
+ end
398
+
399
+ end
@@ -0,0 +1,389 @@
1
+ =begin
2
+ #Polar Accesslink API
3
+
4
+ #Polar Accesslink API documentation
5
+
6
+ The version of the OpenAPI document: 3.78.0
7
+ Contact: b2bhelpdesk@polar.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PolarAccesslinkApiGem
17
+ # Training session summary data
18
+ class ExerciseHashId
19
+ # Hashed id of the trainining session
20
+ attr_accessor :id
21
+
22
+ # Time of the transfer from wrist unit to Polar database
23
+ attr_accessor :upload_time
24
+
25
+ # Absolute link to Polar user owning the training
26
+ attr_accessor :polar_user
27
+
28
+ # Polar product used in training
29
+ attr_accessor :device
30
+
31
+ # Start time of the training session in local time
32
+ attr_accessor :start_time
33
+
34
+ # The duration of the training session as specified in ISO8601
35
+ attr_accessor :duration
36
+
37
+ # Expended calories during training in kilocalories
38
+ attr_accessor :calories
39
+
40
+ # Distance in meters travelled during training
41
+ attr_accessor :distance
42
+
43
+ attr_accessor :heart_rate
44
+
45
+ # Training load effect to user
46
+ attr_accessor :training_load
47
+
48
+ # Sport name
49
+ attr_accessor :sport
50
+
51
+ # Boolean indicating if the exercise has route data
52
+ attr_accessor :has_route
53
+
54
+ # Has value if the exercise is from \"Flow For Club\", otherwise not printed. Value -1 indicates that there were errors finding the club
55
+ attr_accessor :club_id
56
+
57
+ # Has value if the exercise is from \"Flow For Club\", otherwise not printed. Value \"Ambiguous club location. Please contact support.\" is printed in case of error (and the club-id is -1).
58
+ attr_accessor :club_name
59
+
60
+ # String containing the name of a Polar Flow-compatible sport, if one is set for the exercise.
61
+ attr_accessor :detailed_sport_info
62
+
63
+ # Fat percentage of exercise calories. Has value if the exercise is from training device supporting Energy sources, otherwise not printed.
64
+ attr_accessor :fat_percentage
65
+
66
+ # Carbohydrate percentage of exercise calories. Has value if the exercise is from training device supporting Energy sources, otherwise not printed.
67
+ attr_accessor :carbohydrate_percentage
68
+
69
+ # Protein percentage of exercise calories. Has value if the exercise is from training device supporting Energy sources, otherwise not printed.
70
+ attr_accessor :protein_percentage
71
+
72
+ # Attribute mapping from ruby-style variable name to JSON key.
73
+ def self.attribute_map
74
+ {
75
+ :'id' => :'id',
76
+ :'upload_time' => :'upload_time',
77
+ :'polar_user' => :'polar_user',
78
+ :'device' => :'device',
79
+ :'start_time' => :'start_time',
80
+ :'duration' => :'duration',
81
+ :'calories' => :'calories',
82
+ :'distance' => :'distance',
83
+ :'heart_rate' => :'heart_rate',
84
+ :'training_load' => :'training_load',
85
+ :'sport' => :'sport',
86
+ :'has_route' => :'has_route',
87
+ :'club_id' => :'club_id',
88
+ :'club_name' => :'club_name',
89
+ :'detailed_sport_info' => :'detailed_sport_info',
90
+ :'fat_percentage' => :'fat_percentage',
91
+ :'carbohydrate_percentage' => :'carbohydrate_percentage',
92
+ :'protein_percentage' => :'protein_percentage'
93
+ }
94
+ end
95
+
96
+ # Returns all the JSON keys this model knows about
97
+ def self.acceptable_attributes
98
+ attribute_map.values
99
+ end
100
+
101
+ # Attribute type mapping.
102
+ def self.openapi_types
103
+ {
104
+ :'id' => :'String',
105
+ :'upload_time' => :'String',
106
+ :'polar_user' => :'String',
107
+ :'device' => :'String',
108
+ :'start_time' => :'String',
109
+ :'duration' => :'String',
110
+ :'calories' => :'Integer',
111
+ :'distance' => :'Float',
112
+ :'heart_rate' => :'HeartRate',
113
+ :'training_load' => :'Float',
114
+ :'sport' => :'String',
115
+ :'has_route' => :'Boolean',
116
+ :'club_id' => :'Integer',
117
+ :'club_name' => :'String',
118
+ :'detailed_sport_info' => :'String',
119
+ :'fat_percentage' => :'Integer',
120
+ :'carbohydrate_percentage' => :'Integer',
121
+ :'protein_percentage' => :'Integer'
122
+ }
123
+ end
124
+
125
+ # List of attributes with nullable: true
126
+ def self.openapi_nullable
127
+ Set.new([
128
+ ])
129
+ end
130
+
131
+ # Initializes the object
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ def initialize(attributes = {})
134
+ if (!attributes.is_a?(Hash))
135
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslinkApiGem::ExerciseHashId` initialize method"
136
+ end
137
+
138
+ # check to see if the attribute exists and convert string to symbol for hash key
139
+ attributes = attributes.each_with_object({}) { |(k, v), h|
140
+ if (!self.class.attribute_map.key?(k.to_sym))
141
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslinkApiGem::ExerciseHashId`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
142
+ end
143
+ h[k.to_sym] = v
144
+ }
145
+
146
+ if attributes.key?(:'id')
147
+ self.id = attributes[:'id']
148
+ end
149
+
150
+ if attributes.key?(:'upload_time')
151
+ self.upload_time = attributes[:'upload_time']
152
+ end
153
+
154
+ if attributes.key?(:'polar_user')
155
+ self.polar_user = attributes[:'polar_user']
156
+ end
157
+
158
+ if attributes.key?(:'device')
159
+ self.device = attributes[:'device']
160
+ end
161
+
162
+ if attributes.key?(:'start_time')
163
+ self.start_time = attributes[:'start_time']
164
+ end
165
+
166
+ if attributes.key?(:'duration')
167
+ self.duration = attributes[:'duration']
168
+ end
169
+
170
+ if attributes.key?(:'calories')
171
+ self.calories = attributes[:'calories']
172
+ end
173
+
174
+ if attributes.key?(:'distance')
175
+ self.distance = attributes[:'distance']
176
+ end
177
+
178
+ if attributes.key?(:'heart_rate')
179
+ self.heart_rate = attributes[:'heart_rate']
180
+ end
181
+
182
+ if attributes.key?(:'training_load')
183
+ self.training_load = attributes[:'training_load']
184
+ end
185
+
186
+ if attributes.key?(:'sport')
187
+ self.sport = attributes[:'sport']
188
+ end
189
+
190
+ if attributes.key?(:'has_route')
191
+ self.has_route = attributes[:'has_route']
192
+ end
193
+
194
+ if attributes.key?(:'club_id')
195
+ self.club_id = attributes[:'club_id']
196
+ end
197
+
198
+ if attributes.key?(:'club_name')
199
+ self.club_name = attributes[:'club_name']
200
+ end
201
+
202
+ if attributes.key?(:'detailed_sport_info')
203
+ self.detailed_sport_info = attributes[:'detailed_sport_info']
204
+ end
205
+
206
+ if attributes.key?(:'fat_percentage')
207
+ self.fat_percentage = attributes[:'fat_percentage']
208
+ end
209
+
210
+ if attributes.key?(:'carbohydrate_percentage')
211
+ self.carbohydrate_percentage = attributes[:'carbohydrate_percentage']
212
+ end
213
+
214
+ if attributes.key?(:'protein_percentage')
215
+ self.protein_percentage = attributes[:'protein_percentage']
216
+ end
217
+ end
218
+
219
+ # Show invalid properties with the reasons. Usually used together with valid?
220
+ # @return Array for valid properties with the reasons
221
+ def list_invalid_properties
222
+ invalid_properties = Array.new
223
+ invalid_properties
224
+ end
225
+
226
+ # Check to see if the all the properties in the model are valid
227
+ # @return true if the model is valid
228
+ def valid?
229
+ true
230
+ end
231
+
232
+ # Checks equality by comparing each attribute.
233
+ # @param [Object] Object to be compared
234
+ def ==(o)
235
+ return true if self.equal?(o)
236
+ self.class == o.class &&
237
+ id == o.id &&
238
+ upload_time == o.upload_time &&
239
+ polar_user == o.polar_user &&
240
+ device == o.device &&
241
+ start_time == o.start_time &&
242
+ duration == o.duration &&
243
+ calories == o.calories &&
244
+ distance == o.distance &&
245
+ heart_rate == o.heart_rate &&
246
+ training_load == o.training_load &&
247
+ sport == o.sport &&
248
+ has_route == o.has_route &&
249
+ club_id == o.club_id &&
250
+ club_name == o.club_name &&
251
+ detailed_sport_info == o.detailed_sport_info &&
252
+ fat_percentage == o.fat_percentage &&
253
+ carbohydrate_percentage == o.carbohydrate_percentage &&
254
+ protein_percentage == o.protein_percentage
255
+ end
256
+
257
+ # @see the `==` method
258
+ # @param [Object] Object to be compared
259
+ def eql?(o)
260
+ self == o
261
+ end
262
+
263
+ # Calculates hash code according to all attributes.
264
+ # @return [Integer] Hash code
265
+ def hash
266
+ [id, upload_time, polar_user, device, start_time, duration, calories, distance, heart_rate, training_load, sport, has_route, club_id, club_name, detailed_sport_info, fat_percentage, carbohydrate_percentage, protein_percentage].hash
267
+ end
268
+
269
+ # Builds the object from hash
270
+ # @param [Hash] attributes Model attributes in the form of hash
271
+ # @return [Object] Returns the model itself
272
+ def self.build_from_hash(attributes)
273
+ new.build_from_hash(attributes)
274
+ end
275
+
276
+ # Builds the object from hash
277
+ # @param [Hash] attributes Model attributes in the form of hash
278
+ # @return [Object] Returns the model itself
279
+ def build_from_hash(attributes)
280
+ return nil unless attributes.is_a?(Hash)
281
+ self.class.openapi_types.each_pair do |key, type|
282
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
283
+ self.send("#{key}=", nil)
284
+ elsif type =~ /\AArray<(.*)>/i
285
+ # check to ensure the input is an array given that the attribute
286
+ # is documented as an array but the input is not
287
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
288
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
289
+ end
290
+ elsif !attributes[self.class.attribute_map[key]].nil?
291
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
292
+ end
293
+ end
294
+
295
+ self
296
+ end
297
+
298
+ # Deserializes the data based on type
299
+ # @param string type Data type
300
+ # @param string value Value to be deserialized
301
+ # @return [Object] Deserialized data
302
+ def _deserialize(type, value)
303
+ case type.to_sym
304
+ when :Time
305
+ Time.parse(value)
306
+ when :Date
307
+ Date.parse(value)
308
+ when :String
309
+ value.to_s
310
+ when :Integer
311
+ value.to_i
312
+ when :Float
313
+ value.to_f
314
+ when :Boolean
315
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
316
+ true
317
+ else
318
+ false
319
+ end
320
+ when :Object
321
+ # generic object (usually a Hash), return directly
322
+ value
323
+ when /\AArray<(?<inner_type>.+)>\z/
324
+ inner_type = Regexp.last_match[:inner_type]
325
+ value.map { |v| _deserialize(inner_type, v) }
326
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
327
+ k_type = Regexp.last_match[:k_type]
328
+ v_type = Regexp.last_match[:v_type]
329
+ {}.tap do |hash|
330
+ value.each do |k, v|
331
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
332
+ end
333
+ end
334
+ else # model
335
+ # models (e.g. Pet) or oneOf
336
+ klass = PolarAccesslinkApiGem.const_get(type)
337
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
338
+ end
339
+ end
340
+
341
+ # Returns the string representation of the object
342
+ # @return [String] String presentation of the object
343
+ def to_s
344
+ to_hash.to_s
345
+ end
346
+
347
+ # to_body is an alias to to_hash (backward compatibility)
348
+ # @return [Hash] Returns the object in the form of hash
349
+ def to_body
350
+ to_hash
351
+ end
352
+
353
+ # Returns the object in the form of hash
354
+ # @return [Hash] Returns the object in the form of hash
355
+ def to_hash
356
+ hash = {}
357
+ self.class.attribute_map.each_pair do |attr, param|
358
+ value = self.send(attr)
359
+ if value.nil?
360
+ is_nullable = self.class.openapi_nullable.include?(attr)
361
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
362
+ end
363
+
364
+ hash[param] = _to_hash(value)
365
+ end
366
+ hash
367
+ end
368
+
369
+ # Outputs non-array value in the form of hash
370
+ # For object, use to_hash. Otherwise, just return the value
371
+ # @param [Object] value Any valid value
372
+ # @return [Hash] Returns the value in the form of hash
373
+ def _to_hash(value)
374
+ if value.is_a?(Array)
375
+ value.compact.map { |v| _to_hash(v) }
376
+ elsif value.is_a?(Hash)
377
+ {}.tap do |hash|
378
+ value.each { |k, v| hash[k] = _to_hash(v) }
379
+ end
380
+ elsif value.respond_to? :to_hash
381
+ value.to_hash
382
+ else
383
+ value
384
+ end
385
+ end
386
+
387
+ end
388
+
389
+ end