polar-accesslink-api-gem 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,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
+ # Exercise transaction container
18
+ class Exercises
19
+ # Absolute links to individual exercises within the transaction
20
+ attr_accessor :exercises
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'exercises' => :'exercises'
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
+ :'exercises' => :'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::Exercises` 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::Exercises`. 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?(:'exercises')
63
+ if (value = attributes[:'exercises']).is_a?(Array)
64
+ self.exercises = 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
+ exercises == o.exercises
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
+ [exercises].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,230 @@
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
+ # Heart-rate statistics information
18
+ class HeartRate
19
+ # Average heart-rate
20
+ attr_accessor :average
21
+
22
+ # Maximum heart-rate
23
+ attr_accessor :maximum
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'average' => :'average',
29
+ :'maximum' => :'maximum'
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
+ :'average' => :'Integer',
42
+ :'maximum' => :'Integer'
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::HeartRate` 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::HeartRate`. 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?(:'average')
68
+ self.average = attributes[:'average']
69
+ end
70
+
71
+ if attributes.key?(:'maximum')
72
+ self.maximum = attributes[:'maximum']
73
+ end
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properties with the reasons
78
+ def list_invalid_properties
79
+ invalid_properties = Array.new
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ true
87
+ end
88
+
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
91
+ def ==(o)
92
+ return true if self.equal?(o)
93
+ self.class == o.class &&
94
+ average == o.average &&
95
+ maximum == o.maximum
96
+ end
97
+
98
+ # @see the `==` method
99
+ # @param [Object] Object to be compared
100
+ def eql?(o)
101
+ self == o
102
+ end
103
+
104
+ # Calculates hash code according to all attributes.
105
+ # @return [Integer] Hash code
106
+ def hash
107
+ [average, maximum].hash
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def self.build_from_hash(attributes)
114
+ new.build_from_hash(attributes)
115
+ end
116
+
117
+ # Builds the object from hash
118
+ # @param [Hash] attributes Model attributes in the form of hash
119
+ # @return [Object] Returns the model itself
120
+ def build_from_hash(attributes)
121
+ return nil unless attributes.is_a?(Hash)
122
+ self.class.openapi_types.each_pair do |key, type|
123
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
124
+ self.send("#{key}=", nil)
125
+ elsif type =~ /\AArray<(.*)>/i
126
+ # check to ensure the input is an array given that the attribute
127
+ # is documented as an array but the input is not
128
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
129
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
130
+ end
131
+ elsif !attributes[self.class.attribute_map[key]].nil?
132
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
133
+ end
134
+ end
135
+
136
+ self
137
+ end
138
+
139
+ # Deserializes the data based on type
140
+ # @param string type Data type
141
+ # @param string value Value to be deserialized
142
+ # @return [Object] Deserialized data
143
+ def _deserialize(type, value)
144
+ case type.to_sym
145
+ when :Time
146
+ Time.parse(value)
147
+ when :Date
148
+ Date.parse(value)
149
+ when :String
150
+ value.to_s
151
+ when :Integer
152
+ value.to_i
153
+ when :Float
154
+ value.to_f
155
+ when :Boolean
156
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
157
+ true
158
+ else
159
+ false
160
+ end
161
+ when :Object
162
+ # generic object (usually a Hash), return directly
163
+ value
164
+ when /\AArray<(?<inner_type>.+)>\z/
165
+ inner_type = Regexp.last_match[:inner_type]
166
+ value.map { |v| _deserialize(inner_type, v) }
167
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
168
+ k_type = Regexp.last_match[:k_type]
169
+ v_type = Regexp.last_match[:v_type]
170
+ {}.tap do |hash|
171
+ value.each do |k, v|
172
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
173
+ end
174
+ end
175
+ else # model
176
+ # models (e.g. Pet) or oneOf
177
+ klass = PolarAccesslinkApiGem.const_get(type)
178
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
179
+ end
180
+ end
181
+
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
184
+ def to_s
185
+ to_hash.to_s
186
+ end
187
+
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_body
191
+ to_hash
192
+ end
193
+
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_hash
197
+ hash = {}
198
+ self.class.attribute_map.each_pair do |attr, param|
199
+ value = self.send(attr)
200
+ if value.nil?
201
+ is_nullable = self.class.openapi_nullable.include?(attr)
202
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
203
+ end
204
+
205
+ hash[param] = _to_hash(value)
206
+ end
207
+ hash
208
+ end
209
+
210
+ # Outputs non-array value in the form of hash
211
+ # For object, use to_hash. Otherwise, just return the value
212
+ # @param [Object] value Any valid value
213
+ # @return [Hash] Returns the value in the form of hash
214
+ def _to_hash(value)
215
+ if value.is_a?(Array)
216
+ value.compact.map { |v| _to_hash(v) }
217
+ elsif value.is_a?(Hash)
218
+ {}.tap do |hash|
219
+ value.each { |k, v| hash[k] = _to_hash(v) }
220
+ end
221
+ elsif value.respond_to? :to_hash
222
+ value.to_hash
223
+ else
224
+ value
225
+ end
226
+ end
227
+
228
+ end
229
+
230
+ end