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,288 @@
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
+ # Summary of user's daily activity
17
+ class Activity
18
+ # Activity summary id
19
+ attr_accessor :id
20
+
21
+ # Absolute link to user owning the activity
22
+ attr_accessor :polar_user
23
+
24
+ # Id of the activity-transaction this training was transferred in
25
+ attr_accessor :transaction_id
26
+
27
+ # Date when activity summary was recorded, in format YYYY-MM-DD
28
+ attr_accessor :date
29
+
30
+ # The time activity summary was created in Accesslink, in format YYYY-MM-DDTHH:mm:ss.SSS
31
+ attr_accessor :created
32
+
33
+ # Total daily calories in kilo calories including BMR
34
+ attr_accessor :calories
35
+
36
+ # Total daily calories not including BMR. Precise calculation requires that user's physical data is entered into Polar Flow
37
+ attr_accessor :active_calories
38
+
39
+ # The time interval as specified in ISO 8601
40
+ attr_accessor :duration
41
+
42
+ # You could consider this as a kind of activity unit. If you take one step the active-steps should increase by one and any activity comparable to one physical step would also increase the number by one
43
+ attr_accessor :active_steps
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'id' => :'id',
49
+ :'polar_user' => :'polar-user',
50
+ :'transaction_id' => :'transaction-id',
51
+ :'date' => :'date',
52
+ :'created' => :'created',
53
+ :'calories' => :'calories',
54
+ :'active_calories' => :'active-calories',
55
+ :'duration' => :'duration',
56
+ :'active_steps' => :'active-steps'
57
+ }
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'id' => :'Integer',
64
+ :'polar_user' => :'String',
65
+ :'transaction_id' => :'Integer',
66
+ :'date' => :'String',
67
+ :'created' => :'String',
68
+ :'calories' => :'Integer',
69
+ :'active_calories' => :'Integer',
70
+ :'duration' => :'String',
71
+ :'active_steps' => :'Integer'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.openapi_nullable
77
+ Set.new([
78
+ ])
79
+ end
80
+
81
+ # Initializes the object
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ def initialize(attributes = {})
84
+ if (!attributes.is_a?(Hash))
85
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslink::Activity` initialize method"
86
+ end
87
+
88
+ # check to see if the attribute exists and convert string to symbol for hash key
89
+ attributes = attributes.each_with_object({}) { |(k, v), h|
90
+ if (!self.class.attribute_map.key?(k.to_sym))
91
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslink::Activity`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
92
+ end
93
+ h[k.to_sym] = v
94
+ }
95
+
96
+ if attributes.key?(:'id')
97
+ self.id = attributes[:'id']
98
+ end
99
+
100
+ if attributes.key?(:'polar_user')
101
+ self.polar_user = attributes[:'polar_user']
102
+ end
103
+
104
+ if attributes.key?(:'transaction_id')
105
+ self.transaction_id = attributes[:'transaction_id']
106
+ end
107
+
108
+ if attributes.key?(:'date')
109
+ self.date = attributes[:'date']
110
+ end
111
+
112
+ if attributes.key?(:'created')
113
+ self.created = attributes[:'created']
114
+ end
115
+
116
+ if attributes.key?(:'calories')
117
+ self.calories = attributes[:'calories']
118
+ end
119
+
120
+ if attributes.key?(:'active_calories')
121
+ self.active_calories = attributes[:'active_calories']
122
+ end
123
+
124
+ if attributes.key?(:'duration')
125
+ self.duration = attributes[:'duration']
126
+ end
127
+
128
+ if attributes.key?(:'active_steps')
129
+ self.active_steps = attributes[:'active_steps']
130
+ end
131
+ end
132
+
133
+ # Show invalid properties with the reasons. Usually used together with valid?
134
+ # @return Array for valid properties with the reasons
135
+ def list_invalid_properties
136
+ invalid_properties = Array.new
137
+ invalid_properties
138
+ end
139
+
140
+ # Check to see if the all the properties in the model are valid
141
+ # @return true if the model is valid
142
+ def valid?
143
+ true
144
+ end
145
+
146
+ # Checks equality by comparing each attribute.
147
+ # @param [Object] Object to be compared
148
+ def ==(o)
149
+ return true if self.equal?(o)
150
+ self.class == o.class &&
151
+ id == o.id &&
152
+ polar_user == o.polar_user &&
153
+ transaction_id == o.transaction_id &&
154
+ date == o.date &&
155
+ created == o.created &&
156
+ calories == o.calories &&
157
+ active_calories == o.active_calories &&
158
+ duration == o.duration &&
159
+ active_steps == o.active_steps
160
+ end
161
+
162
+ # @see the `==` method
163
+ # @param [Object] Object to be compared
164
+ def eql?(o)
165
+ self == o
166
+ end
167
+
168
+ # Calculates hash code according to all attributes.
169
+ # @return [Integer] Hash code
170
+ def hash
171
+ [id, polar_user, transaction_id, date, created, calories, active_calories, duration, active_steps].hash
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def self.build_from_hash(attributes)
178
+ new.build_from_hash(attributes)
179
+ end
180
+
181
+ # Builds the object from hash
182
+ # @param [Hash] attributes Model attributes in the form of hash
183
+ # @return [Object] Returns the model itself
184
+ def build_from_hash(attributes)
185
+ return nil unless attributes.is_a?(Hash)
186
+ self.class.openapi_types.each_pair do |key, type|
187
+ if type =~ /\AArray<(.*)>/i
188
+ # check to ensure the input is an array given that the attribute
189
+ # is documented as an array but the input is not
190
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
191
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
192
+ end
193
+ elsif !attributes[self.class.attribute_map[key]].nil?
194
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
195
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
196
+ end
197
+
198
+ self
199
+ end
200
+
201
+ # Deserializes the data based on type
202
+ # @param string type Data type
203
+ # @param string value Value to be deserialized
204
+ # @return [Object] Deserialized data
205
+ def _deserialize(type, value)
206
+ case type.to_sym
207
+ when :DateTime
208
+ DateTime.parse(value)
209
+ when :Date
210
+ Date.parse(value)
211
+ when :String
212
+ value.to_s
213
+ when :Integer
214
+ value.to_i
215
+ when :Float
216
+ value.to_f
217
+ when :Boolean
218
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
219
+ true
220
+ else
221
+ false
222
+ end
223
+ when :Object
224
+ # generic object (usually a Hash), return directly
225
+ value
226
+ when /\AArray<(?<inner_type>.+)>\z/
227
+ inner_type = Regexp.last_match[:inner_type]
228
+ value.map { |v| _deserialize(inner_type, v) }
229
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
230
+ k_type = Regexp.last_match[:k_type]
231
+ v_type = Regexp.last_match[:v_type]
232
+ {}.tap do |hash|
233
+ value.each do |k, v|
234
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
235
+ end
236
+ end
237
+ else # model
238
+ OpenapiClient.const_get(type).build_from_hash(value)
239
+ end
240
+ end
241
+
242
+ # Returns the string representation of the object
243
+ # @return [String] String presentation of the object
244
+ def to_s
245
+ to_hash.to_s
246
+ end
247
+
248
+ # to_body is an alias to to_hash (backward compatibility)
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_body
251
+ to_hash
252
+ end
253
+
254
+ # Returns the object in the form of hash
255
+ # @return [Hash] Returns the object in the form of hash
256
+ def to_hash
257
+ hash = {}
258
+ self.class.attribute_map.each_pair do |attr, param|
259
+ value = self.send(attr)
260
+ if value.nil?
261
+ is_nullable = self.class.openapi_nullable.include?(attr)
262
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
263
+ end
264
+
265
+ hash[param] = _to_hash(value)
266
+ end
267
+ hash
268
+ end
269
+
270
+ # Outputs non-array value in the form of hash
271
+ # For object, use to_hash. Otherwise, just return the value
272
+ # @param [Object] value Any valid value
273
+ # @return [Hash] Returns the value in the form of hash
274
+ def _to_hash(value)
275
+ if value.is_a?(Array)
276
+ value.compact.map { |v| _to_hash(v) }
277
+ elsif value.is_a?(Hash)
278
+ {}.tap do |hash|
279
+ value.each { |k, v| hash[k] = _to_hash(v) }
280
+ end
281
+ elsif value.respond_to? :to_hash
282
+ value.to_hash
283
+ else
284
+ value
285
+ end
286
+ end
287
+ end
288
+ 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
+ # Activity transaction container
17
+ class ActivityLog
18
+ # Absolute links to individual activity summaries within the transaction
19
+ attr_accessor :activity_log
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'activity_log' => :'activity-log'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'activity_log' => :'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::ActivityLog` 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::ActivityLog`. 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?(:'activity_log')
57
+ if (value = attributes[:'activity_log']).is_a?(Array)
58
+ self.activity_log = 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
+ activity_log == o.activity_log
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
+ [activity_log].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
@@ -0,0 +1,218 @@
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
+ # Model contains number of steps in certain time period.
17
+ class ActivityStepSample
18
+ # Number of steps in sample segment. If element is null, step samples are not available for current segment.
19
+ attr_accessor :steps
20
+
21
+ # Start time of sample segment.
22
+ attr_accessor :time
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'steps' => :'steps',
28
+ :'time' => :'time'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'steps' => :'Integer',
36
+ :'time' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslink::ActivityStepSample` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslink::ActivityStepSample`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'steps')
62
+ self.steps = attributes[:'steps']
63
+ end
64
+
65
+ if attributes.key?(:'time')
66
+ self.time = attributes[:'time']
67
+ end
68
+ end
69
+
70
+ # Show invalid properties with the reasons. Usually used together with valid?
71
+ # @return Array for valid properties with the reasons
72
+ def list_invalid_properties
73
+ invalid_properties = Array.new
74
+ invalid_properties
75
+ end
76
+
77
+ # Check to see if the all the properties in the model are valid
78
+ # @return true if the model is valid
79
+ def valid?
80
+ true
81
+ end
82
+
83
+ # Checks equality by comparing each attribute.
84
+ # @param [Object] Object to be compared
85
+ def ==(o)
86
+ return true if self.equal?(o)
87
+ self.class == o.class &&
88
+ steps == o.steps &&
89
+ time == o.time
90
+ end
91
+
92
+ # @see the `==` method
93
+ # @param [Object] Object to be compared
94
+ def eql?(o)
95
+ self == o
96
+ end
97
+
98
+ # Calculates hash code according to all attributes.
99
+ # @return [Integer] Hash code
100
+ def hash
101
+ [steps, time].hash
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def self.build_from_hash(attributes)
108
+ new.build_from_hash(attributes)
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ self.class.openapi_types.each_pair do |key, type|
117
+ if type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
121
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
122
+ end
123
+ elsif !attributes[self.class.attribute_map[key]].nil?
124
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
125
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
126
+ end
127
+
128
+ self
129
+ end
130
+
131
+ # Deserializes the data based on type
132
+ # @param string type Data type
133
+ # @param string value Value to be deserialized
134
+ # @return [Object] Deserialized data
135
+ def _deserialize(type, value)
136
+ case type.to_sym
137
+ when :DateTime
138
+ DateTime.parse(value)
139
+ when :Date
140
+ Date.parse(value)
141
+ when :String
142
+ value.to_s
143
+ when :Integer
144
+ value.to_i
145
+ when :Float
146
+ value.to_f
147
+ when :Boolean
148
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
149
+ true
150
+ else
151
+ false
152
+ end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ else # model
168
+ OpenapiClient.const_get(type).build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+ end
218
+ end