polar_accesslink 1.0.2 → 1.0.3

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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +9 -5
  3. data/README.md +20 -65
  4. data/Rakefile +0 -2
  5. data/docs/DailyActivityApi.md +96 -123
  6. data/docs/ExercisesApi.md +35 -55
  7. data/docs/NightlyRechargeApi.md +96 -0
  8. data/docs/PhysicalInfoApi.md +60 -79
  9. data/docs/PullNotificationsApi.md +11 -20
  10. data/docs/SleepApi.md +137 -0
  11. data/docs/TrainingDataApi.md +175 -213
  12. data/docs/UsersApi.md +33 -56
  13. data/docs/WebhooksApi.md +43 -80
  14. data/git_push.sh +55 -0
  15. data/lib/polar_accesslink.rb +5 -36
  16. data/lib/polar_accesslink/api/daily_activity_api.rb +101 -201
  17. data/lib/polar_accesslink/api/exercises_api.rb +43 -81
  18. data/lib/polar_accesslink/api/nightly_recharge_api.rb +115 -0
  19. data/lib/polar_accesslink/api/physical_info_api.rb +65 -114
  20. data/lib/polar_accesslink/api/pull_notifications_api.rb +15 -27
  21. data/lib/polar_accesslink/api/sleep_api.rb +158 -0
  22. data/lib/polar_accesslink/api/training_data_api.rb +178 -332
  23. data/lib/polar_accesslink/api/users_api.rb +42 -96
  24. data/lib/polar_accesslink/api/webhooks_api.rb +59 -126
  25. data/lib/polar_accesslink/api_client.rb +45 -41
  26. data/lib/polar_accesslink/api_error.rb +3 -22
  27. data/lib/polar_accesslink/configuration.rb +9 -62
  28. data/lib/polar_accesslink/version.rb +3 -3
  29. data/polar_accesslink.gemspec +2 -1
  30. data/spec/api/daily_activity_api_spec.rb +11 -11
  31. data/spec/api/exercises_api_spec.rb +9 -9
  32. data/spec/api/nightly_recharge_api_spec.rb +58 -0
  33. data/spec/api/physical_info_api_spec.rb +9 -9
  34. data/spec/api/pull_notifications_api_spec.rb +7 -7
  35. data/spec/api/sleep_api_spec.rb +69 -0
  36. data/spec/api/training_data_api_spec.rb +16 -15
  37. data/spec/api/users_api_spec.rb +8 -9
  38. data/spec/api/webhooks_api_spec.rb +11 -13
  39. data/spec/api_client_spec.rb +21 -4
  40. data/spec/configuration_spec.rb +6 -6
  41. data/spec/spec_helper.rb +3 -3
  42. metadata +36 -145
  43. data/docs/Activity.md +0 -33
  44. data/docs/ActivityLog.md +0 -17
  45. data/docs/ActivityStepSample.md +0 -19
  46. data/docs/ActivityStepSamples.md +0 -19
  47. data/docs/ActivityZoneSample.md +0 -19
  48. data/docs/ActivityZoneSamples.md +0 -19
  49. data/docs/AvailableUserData.md +0 -21
  50. data/docs/AvailableUserDatas.md +0 -17
  51. data/docs/CreatedWebhook.md +0 -17
  52. data/docs/CreatedWebhookData.md +0 -23
  53. data/docs/DurationZone.md +0 -19
  54. data/docs/Error.md +0 -25
  55. data/docs/Exercise.md +0 -47
  56. data/docs/ExerciseHashId.md +0 -45
  57. data/docs/Exercises.md +0 -17
  58. data/docs/HeartRate.md +0 -19
  59. data/docs/PhysicalInformation.md +0 -39
  60. data/docs/PhysicalInformations.md +0 -17
  61. data/docs/Register.md +0 -17
  62. data/docs/Sample.md +0 -21
  63. data/docs/Samples.md +0 -17
  64. data/docs/TransactionLocation.md +0 -19
  65. data/docs/User.md +0 -35
  66. data/docs/UserExtraInfo.md +0 -21
  67. data/docs/WebhookInfo.md +0 -17
  68. data/docs/WebhookInfoData.md +0 -21
  69. data/docs/WebhookPatch.md +0 -19
  70. data/docs/WebhookPayload.md +0 -25
  71. data/docs/WebhookPing.md +0 -19
  72. data/docs/WebhookRequest.md +0 -19
  73. data/docs/WebhookType.md +0 -16
  74. data/docs/Zone.md +0 -23
  75. data/docs/Zones.md +0 -17
  76. data/lib/polar_accesslink/models/activity.rb +0 -288
  77. data/lib/polar_accesslink/models/activity_log.rb +0 -210
  78. data/lib/polar_accesslink/models/activity_step_sample.rb +0 -218
  79. data/lib/polar_accesslink/models/activity_step_samples.rb +0 -220
  80. data/lib/polar_accesslink/models/activity_zone_sample.rb +0 -220
  81. data/lib/polar_accesslink/models/activity_zone_samples.rb +0 -220
  82. data/lib/polar_accesslink/models/available_user_data.rb +0 -262
  83. data/lib/polar_accesslink/models/available_user_datas.rb +0 -210
  84. data/lib/polar_accesslink/models/created_webhook.rb +0 -206
  85. data/lib/polar_accesslink/models/created_webhook_data.rb +0 -236
  86. data/lib/polar_accesslink/models/duration_zone.rb +0 -218
  87. data/lib/polar_accesslink/models/error.rb +0 -248
  88. data/lib/polar_accesslink/models/exercise.rb +0 -357
  89. data/lib/polar_accesslink/models/exercise_hash_id.rb +0 -347
  90. data/lib/polar_accesslink/models/exercises.rb +0 -210
  91. data/lib/polar_accesslink/models/heart_rate.rb +0 -218
  92. data/lib/polar_accesslink/models/physical_information.rb +0 -352
  93. data/lib/polar_accesslink/models/physical_informations.rb +0 -210
  94. data/lib/polar_accesslink/models/register.rb +0 -213
  95. data/lib/polar_accesslink/models/sample.rb +0 -228
  96. data/lib/polar_accesslink/models/samples.rb +0 -210
  97. data/lib/polar_accesslink/models/transaction_location.rb +0 -218
  98. data/lib/polar_accesslink/models/user.rb +0 -334
  99. data/lib/polar_accesslink/models/user_extra_info.rb +0 -228
  100. data/lib/polar_accesslink/models/webhook_info.rb +0 -206
  101. data/lib/polar_accesslink/models/webhook_info_data.rb +0 -226
  102. data/lib/polar_accesslink/models/webhook_patch.rb +0 -219
  103. data/lib/polar_accesslink/models/webhook_payload.rb +0 -246
  104. data/lib/polar_accesslink/models/webhook_ping.rb +0 -252
  105. data/lib/polar_accesslink/models/webhook_request.rb +0 -229
  106. data/lib/polar_accesslink/models/webhook_type.rb +0 -37
  107. data/lib/polar_accesslink/models/zone.rb +0 -238
  108. data/lib/polar_accesslink/models/zones.rb +0 -210
  109. data/spec/models/activity_log_spec.rb +0 -41
  110. data/spec/models/activity_spec.rb +0 -89
  111. data/spec/models/activity_step_sample_spec.rb +0 -47
  112. data/spec/models/activity_step_samples_spec.rb +0 -47
  113. data/spec/models/activity_zone_sample_spec.rb +0 -47
  114. data/spec/models/activity_zone_samples_spec.rb +0 -47
  115. data/spec/models/available_user_data_spec.rb +0 -57
  116. data/spec/models/available_user_datas_spec.rb +0 -41
  117. data/spec/models/created_webhook_data_spec.rb +0 -59
  118. data/spec/models/created_webhook_spec.rb +0 -41
  119. data/spec/models/duration_zone_spec.rb +0 -47
  120. data/spec/models/error_spec.rb +0 -65
  121. data/spec/models/exercise_hash_id_spec.rb +0 -125
  122. data/spec/models/exercise_spec.rb +0 -131
  123. data/spec/models/exercises_spec.rb +0 -41
  124. data/spec/models/heart_rate_spec.rb +0 -47
  125. data/spec/models/physical_information_spec.rb +0 -111
  126. data/spec/models/physical_informations_spec.rb +0 -41
  127. data/spec/models/register_spec.rb +0 -41
  128. data/spec/models/sample_spec.rb +0 -53
  129. data/spec/models/samples_spec.rb +0 -41
  130. data/spec/models/transaction_location_spec.rb +0 -47
  131. data/spec/models/user_extra_info_spec.rb +0 -53
  132. data/spec/models/user_spec.rb +0 -99
  133. data/spec/models/webhook_info_data_spec.rb +0 -53
  134. data/spec/models/webhook_info_spec.rb +0 -41
  135. data/spec/models/webhook_patch_spec.rb +0 -47
  136. data/spec/models/webhook_payload_spec.rb +0 -65
  137. data/spec/models/webhook_ping_spec.rb +0 -51
  138. data/spec/models/webhook_request_spec.rb +0 -47
  139. data/spec/models/webhook_type_spec.rb +0 -35
  140. data/spec/models/zone_spec.rb +0 -59
  141. data/spec/models/zones_spec.rb +0 -41
