polar-accesslink-api-gem 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +182 -0
- data/Rakefile +10 -0
- data/docs/Activity.md +34 -0
- data/docs/ActivityLog.md +18 -0
- data/docs/ActivityStepSample.md +20 -0
- data/docs/ActivityStepSamples.md +20 -0
- data/docs/ActivityZoneSample.md +20 -0
- data/docs/ActivityZoneSamples.md +20 -0
- data/docs/AvailableSleep.md +22 -0
- data/docs/AvailableSleeps.md +18 -0
- data/docs/AvailableUserData.md +22 -0
- data/docs/AvailableUserDatas.md +18 -0
- data/docs/CreatedWebhook.md +18 -0
- data/docs/CreatedWebhookData.md +24 -0
- data/docs/DailyActivityApi.md +440 -0
- data/docs/DurationZone.md +20 -0
- data/docs/Error.md +26 -0
- data/docs/Exercise.md +54 -0
- data/docs/ExerciseHashId.md +52 -0
- data/docs/Exercises.md +18 -0
- data/docs/ExercisesApi.md +214 -0
- data/docs/HeartRate.md +20 -0
- data/docs/NightlyRecharge.md +38 -0
- data/docs/NightlyRechargeApi.md +144 -0
- data/docs/Nights.md +18 -0
- data/docs/PhysicalInfoApi.md +294 -0
- data/docs/PhysicalInformation.md +40 -0
- data/docs/PhysicalInformations.md +18 -0
- data/docs/PullNotificationsApi.md +75 -0
- data/docs/Recharges.md +18 -0
- data/docs/Register.md +18 -0
- data/docs/Sample.md +22 -0
- data/docs/Samples.md +18 -0
- data/docs/Sleep.md +64 -0
- data/docs/SleepApi.md +211 -0
- data/docs/TrainingDataApi.md +744 -0
- data/docs/TransactionLocation.md +20 -0
- data/docs/User.md +36 -0
- data/docs/UserExtraInfo.md +22 -0
- data/docs/UsersApi.md +216 -0
- data/docs/WebhookInfo.md +18 -0
- data/docs/WebhookInfoData.md +22 -0
- data/docs/WebhookPatch.md +20 -0
- data/docs/WebhookPayloadExercise.md +26 -0
- data/docs/WebhookPayloadSleep.md +26 -0
- data/docs/WebhookPing.md +20 -0
- data/docs/WebhookRequest.md +20 -0
- data/docs/WebhookType.md +15 -0
- data/docs/WebhooksApi.md +289 -0
- data/docs/Zone.md +24 -0
- data/docs/Zones.md +18 -0
- data/git_push.sh +58 -0
- data/lib/polar-accesslink-api-gem/api/daily_activity_api.rb +469 -0
- data/lib/polar-accesslink-api-gem/api/exercises_api.rb +205 -0
- data/lib/polar-accesslink-api-gem/api/nightly_recharge_api.rb +142 -0
- data/lib/polar-accesslink-api-gem/api/physical_info_api.rb +296 -0
- data/lib/polar-accesslink-api-gem/api/pull_notifications_api.rb +79 -0
- data/lib/polar-accesslink-api-gem/api/sleep_api.rb +199 -0
- data/lib/polar-accesslink-api-gem/api/training_data_api.rb +785 -0
- data/lib/polar-accesslink-api-gem/api/users_api.rb +221 -0
- data/lib/polar-accesslink-api-gem/api/webhooks_api.rb +278 -0
- data/lib/polar-accesslink-api-gem/api_client.rb +390 -0
- data/lib/polar-accesslink-api-gem/api_error.rb +57 -0
- data/lib/polar-accesslink-api-gem/configuration.rb +284 -0
- data/lib/polar-accesslink-api-gem/models/activity.rb +300 -0
- data/lib/polar-accesslink-api-gem/models/activity_log.rb +222 -0
- data/lib/polar-accesslink-api-gem/models/activity_step_sample.rb +230 -0
- data/lib/polar-accesslink-api-gem/models/activity_step_samples.rb +232 -0
- data/lib/polar-accesslink-api-gem/models/activity_zone_sample.rb +232 -0
- data/lib/polar-accesslink-api-gem/models/activity_zone_samples.rb +232 -0
- data/lib/polar-accesslink-api-gem/models/available_sleep.rb +239 -0
- data/lib/polar-accesslink-api-gem/models/available_sleeps.rb +221 -0
- data/lib/polar-accesslink-api-gem/models/available_user_data.rb +274 -0
- data/lib/polar-accesslink-api-gem/models/available_user_datas.rb +222 -0
- data/lib/polar-accesslink-api-gem/models/created_webhook.rb +218 -0
- data/lib/polar-accesslink-api-gem/models/created_webhook_data.rb +248 -0
- data/lib/polar-accesslink-api-gem/models/duration_zone.rb +230 -0
- data/lib/polar-accesslink-api-gem/models/error.rb +260 -0
- data/lib/polar-accesslink-api-gem/models/exercise.rb +399 -0
- data/lib/polar-accesslink-api-gem/models/exercise_hash_id.rb +389 -0
- data/lib/polar-accesslink-api-gem/models/exercises.rb +222 -0
- data/lib/polar-accesslink-api-gem/models/heart_rate.rb +230 -0
- data/lib/polar-accesslink-api-gem/models/nightly_recharge.rb +319 -0
- data/lib/polar-accesslink-api-gem/models/nights.rb +222 -0
- data/lib/polar-accesslink-api-gem/models/physical_information.rb +364 -0
- data/lib/polar-accesslink-api-gem/models/physical_informations.rb +222 -0
- data/lib/polar-accesslink-api-gem/models/recharges.rb +222 -0
- data/lib/polar-accesslink-api-gem/models/register.rb +225 -0
- data/lib/polar-accesslink-api-gem/models/sample.rb +240 -0
- data/lib/polar-accesslink-api-gem/models/samples.rb +222 -0
- data/lib/polar-accesslink-api-gem/models/sleep.rb +449 -0
- data/lib/polar-accesslink-api-gem/models/transaction_location.rb +230 -0
- data/lib/polar-accesslink-api-gem/models/user.rb +346 -0
- data/lib/polar-accesslink-api-gem/models/user_extra_info.rb +240 -0
- data/lib/polar-accesslink-api-gem/models/webhook_info.rb +218 -0
- data/lib/polar-accesslink-api-gem/models/webhook_info_data.rb +238 -0
- data/lib/polar-accesslink-api-gem/models/webhook_patch.rb +231 -0
- data/lib/polar-accesslink-api-gem/models/webhook_payload_exercise.rb +260 -0
- data/lib/polar-accesslink-api-gem/models/webhook_payload_sleep.rb +260 -0
- data/lib/polar-accesslink-api-gem/models/webhook_ping.rb +264 -0
- data/lib/polar-accesslink-api-gem/models/webhook_request.rb +241 -0
- data/lib/polar-accesslink-api-gem/models/webhook_type.rb +36 -0
- data/lib/polar-accesslink-api-gem/models/zone.rb +250 -0
- data/lib/polar-accesslink-api-gem/models/zones.rb +222 -0
- data/lib/polar-accesslink-api-gem/version.rb +15 -0
- data/lib/polar-accesslink-api-gem.rb +88 -0
- data/polar-accesslink-api-gem.gemspec +38 -0
- data/spec/api/daily_activity_api_spec.rb +114 -0
- data/spec/api/exercises_api_spec.rb +70 -0
- data/spec/api/nightly_recharge_api_spec.rb +58 -0
- data/spec/api/physical_info_api_spec.rb +87 -0
- data/spec/api/pull_notifications_api_spec.rb +46 -0
- data/spec/api/sleep_api_spec.rb +69 -0
- data/spec/api/training_data_api_spec.rb +173 -0
- data/spec/api/users_api_spec.rb +71 -0
- data/spec/api/webhooks_api_spec.rb +83 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/activity_log_spec.rb +34 -0
- data/spec/models/activity_spec.rb +82 -0
- data/spec/models/activity_step_sample_spec.rb +40 -0
- data/spec/models/activity_step_samples_spec.rb +40 -0
- data/spec/models/activity_zone_sample_spec.rb +40 -0
- data/spec/models/activity_zone_samples_spec.rb +40 -0
- data/spec/models/available_sleep_spec.rb +46 -0
- data/spec/models/available_sleeps_spec.rb +34 -0
- data/spec/models/available_user_data_spec.rb +50 -0
- data/spec/models/available_user_datas_spec.rb +34 -0
- data/spec/models/created_webhook_data_spec.rb +52 -0
- data/spec/models/created_webhook_spec.rb +34 -0
- data/spec/models/duration_zone_spec.rb +40 -0
- data/spec/models/error_spec.rb +58 -0
- data/spec/models/exercise_hash_id_spec.rb +136 -0
- data/spec/models/exercise_spec.rb +142 -0
- data/spec/models/exercises_spec.rb +34 -0
- data/spec/models/heart_rate_spec.rb +40 -0
- data/spec/models/nightly_recharge_spec.rb +94 -0
- data/spec/models/nights_spec.rb +34 -0
- data/spec/models/physical_information_spec.rb +104 -0
- data/spec/models/physical_informations_spec.rb +34 -0
- data/spec/models/recharges_spec.rb +34 -0
- data/spec/models/register_spec.rb +34 -0
- data/spec/models/sample_spec.rb +46 -0
- data/spec/models/samples_spec.rb +34 -0
- data/spec/models/sleep_spec.rb +172 -0
- data/spec/models/transaction_location_spec.rb +40 -0
- data/spec/models/user_extra_info_spec.rb +46 -0
- data/spec/models/user_spec.rb +92 -0
- data/spec/models/webhook_info_data_spec.rb +46 -0
- data/spec/models/webhook_info_spec.rb +34 -0
- data/spec/models/webhook_patch_spec.rb +40 -0
- data/spec/models/webhook_payload_exercise_spec.rb +58 -0
- data/spec/models/webhook_payload_sleep_spec.rb +58 -0
- data/spec/models/webhook_ping_spec.rb +44 -0
- data/spec/models/webhook_request_spec.rb +40 -0
- data/spec/models/webhook_type_spec.rb +28 -0
- data/spec/models/zone_spec.rb +52 -0
- data/spec/models/zones_spec.rb +34 -0
- data/spec/spec_helper.rb +111 -0
- metadata +295 -0
@@ -0,0 +1,222 @@
|
|
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
|
+
# List of URIs pointing to single sample type data.
|
18
|
+
class Samples
|
19
|
+
# List of URIs pointing to single sample type data.
|
20
|
+
attr_accessor :sample
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'sample' => :'sample'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns all the JSON keys this model knows about
|
30
|
+
def self.acceptable_attributes
|
31
|
+
attribute_map.values
|
32
|
+
end
|
33
|
+
|
34
|
+
# Attribute type mapping.
|
35
|
+
def self.openapi_types
|
36
|
+
{
|
37
|
+
:'sample' => :'Array<String>'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# List of attributes with nullable: true
|
42
|
+
def self.openapi_nullable
|
43
|
+
Set.new([
|
44
|
+
])
|
45
|
+
end
|
46
|
+
|
47
|
+
# Initializes the object
|
48
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
49
|
+
def initialize(attributes = {})
|
50
|
+
if (!attributes.is_a?(Hash))
|
51
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslinkApiGem::Samples` initialize method"
|
52
|
+
end
|
53
|
+
|
54
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
55
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
56
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
57
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslinkApiGem::Samples`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
58
|
+
end
|
59
|
+
h[k.to_sym] = v
|
60
|
+
}
|
61
|
+
|
62
|
+
if attributes.key?(:'sample')
|
63
|
+
if (value = attributes[:'sample']).is_a?(Array)
|
64
|
+
self.sample = value
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
70
|
+
# @return Array for valid properties with the reasons
|
71
|
+
def list_invalid_properties
|
72
|
+
invalid_properties = Array.new
|
73
|
+
invalid_properties
|
74
|
+
end
|
75
|
+
|
76
|
+
# Check to see if the all the properties in the model are valid
|
77
|
+
# @return true if the model is valid
|
78
|
+
def valid?
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
# Checks equality by comparing each attribute.
|
83
|
+
# @param [Object] Object to be compared
|
84
|
+
def ==(o)
|
85
|
+
return true if self.equal?(o)
|
86
|
+
self.class == o.class &&
|
87
|
+
sample == o.sample
|
88
|
+
end
|
89
|
+
|
90
|
+
# @see the `==` method
|
91
|
+
# @param [Object] Object to be compared
|
92
|
+
def eql?(o)
|
93
|
+
self == o
|
94
|
+
end
|
95
|
+
|
96
|
+
# Calculates hash code according to all attributes.
|
97
|
+
# @return [Integer] Hash code
|
98
|
+
def hash
|
99
|
+
[sample].hash
|
100
|
+
end
|
101
|
+
|
102
|
+
# Builds the object from hash
|
103
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
104
|
+
# @return [Object] Returns the model itself
|
105
|
+
def self.build_from_hash(attributes)
|
106
|
+
new.build_from_hash(attributes)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds the object from hash
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
# @return [Object] Returns the model itself
|
112
|
+
def build_from_hash(attributes)
|
113
|
+
return nil unless attributes.is_a?(Hash)
|
114
|
+
self.class.openapi_types.each_pair do |key, type|
|
115
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
116
|
+
self.send("#{key}=", nil)
|
117
|
+
elsif 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
|
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 :Time
|
138
|
+
Time.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
|
+
# models (e.g. Pet) or oneOf
|
169
|
+
klass = PolarAccesslinkApiGem.const_get(type)
|
170
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the string representation of the object
|
175
|
+
# @return [String] String presentation of the object
|
176
|
+
def to_s
|
177
|
+
to_hash.to_s
|
178
|
+
end
|
179
|
+
|
180
|
+
# to_body is an alias to to_hash (backward compatibility)
|
181
|
+
# @return [Hash] Returns the object in the form of hash
|
182
|
+
def to_body
|
183
|
+
to_hash
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns the object in the form of hash
|
187
|
+
# @return [Hash] Returns the object in the form of hash
|
188
|
+
def to_hash
|
189
|
+
hash = {}
|
190
|
+
self.class.attribute_map.each_pair do |attr, param|
|
191
|
+
value = self.send(attr)
|
192
|
+
if value.nil?
|
193
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
194
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
195
|
+
end
|
196
|
+
|
197
|
+
hash[param] = _to_hash(value)
|
198
|
+
end
|
199
|
+
hash
|
200
|
+
end
|
201
|
+
|
202
|
+
# Outputs non-array value in the form of hash
|
203
|
+
# For object, use to_hash. Otherwise, just return the value
|
204
|
+
# @param [Object] value Any valid value
|
205
|
+
# @return [Hash] Returns the value in the form of hash
|
206
|
+
def _to_hash(value)
|
207
|
+
if value.is_a?(Array)
|
208
|
+
value.compact.map { |v| _to_hash(v) }
|
209
|
+
elsif value.is_a?(Hash)
|
210
|
+
{}.tap do |hash|
|
211
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
212
|
+
end
|
213
|
+
elsif value.respond_to? :to_hash
|
214
|
+
value.to_hash
|
215
|
+
else
|
216
|
+
value
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
@@ -0,0 +1,449 @@
|
|
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
|
+
class Sleep
|
18
|
+
# Absolute link to user owning the sleep
|
19
|
+
attr_accessor :polar_user
|
20
|
+
|
21
|
+
# Result date of the sleep
|
22
|
+
attr_accessor :date
|
23
|
+
|
24
|
+
# Start timestamp of the sleep as ISO-8601 datetime string
|
25
|
+
attr_accessor :sleep_start_time
|
26
|
+
|
27
|
+
# End timestamp of the sleep as ISO-8601 datetime string
|
28
|
+
attr_accessor :sleep_end_time
|
29
|
+
|
30
|
+
# Id of the device the sleep was measured with
|
31
|
+
attr_accessor :device_id
|
32
|
+
|
33
|
+
# Continuity is an estimate of how continuous the sleep was on a scale of 1.0 – 5.0, where 5.0 reflects uninterrupted sleep. The lower the value the more fragmented the sleep was.
|
34
|
+
attr_accessor :continuity
|
35
|
+
|
36
|
+
# Verbal assessments of sleep continuity Very continuous sleep (5) Continuous sleep (4) Fairly continuous sleep (3) Fairly fragmented sleep (2) Fragmented sleep (1)
|
37
|
+
attr_accessor :continuity_class
|
38
|
+
|
39
|
+
# Total time in seconds spent in light sleep stage between when you fell asleep and when you woke up. Corresponds to N1+ N2 according to AASM classification.
|
40
|
+
attr_accessor :light_sleep
|
41
|
+
|
42
|
+
# Total time in seconds spent in the deep sleep stage between when you fell asleep and when you woke up. Corresponds to N3 according to AASM classification.
|
43
|
+
attr_accessor :deep_sleep
|
44
|
+
|
45
|
+
# Total time in seconds spent in REM sleep stage between when you fell asleep and when you woke up. REM stands for rapid eye movement.
|
46
|
+
attr_accessor :rem_sleep
|
47
|
+
|
48
|
+
# Total time in seconds spent in unrecognised sleep stage. Sometimes it's impossible to recognize sleep stages. This might happen when, for example, the wrist strap is not tight enough, or if you sleep on your hand.
|
49
|
+
attr_accessor :unrecognized_sleep_stage
|
50
|
+
|
51
|
+
# Sleep score summarizes the amount and quality of your sleep into a single number on a scale of 1 – 100. Sleep score tells you how well you slept compared to the indicators of a good night's sleep based on the current sleep science. It consists of six components; sleep time, long interruptions, continuity, actual sleep, REM sleep, and deep sleep.
|
52
|
+
attr_accessor :sleep_score
|
53
|
+
|
54
|
+
# The total time in seconds you spent awake between when you fell asleep and when you woke up.
|
55
|
+
attr_accessor :total_interruption_duration
|
56
|
+
|
57
|
+
# Sleep score compared to your usual level from the past 28 days.Scale: much below usual (1) – below usual (2) – usual (3) – above usual (4) – much above usual(5).
|
58
|
+
attr_accessor :sleep_charge
|
59
|
+
|
60
|
+
# Time goal in seconds for sleep selectedby user. A default value of the setting is based on age-related sleep duration recommendations.
|
61
|
+
attr_accessor :sleep_goal
|
62
|
+
|
63
|
+
# Numeric value given by user for representing the quality of sleep. Selection scale: Very poorly(1), poorly(2), ok(3), well(4), very well(5). 0 means no value is given.
|
64
|
+
attr_accessor :sleep_rating
|
65
|
+
|
66
|
+
# Total time in seconds of short interruptions. Short interruption is interruption in sleep of less than 90 seconds.
|
67
|
+
attr_accessor :short_interruption_duration
|
68
|
+
|
69
|
+
# Total time in seconds of long interruptions. Long interruption is interruption in sleep of 90 seconds or more.
|
70
|
+
attr_accessor :long_interruption_duration
|
71
|
+
|
72
|
+
# Number of sleep cycles.
|
73
|
+
attr_accessor :sleep_cycles
|
74
|
+
|
75
|
+
# Sleep score consists of six components that are grouped under three themes. Score for sleep duration theme looks at your sleep time compared to your ‘preferred sleep time’ setting and the age-related duration recommendations. Group duration score ranges from 1.0 to 100.0. It is interpreted as textual feedback: poor, moderate or good amount.
|
76
|
+
attr_accessor :group_duration_score
|
77
|
+
|
78
|
+
# Sleep score consists of six components that are grouped under three themes. Score for sleep solidity theme is the average of the component scores of long interruptions, continuity and actual sleep. Group solidity score ranges from 1.0 to 100.0. It is interpreted as textual feedback: poor, moderate or good solidity.
|
79
|
+
attr_accessor :group_solidity_score
|
80
|
+
|
81
|
+
# Sleep score consists of six components that are grouped under three themes. Score for regeneration theme is the average of the scores of REM sleep and deep sleep. Group regeneration score ranges from 1.0 to 100.0. It is interpreted as textual feedback: poor, moderate or good regeneration
|
82
|
+
attr_accessor :group_regeneration_score
|
83
|
+
|
84
|
+
# The time span between when you fell asleep and when you woke up is classified into light, deep or REM sleep, or unrecognised or wake in 30-s epochs. 0 = WAKE, 1 = REM, 2 = LIGHTER NON-REM, 3 = LIGHT NON-REM, 4 = DEEP NON-REM, 5 = UNKNOWN (eg. due to bad skin contact). You can request access to this data at https://www.polar.com/en/science/polar-accesslink-api-extended-content
|
85
|
+
attr_accessor :hypnogram
|
86
|
+
|
87
|
+
# 5 min average samples of heart rate from the duration of the sleep. Default time between samples is 5 minutes. There may be periods with samples more often than every 5 minutes. Unit of samples is beats per minute (bpm). You can request access to this data at https://www.polar.com/en/science/polar-accesslink-api-extended-content
|
88
|
+
attr_accessor :heart_rate_samples
|
89
|
+
|
90
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
91
|
+
def self.attribute_map
|
92
|
+
{
|
93
|
+
:'polar_user' => :'polar_user',
|
94
|
+
:'date' => :'date',
|
95
|
+
:'sleep_start_time' => :'sleep_start_time',
|
96
|
+
:'sleep_end_time' => :'sleep_end_time',
|
97
|
+
:'device_id' => :'device_id',
|
98
|
+
:'continuity' => :'continuity',
|
99
|
+
:'continuity_class' => :'continuity_class',
|
100
|
+
:'light_sleep' => :'light_sleep',
|
101
|
+
:'deep_sleep' => :'deep_sleep',
|
102
|
+
:'rem_sleep' => :'rem_sleep',
|
103
|
+
:'unrecognized_sleep_stage' => :'unrecognized_sleep_stage',
|
104
|
+
:'sleep_score' => :'sleep_score',
|
105
|
+
:'total_interruption_duration' => :'total_interruption_duration',
|
106
|
+
:'sleep_charge' => :'sleep_charge',
|
107
|
+
:'sleep_goal' => :'sleep_goal',
|
108
|
+
:'sleep_rating' => :'sleep_rating',
|
109
|
+
:'short_interruption_duration' => :'short_interruption_duration',
|
110
|
+
:'long_interruption_duration' => :'long_interruption_duration',
|
111
|
+
:'sleep_cycles' => :'sleep_cycles',
|
112
|
+
:'group_duration_score' => :'group_duration_score',
|
113
|
+
:'group_solidity_score' => :'group_solidity_score',
|
114
|
+
:'group_regeneration_score' => :'group_regeneration_score',
|
115
|
+
:'hypnogram' => :'hypnogram',
|
116
|
+
:'heart_rate_samples' => :'heart_rate_samples'
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
# Returns all the JSON keys this model knows about
|
121
|
+
def self.acceptable_attributes
|
122
|
+
attribute_map.values
|
123
|
+
end
|
124
|
+
|
125
|
+
# Attribute type mapping.
|
126
|
+
def self.openapi_types
|
127
|
+
{
|
128
|
+
:'polar_user' => :'String',
|
129
|
+
:'date' => :'Date',
|
130
|
+
:'sleep_start_time' => :'Time',
|
131
|
+
:'sleep_end_time' => :'Time',
|
132
|
+
:'device_id' => :'String',
|
133
|
+
:'continuity' => :'Float',
|
134
|
+
:'continuity_class' => :'Integer',
|
135
|
+
:'light_sleep' => :'Integer',
|
136
|
+
:'deep_sleep' => :'Integer',
|
137
|
+
:'rem_sleep' => :'Integer',
|
138
|
+
:'unrecognized_sleep_stage' => :'Integer',
|
139
|
+
:'sleep_score' => :'Integer',
|
140
|
+
:'total_interruption_duration' => :'Integer',
|
141
|
+
:'sleep_charge' => :'Integer',
|
142
|
+
:'sleep_goal' => :'Integer',
|
143
|
+
:'sleep_rating' => :'Integer',
|
144
|
+
:'short_interruption_duration' => :'Integer',
|
145
|
+
:'long_interruption_duration' => :'Integer',
|
146
|
+
:'sleep_cycles' => :'Integer',
|
147
|
+
:'group_duration_score' => :'Float',
|
148
|
+
:'group_solidity_score' => :'Float',
|
149
|
+
:'group_regeneration_score' => :'Float',
|
150
|
+
:'hypnogram' => :'Object',
|
151
|
+
:'heart_rate_samples' => :'Object'
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
# List of attributes with nullable: true
|
156
|
+
def self.openapi_nullable
|
157
|
+
Set.new([
|
158
|
+
])
|
159
|
+
end
|
160
|
+
|
161
|
+
# Initializes the object
|
162
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
163
|
+
def initialize(attributes = {})
|
164
|
+
if (!attributes.is_a?(Hash))
|
165
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslinkApiGem::Sleep` initialize method"
|
166
|
+
end
|
167
|
+
|
168
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
169
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
170
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
171
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslinkApiGem::Sleep`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
172
|
+
end
|
173
|
+
h[k.to_sym] = v
|
174
|
+
}
|
175
|
+
|
176
|
+
if attributes.key?(:'polar_user')
|
177
|
+
self.polar_user = attributes[:'polar_user']
|
178
|
+
end
|
179
|
+
|
180
|
+
if attributes.key?(:'date')
|
181
|
+
self.date = attributes[:'date']
|
182
|
+
end
|
183
|
+
|
184
|
+
if attributes.key?(:'sleep_start_time')
|
185
|
+
self.sleep_start_time = attributes[:'sleep_start_time']
|
186
|
+
end
|
187
|
+
|
188
|
+
if attributes.key?(:'sleep_end_time')
|
189
|
+
self.sleep_end_time = attributes[:'sleep_end_time']
|
190
|
+
end
|
191
|
+
|
192
|
+
if attributes.key?(:'device_id')
|
193
|
+
self.device_id = attributes[:'device_id']
|
194
|
+
end
|
195
|
+
|
196
|
+
if attributes.key?(:'continuity')
|
197
|
+
self.continuity = attributes[:'continuity']
|
198
|
+
end
|
199
|
+
|
200
|
+
if attributes.key?(:'continuity_class')
|
201
|
+
self.continuity_class = attributes[:'continuity_class']
|
202
|
+
end
|
203
|
+
|
204
|
+
if attributes.key?(:'light_sleep')
|
205
|
+
self.light_sleep = attributes[:'light_sleep']
|
206
|
+
end
|
207
|
+
|
208
|
+
if attributes.key?(:'deep_sleep')
|
209
|
+
self.deep_sleep = attributes[:'deep_sleep']
|
210
|
+
end
|
211
|
+
|
212
|
+
if attributes.key?(:'rem_sleep')
|
213
|
+
self.rem_sleep = attributes[:'rem_sleep']
|
214
|
+
end
|
215
|
+
|
216
|
+
if attributes.key?(:'unrecognized_sleep_stage')
|
217
|
+
self.unrecognized_sleep_stage = attributes[:'unrecognized_sleep_stage']
|
218
|
+
end
|
219
|
+
|
220
|
+
if attributes.key?(:'sleep_score')
|
221
|
+
self.sleep_score = attributes[:'sleep_score']
|
222
|
+
end
|
223
|
+
|
224
|
+
if attributes.key?(:'total_interruption_duration')
|
225
|
+
self.total_interruption_duration = attributes[:'total_interruption_duration']
|
226
|
+
end
|
227
|
+
|
228
|
+
if attributes.key?(:'sleep_charge')
|
229
|
+
self.sleep_charge = attributes[:'sleep_charge']
|
230
|
+
end
|
231
|
+
|
232
|
+
if attributes.key?(:'sleep_goal')
|
233
|
+
self.sleep_goal = attributes[:'sleep_goal']
|
234
|
+
end
|
235
|
+
|
236
|
+
if attributes.key?(:'sleep_rating')
|
237
|
+
self.sleep_rating = attributes[:'sleep_rating']
|
238
|
+
end
|
239
|
+
|
240
|
+
if attributes.key?(:'short_interruption_duration')
|
241
|
+
self.short_interruption_duration = attributes[:'short_interruption_duration']
|
242
|
+
end
|
243
|
+
|
244
|
+
if attributes.key?(:'long_interruption_duration')
|
245
|
+
self.long_interruption_duration = attributes[:'long_interruption_duration']
|
246
|
+
end
|
247
|
+
|
248
|
+
if attributes.key?(:'sleep_cycles')
|
249
|
+
self.sleep_cycles = attributes[:'sleep_cycles']
|
250
|
+
end
|
251
|
+
|
252
|
+
if attributes.key?(:'group_duration_score')
|
253
|
+
self.group_duration_score = attributes[:'group_duration_score']
|
254
|
+
end
|
255
|
+
|
256
|
+
if attributes.key?(:'group_solidity_score')
|
257
|
+
self.group_solidity_score = attributes[:'group_solidity_score']
|
258
|
+
end
|
259
|
+
|
260
|
+
if attributes.key?(:'group_regeneration_score')
|
261
|
+
self.group_regeneration_score = attributes[:'group_regeneration_score']
|
262
|
+
end
|
263
|
+
|
264
|
+
if attributes.key?(:'hypnogram')
|
265
|
+
self.hypnogram = attributes[:'hypnogram']
|
266
|
+
end
|
267
|
+
|
268
|
+
if attributes.key?(:'heart_rate_samples')
|
269
|
+
self.heart_rate_samples = attributes[:'heart_rate_samples']
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
274
|
+
# @return Array for valid properties with the reasons
|
275
|
+
def list_invalid_properties
|
276
|
+
invalid_properties = Array.new
|
277
|
+
invalid_properties
|
278
|
+
end
|
279
|
+
|
280
|
+
# Check to see if the all the properties in the model are valid
|
281
|
+
# @return true if the model is valid
|
282
|
+
def valid?
|
283
|
+
true
|
284
|
+
end
|
285
|
+
|
286
|
+
# Checks equality by comparing each attribute.
|
287
|
+
# @param [Object] Object to be compared
|
288
|
+
def ==(o)
|
289
|
+
return true if self.equal?(o)
|
290
|
+
self.class == o.class &&
|
291
|
+
polar_user == o.polar_user &&
|
292
|
+
date == o.date &&
|
293
|
+
sleep_start_time == o.sleep_start_time &&
|
294
|
+
sleep_end_time == o.sleep_end_time &&
|
295
|
+
device_id == o.device_id &&
|
296
|
+
continuity == o.continuity &&
|
297
|
+
continuity_class == o.continuity_class &&
|
298
|
+
light_sleep == o.light_sleep &&
|
299
|
+
deep_sleep == o.deep_sleep &&
|
300
|
+
rem_sleep == o.rem_sleep &&
|
301
|
+
unrecognized_sleep_stage == o.unrecognized_sleep_stage &&
|
302
|
+
sleep_score == o.sleep_score &&
|
303
|
+
total_interruption_duration == o.total_interruption_duration &&
|
304
|
+
sleep_charge == o.sleep_charge &&
|
305
|
+
sleep_goal == o.sleep_goal &&
|
306
|
+
sleep_rating == o.sleep_rating &&
|
307
|
+
short_interruption_duration == o.short_interruption_duration &&
|
308
|
+
long_interruption_duration == o.long_interruption_duration &&
|
309
|
+
sleep_cycles == o.sleep_cycles &&
|
310
|
+
group_duration_score == o.group_duration_score &&
|
311
|
+
group_solidity_score == o.group_solidity_score &&
|
312
|
+
group_regeneration_score == o.group_regeneration_score &&
|
313
|
+
hypnogram == o.hypnogram &&
|
314
|
+
heart_rate_samples == o.heart_rate_samples
|
315
|
+
end
|
316
|
+
|
317
|
+
# @see the `==` method
|
318
|
+
# @param [Object] Object to be compared
|
319
|
+
def eql?(o)
|
320
|
+
self == o
|
321
|
+
end
|
322
|
+
|
323
|
+
# Calculates hash code according to all attributes.
|
324
|
+
# @return [Integer] Hash code
|
325
|
+
def hash
|
326
|
+
[polar_user, date, sleep_start_time, sleep_end_time, device_id, continuity, continuity_class, light_sleep, deep_sleep, rem_sleep, unrecognized_sleep_stage, sleep_score, total_interruption_duration, sleep_charge, sleep_goal, sleep_rating, short_interruption_duration, long_interruption_duration, sleep_cycles, group_duration_score, group_solidity_score, group_regeneration_score, hypnogram, heart_rate_samples].hash
|
327
|
+
end
|
328
|
+
|
329
|
+
# Builds the object from hash
|
330
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
331
|
+
# @return [Object] Returns the model itself
|
332
|
+
def self.build_from_hash(attributes)
|
333
|
+
new.build_from_hash(attributes)
|
334
|
+
end
|
335
|
+
|
336
|
+
# Builds the object from hash
|
337
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
338
|
+
# @return [Object] Returns the model itself
|
339
|
+
def build_from_hash(attributes)
|
340
|
+
return nil unless attributes.is_a?(Hash)
|
341
|
+
self.class.openapi_types.each_pair do |key, type|
|
342
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
343
|
+
self.send("#{key}=", nil)
|
344
|
+
elsif type =~ /\AArray<(.*)>/i
|
345
|
+
# check to ensure the input is an array given that the attribute
|
346
|
+
# is documented as an array but the input is not
|
347
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
348
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
349
|
+
end
|
350
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
351
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
self
|
356
|
+
end
|
357
|
+
|
358
|
+
# Deserializes the data based on type
|
359
|
+
# @param string type Data type
|
360
|
+
# @param string value Value to be deserialized
|
361
|
+
# @return [Object] Deserialized data
|
362
|
+
def _deserialize(type, value)
|
363
|
+
case type.to_sym
|
364
|
+
when :Time
|
365
|
+
Time.parse(value)
|
366
|
+
when :Date
|
367
|
+
Date.parse(value)
|
368
|
+
when :String
|
369
|
+
value.to_s
|
370
|
+
when :Integer
|
371
|
+
value.to_i
|
372
|
+
when :Float
|
373
|
+
value.to_f
|
374
|
+
when :Boolean
|
375
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
376
|
+
true
|
377
|
+
else
|
378
|
+
false
|
379
|
+
end
|
380
|
+
when :Object
|
381
|
+
# generic object (usually a Hash), return directly
|
382
|
+
value
|
383
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
384
|
+
inner_type = Regexp.last_match[:inner_type]
|
385
|
+
value.map { |v| _deserialize(inner_type, v) }
|
386
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
387
|
+
k_type = Regexp.last_match[:k_type]
|
388
|
+
v_type = Regexp.last_match[:v_type]
|
389
|
+
{}.tap do |hash|
|
390
|
+
value.each do |k, v|
|
391
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
else # model
|
395
|
+
# models (e.g. Pet) or oneOf
|
396
|
+
klass = PolarAccesslinkApiGem.const_get(type)
|
397
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
# Returns the string representation of the object
|
402
|
+
# @return [String] String presentation of the object
|
403
|
+
def to_s
|
404
|
+
to_hash.to_s
|
405
|
+
end
|
406
|
+
|
407
|
+
# to_body is an alias to to_hash (backward compatibility)
|
408
|
+
# @return [Hash] Returns the object in the form of hash
|
409
|
+
def to_body
|
410
|
+
to_hash
|
411
|
+
end
|
412
|
+
|
413
|
+
# Returns the object in the form of hash
|
414
|
+
# @return [Hash] Returns the object in the form of hash
|
415
|
+
def to_hash
|
416
|
+
hash = {}
|
417
|
+
self.class.attribute_map.each_pair do |attr, param|
|
418
|
+
value = self.send(attr)
|
419
|
+
if value.nil?
|
420
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
421
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
422
|
+
end
|
423
|
+
|
424
|
+
hash[param] = _to_hash(value)
|
425
|
+
end
|
426
|
+
hash
|
427
|
+
end
|
428
|
+
|
429
|
+
# Outputs non-array value in the form of hash
|
430
|
+
# For object, use to_hash. Otherwise, just return the value
|
431
|
+
# @param [Object] value Any valid value
|
432
|
+
# @return [Hash] Returns the value in the form of hash
|
433
|
+
def _to_hash(value)
|
434
|
+
if value.is_a?(Array)
|
435
|
+
value.compact.map { |v| _to_hash(v) }
|
436
|
+
elsif value.is_a?(Hash)
|
437
|
+
{}.tap do |hash|
|
438
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
439
|
+
end
|
440
|
+
elsif value.respond_to? :to_hash
|
441
|
+
value.to_hash
|
442
|
+
else
|
443
|
+
value
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
end
|
448
|
+
|
449
|
+
end
|