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,232 @@
|
|
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
|
+
# Model contains number of steps in certain time period.
|
18
|
+
class ActivityZoneSample
|
19
|
+
# List of heart rate zones with duration.
|
20
|
+
attr_accessor :activity_zones
|
21
|
+
|
22
|
+
# Start time of sample segment.
|
23
|
+
attr_accessor :time
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'activity_zones' => :'activity-zones',
|
29
|
+
:'time' => :'time'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'activity_zones' => :'Array<DurationZone>',
|
42
|
+
:'time' => :'String'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# List of attributes with nullable: true
|
47
|
+
def self.openapi_nullable
|
48
|
+
Set.new([
|
49
|
+
])
|
50
|
+
end
|
51
|
+
|
52
|
+
# Initializes the object
|
53
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
54
|
+
def initialize(attributes = {})
|
55
|
+
if (!attributes.is_a?(Hash))
|
56
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslinkApiGem::ActivityZoneSample` initialize method"
|
57
|
+
end
|
58
|
+
|
59
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
60
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
61
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
62
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslinkApiGem::ActivityZoneSample`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
63
|
+
end
|
64
|
+
h[k.to_sym] = v
|
65
|
+
}
|
66
|
+
|
67
|
+
if attributes.key?(:'activity_zones')
|
68
|
+
if (value = attributes[:'activity_zones']).is_a?(Array)
|
69
|
+
self.activity_zones = value
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.key?(:'time')
|
74
|
+
self.time = attributes[:'time']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
79
|
+
# @return Array for valid properties with the reasons
|
80
|
+
def list_invalid_properties
|
81
|
+
invalid_properties = Array.new
|
82
|
+
invalid_properties
|
83
|
+
end
|
84
|
+
|
85
|
+
# Check to see if the all the properties in the model are valid
|
86
|
+
# @return true if the model is valid
|
87
|
+
def valid?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
# Checks equality by comparing each attribute.
|
92
|
+
# @param [Object] Object to be compared
|
93
|
+
def ==(o)
|
94
|
+
return true if self.equal?(o)
|
95
|
+
self.class == o.class &&
|
96
|
+
activity_zones == o.activity_zones &&
|
97
|
+
time == o.time
|
98
|
+
end
|
99
|
+
|
100
|
+
# @see the `==` method
|
101
|
+
# @param [Object] Object to be compared
|
102
|
+
def eql?(o)
|
103
|
+
self == o
|
104
|
+
end
|
105
|
+
|
106
|
+
# Calculates hash code according to all attributes.
|
107
|
+
# @return [Integer] Hash code
|
108
|
+
def hash
|
109
|
+
[activity_zones, time].hash
|
110
|
+
end
|
111
|
+
|
112
|
+
# Builds the object from hash
|
113
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
114
|
+
# @return [Object] Returns the model itself
|
115
|
+
def self.build_from_hash(attributes)
|
116
|
+
new.build_from_hash(attributes)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Builds the object from hash
|
120
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
121
|
+
# @return [Object] Returns the model itself
|
122
|
+
def build_from_hash(attributes)
|
123
|
+
return nil unless attributes.is_a?(Hash)
|
124
|
+
self.class.openapi_types.each_pair do |key, type|
|
125
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
126
|
+
self.send("#{key}=", nil)
|
127
|
+
elsif type =~ /\AArray<(.*)>/i
|
128
|
+
# check to ensure the input is an array given that the attribute
|
129
|
+
# is documented as an array but the input is not
|
130
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
131
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
132
|
+
end
|
133
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
134
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
self
|
139
|
+
end
|
140
|
+
|
141
|
+
# Deserializes the data based on type
|
142
|
+
# @param string type Data type
|
143
|
+
# @param string value Value to be deserialized
|
144
|
+
# @return [Object] Deserialized data
|
145
|
+
def _deserialize(type, value)
|
146
|
+
case type.to_sym
|
147
|
+
when :Time
|
148
|
+
Time.parse(value)
|
149
|
+
when :Date
|
150
|
+
Date.parse(value)
|
151
|
+
when :String
|
152
|
+
value.to_s
|
153
|
+
when :Integer
|
154
|
+
value.to_i
|
155
|
+
when :Float
|
156
|
+
value.to_f
|
157
|
+
when :Boolean
|
158
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
159
|
+
true
|
160
|
+
else
|
161
|
+
false
|
162
|
+
end
|
163
|
+
when :Object
|
164
|
+
# generic object (usually a Hash), return directly
|
165
|
+
value
|
166
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
167
|
+
inner_type = Regexp.last_match[:inner_type]
|
168
|
+
value.map { |v| _deserialize(inner_type, v) }
|
169
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
170
|
+
k_type = Regexp.last_match[:k_type]
|
171
|
+
v_type = Regexp.last_match[:v_type]
|
172
|
+
{}.tap do |hash|
|
173
|
+
value.each do |k, v|
|
174
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
else # model
|
178
|
+
# models (e.g. Pet) or oneOf
|
179
|
+
klass = PolarAccesslinkApiGem.const_get(type)
|
180
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
# Returns the string representation of the object
|
185
|
+
# @return [String] String presentation of the object
|
186
|
+
def to_s
|
187
|
+
to_hash.to_s
|
188
|
+
end
|
189
|
+
|
190
|
+
# to_body is an alias to to_hash (backward compatibility)
|
191
|
+
# @return [Hash] Returns the object in the form of hash
|
192
|
+
def to_body
|
193
|
+
to_hash
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the object in the form of hash
|
197
|
+
# @return [Hash] Returns the object in the form of hash
|
198
|
+
def to_hash
|
199
|
+
hash = {}
|
200
|
+
self.class.attribute_map.each_pair do |attr, param|
|
201
|
+
value = self.send(attr)
|
202
|
+
if value.nil?
|
203
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
204
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
205
|
+
end
|
206
|
+
|
207
|
+
hash[param] = _to_hash(value)
|
208
|
+
end
|
209
|
+
hash
|
210
|
+
end
|
211
|
+
|
212
|
+
# Outputs non-array value in the form of hash
|
213
|
+
# For object, use to_hash. Otherwise, just return the value
|
214
|
+
# @param [Object] value Any valid value
|
215
|
+
# @return [Hash] Returns the value in the form of hash
|
216
|
+
def _to_hash(value)
|
217
|
+
if value.is_a?(Array)
|
218
|
+
value.compact.map { |v| _to_hash(v) }
|
219
|
+
elsif value.is_a?(Hash)
|
220
|
+
{}.tap do |hash|
|
221
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
222
|
+
end
|
223
|
+
elsif value.respond_to? :to_hash
|
224
|
+
value.to_hash
|
225
|
+
else
|
226
|
+
value
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
@@ -0,0 +1,232 @@
|
|
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 containing the times (in zone) in different heart rate zones (i.e. Heart rate between lower and upper values). Zone is null if no zone information available.
|
18
|
+
class ActivityZoneSamples
|
19
|
+
# Sample interval in minutes.
|
20
|
+
attr_accessor :interval
|
21
|
+
|
22
|
+
# List of individual zone sample objects.
|
23
|
+
attr_accessor :samples
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'interval' => :'interval',
|
29
|
+
:'samples' => :'samples'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'interval' => :'Integer',
|
42
|
+
:'samples' => :'Array<ActivityZoneSample>'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# List of attributes with nullable: true
|
47
|
+
def self.openapi_nullable
|
48
|
+
Set.new([
|
49
|
+
])
|
50
|
+
end
|
51
|
+
|
52
|
+
# Initializes the object
|
53
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
54
|
+
def initialize(attributes = {})
|
55
|
+
if (!attributes.is_a?(Hash))
|
56
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PolarAccesslinkApiGem::ActivityZoneSamples` initialize method"
|
57
|
+
end
|
58
|
+
|
59
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
60
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
61
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
62
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PolarAccesslinkApiGem::ActivityZoneSamples`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
63
|
+
end
|
64
|
+
h[k.to_sym] = v
|
65
|
+
}
|
66
|
+
|
67
|
+
if attributes.key?(:'interval')
|
68
|
+
self.interval = attributes[:'interval']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.key?(:'samples')
|
72
|
+
if (value = attributes[:'samples']).is_a?(Array)
|
73
|
+
self.samples = value
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
79
|
+
# @return Array for valid properties with the reasons
|
80
|
+
def list_invalid_properties
|
81
|
+
invalid_properties = Array.new
|
82
|
+
invalid_properties
|
83
|
+
end
|
84
|
+
|
85
|
+
# Check to see if the all the properties in the model are valid
|
86
|
+
# @return true if the model is valid
|
87
|
+
def valid?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
91
|
+
# Checks equality by comparing each attribute.
|
92
|
+
# @param [Object] Object to be compared
|
93
|
+
def ==(o)
|
94
|
+
return true if self.equal?(o)
|
95
|
+
self.class == o.class &&
|
96
|
+
interval == o.interval &&
|
97
|
+
samples == o.samples
|
98
|
+
end
|
99
|
+
|
100
|
+
# @see the `==` method
|
101
|
+
# @param [Object] Object to be compared
|
102
|
+
def eql?(o)
|
103
|
+
self == o
|
104
|
+
end
|
105
|
+
|
106
|
+
# Calculates hash code according to all attributes.
|
107
|
+
# @return [Integer] Hash code
|
108
|
+
def hash
|
109
|
+
[interval, samples].hash
|
110
|
+
end
|
111
|
+
|
112
|
+
# Builds the object from hash
|
113
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
114
|
+
# @return [Object] Returns the model itself
|
115
|
+
def self.build_from_hash(attributes)
|
116
|
+
new.build_from_hash(attributes)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Builds the object from hash
|
120
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
121
|
+
# @return [Object] Returns the model itself
|
122
|
+
def build_from_hash(attributes)
|
123
|
+
return nil unless attributes.is_a?(Hash)
|
124
|
+
self.class.openapi_types.each_pair do |key, type|
|
125
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
126
|
+
self.send("#{key}=", nil)
|
127
|
+
elsif type =~ /\AArray<(.*)>/i
|
128
|
+
# check to ensure the input is an array given that the attribute
|
129
|
+
# is documented as an array but the input is not
|
130
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
131
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
132
|
+
end
|
133
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
134
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
self
|
139
|
+
end
|
140
|
+
|
141
|
+
# Deserializes the data based on type
|
142
|
+
# @param string type Data type
|
143
|
+
# @param string value Value to be deserialized
|
144
|
+
# @return [Object] Deserialized data
|
145
|
+
def _deserialize(type, value)
|
146
|
+
case type.to_sym
|
147
|
+
when :Time
|
148
|
+
Time.parse(value)
|
149
|
+
when :Date
|
150
|
+
Date.parse(value)
|
151
|
+
when :String
|
152
|
+
value.to_s
|
153
|
+
when :Integer
|
154
|
+
value.to_i
|
155
|
+
when :Float
|
156
|
+
value.to_f
|
157
|
+
when :Boolean
|
158
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
159
|
+
true
|
160
|
+
else
|
161
|
+
false
|
162
|
+
end
|
163
|
+
when :Object
|
164
|
+
# generic object (usually a Hash), return directly
|
165
|
+
value
|
166
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
167
|
+
inner_type = Regexp.last_match[:inner_type]
|
168
|
+
value.map { |v| _deserialize(inner_type, v) }
|
169
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
170
|
+
k_type = Regexp.last_match[:k_type]
|
171
|
+
v_type = Regexp.last_match[:v_type]
|
172
|
+
{}.tap do |hash|
|
173
|
+
value.each do |k, v|
|
174
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
else # model
|
178
|
+
# models (e.g. Pet) or oneOf
|
179
|
+
klass = PolarAccesslinkApiGem.const_get(type)
|
180
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
# Returns the string representation of the object
|
185
|
+
# @return [String] String presentation of the object
|
186
|
+
def to_s
|
187
|
+
to_hash.to_s
|
188
|
+
end
|
189
|
+
|
190
|
+
# to_body is an alias to to_hash (backward compatibility)
|
191
|
+
# @return [Hash] Returns the object in the form of hash
|
192
|
+
def to_body
|
193
|
+
to_hash
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the object in the form of hash
|
197
|
+
# @return [Hash] Returns the object in the form of hash
|
198
|
+
def to_hash
|
199
|
+
hash = {}
|
200
|
+
self.class.attribute_map.each_pair do |attr, param|
|
201
|
+
value = self.send(attr)
|
202
|
+
if value.nil?
|
203
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
204
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
205
|
+
end
|
206
|
+
|
207
|
+
hash[param] = _to_hash(value)
|
208
|
+
end
|
209
|
+
hash
|
210
|
+
end
|
211
|
+
|
212
|
+
# Outputs non-array value in the form of hash
|
213
|
+
# For object, use to_hash. Otherwise, just return the value
|
214
|
+
# @param [Object] value Any valid value
|
215
|
+
# @return [Hash] Returns the value in the form of hash
|
216
|
+
def _to_hash(value)
|
217
|
+
if value.is_a?(Array)
|
218
|
+
value.compact.map { |v| _to_hash(v) }
|
219
|
+
elsif value.is_a?(Hash)
|
220
|
+
{}.tap do |hash|
|
221
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
222
|
+
end
|
223
|
+
elsif value.respond_to? :to_hash
|
224
|
+
value.to_hash
|
225
|
+
else
|
226
|
+
value
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|