@@ -1,19 +0,0 @@
1
- # PolarAccesslink::TransactionLocation
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **transaction_id** | **Integer** | Id of the created transaction | [optional]
8
- **resource_uri** | **String** | Absolute links to the created transaction | [optional]
9
-
10
- ## Code Sample
11
-
12
- ```ruby
13
- require 'OpenapiClient'
14
-
15
- instance = PolarAccesslink::TransactionLocation.new(transaction_id: 122,
16
- resource_uri: https://polaraccesslink.com/v3/users/21/physical-information-transactions/32)
17
- ```
18
-
19
-
@@ -1,35 +0,0 @@
1
- # PolarAccesslink::User
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **polar_user_id** | **Integer** | User's id in Polar database | [optional]
8
- **member_id** | **String** | User's identifier in partner's database | [optional]
9
- **registration_date** | **DateTime** | Timestamp marked when ACCEPTED | [optional]
10
- **first_name** | **String** | User's first name | [optional]
11
- **last_name** | **String** | User's surname | [optional]
12
- **birthdate** | **String** | User's birthdate as YYYY-MM-DD | [optional]
13
- **gender** | **String** | User's sex | [optional]
14
- **weight** | **Float** | User's weight in kg | [optional]
15
- **height** | **Float** | Users height in centimeters | [optional]
16
- **field** | [**Array<UserExtraInfo>**](UserExtraInfo.md) | List containing answers given by the user to a number of partner-specific questions. Extra-info is null if there are no required fields defined by the partner. | [optional]
17
-
18
- ## Code Sample
19
-
20
- ```ruby
21
- require 'OpenapiClient'
22
-
23
- instance = PolarAccesslink::User.new(polar_user_id: 2278512,
24
- member_id: i09u9ujj,
25
- registration_date: 2011-10-14T12:50:37Z,
26
- first_name: Eka,
27
- last_name: Toka,
28
- birthdate: 1985-09-06T00:00:00.000Z,
29
- gender: MALE,
30
- weight: 66,
31
- height: 170,
32
- field: null)
33
- ```
34
-
35
-
@@ -1,21 +0,0 @@
1
- # PolarAccesslink::UserExtraInfo
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **value** | **String** | Value provided by the customer | [optional]
8
- **index** | **Integer** | Item index | [optional]
9
- **name** | **String** | Name of the extra info asked from customer | [optional]
10
-
11
- ## Code Sample
12
-
13
- ```ruby
14
- require 'OpenapiClient'
15
-
16
- instance = PolarAccesslink::UserExtraInfo.new(value: 2,
17
- index: 0,
18
- name: number-of-children)
19
- ```
20
-
21
-
@@ -1,17 +0,0 @@
1
- # PolarAccesslink::WebhookInfo
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **data** | [**WebhookInfoData**](WebhookInfoData.md) | | [optional]
8
-
9
- ## Code Sample
10
-
11
- ```ruby
12
- require 'OpenapiClient'
13
-
14
- instance = PolarAccesslink::WebhookInfo.new(data: null)
15
- ```
16
-
17
-
@@ -1,21 +0,0 @@
1
- # PolarAccesslink::WebhookInfoData
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **id** | **String** | Id of the webhook. | [optional]
8
- **events** | [**WebhookType**](WebhookType.md) | | [optional]
9
- **url** | **String** | Url where the webhook notification is sent. | [optional]
10
-
11
- ## Code Sample
12
-
13
- ```ruby
14
- require 'OpenapiClient'
15
-
16
- instance = PolarAccesslink::WebhookInfoData.new(id: abdf33,
17
- events: null,
18
- url: https://myapp.example.com/acl_webhook)
19
- ```
20
-
21
-
@@ -1,19 +0,0 @@
1
- # PolarAccesslink::WebhookPatch
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **events** | [**Array<WebhookType>**](WebhookType.md) | Type of events to subscribe. | [optional]
8
- **url** | **String** | Url where the webhook notification is sent. | [optional]
9
-
10
- ## Code Sample
11
-
12
- ```ruby
13
- require 'OpenapiClient'
14
-
15
- instance = PolarAccesslink::WebhookPatch.new(events: ["EXERCISE","ACTIVITY_SUMMARY"],
16
- url: https://myapp.example.com/acl_webhook)
17
- ```
18
-
19
-
@@ -1,25 +0,0 @@
1
- # PolarAccesslink::WebhookPayload
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **event** | [**WebhookType**](WebhookType.md) | | [optional]
8
- **user_id** | **Integer** | Id of the user who has new data. | [optional]
9
- **entity_id** | **String** | Id of the available data. | [optional]
10
- **timestamp** | **DateTime** | Time when webhook notification is sent. | [optional]
11
- **url** | **String** | Url to the new available data. | [optional]
12
-
13
- ## Code Sample
14
-
15
- ```ruby
16
- require 'OpenapiClient'
17
-
18
- instance = PolarAccesslink::WebhookPayload.new(event: null,
19
- user_id: 475,
20
- entity_id: aQlC83,
21
- timestamp: 2018-05-15T14:22:24Z,
22
- url: https://www.polaraccesslink.com/v3/exercises/aQlC83)
23
- ```
24
-
25
-
@@ -1,19 +0,0 @@
1
- # PolarAccesslink::WebhookPing
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **timestamp** | **DateTime** | Time when webhook ping is sent. | [optional]
8
- **event** | **String** | Only possible value is PING for ping message. | [optional]
9
-
10
- ## Code Sample
11
-
12
- ```ruby
13
- require 'OpenapiClient'
14
-
15
- instance = PolarAccesslink::WebhookPing.new(timestamp: 2018-05-15T14:22:24Z,
16
- event: null)
17
- ```
18
-
19
-
@@ -1,19 +0,0 @@
1
- # PolarAccesslink::WebhookRequest
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **events** | [**Array<WebhookType>**](WebhookType.md) | Type of events to subscribe. |
8
- **url** | **String** | Url where the webhook notification is sent. |
9
-
10
- ## Code Sample
11
-
12
- ```ruby
13
- require 'OpenapiClient'
14
-
15
- instance = PolarAccesslink::WebhookRequest.new(events: ["EXERCISE","ACTIVITY_SUMMARY"],
16
- url: https://myapp.example.com/acl_webhook)
17
- ```
18
-
19
-
@@ -1,16 +0,0 @@
1
- # PolarAccesslink::WebhookType
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
-
8
- ## Code Sample
9
-
10
- ```ruby
11
- require 'OpenapiClient'
12
-
13
- instance = PolarAccesslink::WebhookType.new()
14
- ```
15
-
16
-
@@ -1,23 +0,0 @@
1
- # PolarAccesslink::Zone
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **index** | **Integer** | Zone list index | [optional]
8
- **lower_limit** | **Integer** | Lower heart-rate boundary of the zone | [optional]
9
- **upper_limit** | **Integer** | Upper heart-rate boundary of the zone | [optional]
10
- **in_zone** | **String** | Time duration spent in the zone ISO 8601 | [optional]
11
-
12
- ## Code Sample
13
-
14
- ```ruby
15
- require 'OpenapiClient'
16
-
17
- instance = PolarAccesslink::Zone.new(index: 1,
18
- lower_limit: 110,
19
- upper_limit: 130,
20
- in_zone: PT4S)
21
- ```
22
-
23
-
@@ -1,17 +0,0 @@
1
- # PolarAccesslink::Zones
2
-
3
- ## Properties
4
-
5
- Name | Type | Description | Notes
6
- ------------ | ------------- | ------------- | -------------
7
- **zone** | [**Array<Zone>**](Zone.md) | List of heart rate zones. | [optional]
8
-
9
- ## Code Sample
10
-
11
- ```ruby
12
- require 'OpenapiClient'
13
-
14
- instance = PolarAccesslink::Zones.new(zone: null)
15
- ```
16
-
17
-
@@ -1,288 +0,0 @@
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
- PolarAccesslink.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