artikcloud 2.0.5 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +23 -1
  3. data/LICENSE +1 -2
  4. data/README.md +50 -4
  5. data/artikcloud.gemspec +29 -5
  6. data/docs/DeviceTask.md +13 -0
  7. data/docs/DeviceTaskUpdateRequest.md +8 -0
  8. data/docs/DeviceTaskUpdateResponse.md +8 -0
  9. data/docs/DeviceTypeInfo.md +14 -0
  10. data/docs/DeviceTypeInfoEnvelope.md +8 -0
  11. data/docs/DeviceTypesApi.md +61 -0
  12. data/docs/DeviceTypesInfo.md +14 -0
  13. data/docs/DeviceTypesInfoEnvelope.md +8 -0
  14. data/docs/DevicesManagementApi.md +870 -0
  15. data/docs/EventFeedData.md +10 -0
  16. data/docs/MetadataEnvelope.md +8 -0
  17. data/docs/MetadataPropertiesEnvelope.md +8 -0
  18. data/docs/MetadataQueryEnvelope.md +11 -0
  19. data/docs/MetadataRequest.md +7 -0
  20. data/docs/Task.md +18 -0
  21. data/docs/TaskByDid.md +19 -0
  22. data/docs/TaskByDidList.md +8 -0
  23. data/docs/TaskByDidListEnvelope.md +11 -0
  24. data/docs/TaskEnvelope.md +8 -0
  25. data/docs/TaskHistory.md +13 -0
  26. data/docs/TaskHistoryList.md +8 -0
  27. data/docs/TaskList.md +8 -0
  28. data/docs/TaskListEnvelope.md +12 -0
  29. data/docs/TaskParameters.md +9 -0
  30. data/docs/TaskRequest.md +13 -0
  31. data/docs/TaskStatus.md +13 -0
  32. data/docs/TaskStatusCounts.md +12 -0
  33. data/docs/TaskStatuses.md +19 -0
  34. data/docs/TaskStatusesEnvelope.md +11 -0
  35. data/docs/TaskStatusesHistoryEnvelope.md +8 -0
  36. data/docs/TaskUpdateRequest.md +8 -0
  37. data/docs/TaskUpdateResponse.md +8 -0
  38. data/docs/TasksStatusCounts.md +11 -0
  39. data/lib/artikcloud/api/device_types_api.rb +66 -0
  40. data/lib/artikcloud/api/devices_management_api.rb +971 -0
  41. data/lib/artikcloud/models/device_task.rb +250 -0
  42. data/lib/artikcloud/models/device_task_update_request.rb +200 -0
  43. data/lib/artikcloud/models/device_task_update_response.rb +200 -0
  44. data/lib/artikcloud/models/device_type_info.rb +260 -0
  45. data/lib/artikcloud/models/device_type_info_envelope.rb +199 -0
  46. data/lib/artikcloud/models/device_types_info.rb +260 -0
  47. data/lib/artikcloud/models/device_types_info_envelope.rb +199 -0
  48. data/lib/artikcloud/models/event_feed_data.rb +222 -0
  49. data/lib/artikcloud/models/metadata_envelope.rb +202 -0
  50. data/lib/artikcloud/models/metadata_properties_envelope.rb +201 -0
  51. data/lib/artikcloud/models/metadata_query_envelope.rb +232 -0
  52. data/lib/artikcloud/models/metadata_request.rb +190 -0
  53. data/lib/artikcloud/models/task.rb +302 -0
  54. data/lib/artikcloud/models/task_by_did.rb +314 -0
  55. data/lib/artikcloud/models/task_by_did_list.rb +202 -0
  56. data/lib/artikcloud/models/task_by_did_list_envelope.rb +230 -0
  57. data/lib/artikcloud/models/task_envelope.rb +200 -0
  58. data/lib/artikcloud/models/task_history.rb +250 -0
  59. data/lib/artikcloud/models/task_history_list.rb +202 -0
  60. data/lib/artikcloud/models/task_list.rb +202 -0
  61. data/lib/artikcloud/models/task_list_envelope.rb +240 -0
  62. data/lib/artikcloud/models/task_parameters.rb +210 -0
  63. data/lib/artikcloud/models/task_request.rb +252 -0
  64. data/lib/artikcloud/models/task_status.rb +250 -0
  65. data/lib/artikcloud/models/task_status_counts.rb +240 -0
  66. data/lib/artikcloud/models/task_statuses.rb +314 -0
  67. data/lib/artikcloud/models/task_statuses_envelope.rb +230 -0
  68. data/lib/artikcloud/models/task_statuses_history_envelope.rb +200 -0
  69. data/lib/artikcloud/models/task_update_request.rb +200 -0
  70. data/lib/artikcloud/models/task_update_response.rb +200 -0
  71. data/lib/artikcloud/models/tasks_status_counts.rb +230 -0
  72. data/lib/artikcloud/version.rb +1 -1
  73. data/lib/artikcloud.rb +31 -0
  74. data/pom.xml +1 -1
  75. data/spec/api/devices_api_spec.rb +7 -10
  76. data/spec/api/devices_management_api_spec.rb +251 -0
  77. data/spec/api/messages_api_spec.rb +67 -25
  78. data/spec/api/tokens_api_spec.rb +10 -33
  79. data/spec/api/users_api_spec.rb +65 -14
  80. data/spec/api_client_spec.rb +237 -0
  81. data/spec/configuration_spec.rb +53 -0
  82. data/spec/factories/devices.rb +32 -0
  83. data/spec/factories/users.rb +31 -0
  84. data/spec/fixtures/cassettes/DevicesApi/get_device_presence_test/should_work.yml +50 -0
  85. data/spec/fixtures/cassettes/MessagesApi/get_message_snapshots/should_work.yml +54 -0
  86. data/spec/fixtures/cassettes/MessagesApi/send_actions/should_work.yml +93 -0
  87. data/spec/fixtures/cassettes/MessagesApi/send_message_action_test/should_work.yml +99 -0
  88. data/spec/fixtures/cassettes/TokensApi/refresh_token_test/should_work.yml +43 -0
  89. data/spec/fixtures/cassettes/TokensApi/token_info_test/should_work.yml +38 -0
  90. data/spec/fixtures/cassettes/UsersApi/get_self_test/should_work.yml +53 -0
  91. data/spec/fixtures/cassettes/UsersApi/get_user_device_types_test/should_work.yml +55 -0
  92. data/spec/fixtures/cassettes/UsersApi/get_user_devices_test/should_work.yml +55 -0
  93. data/spec/fixtures/cassettes/UsersApi/get_user_properties_update_user_properties_and_delete_user_properties_test/should_work.yml +52 -0
  94. data/spec/fixtures/cassettes/UsersApi/get_user_rules_test/should_work.yml +58 -0
  95. data/spec/spec_helper.rb +20 -5
  96. metadata +142 -46
@@ -0,0 +1,202 @@
1
+ =begin
2
+ #ARTIK Cloud API
3
+
4
+ #No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module ArtikCloud
27
+ #
28
+ class TaskByDidList
29
+ # Task list
30
+ attr_accessor :tasks
31
+
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'tasks' => :'tasks'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'tasks' => :'Array<TaskByDid>'
44
+ }
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ return unless attributes.is_a?(Hash)
51
+
52
+ # convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
54
+
55
+ if attributes.has_key?(:'tasks')
56
+ if (value = attributes[:'tasks']).is_a?(Array)
57
+ self.tasks = value
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ # Show invalid properties with the reasons. Usually used together with valid?
64
+ # @return Array for valid properies with the reasons
65
+ def list_invalid_properties
66
+ invalid_properties = Array.new
67
+ return invalid_properties
68
+ end
69
+
70
+ # Check to see if the all the properties in the model are valid
71
+ # @return true if the model is valid
72
+ def valid?
73
+ return true
74
+ end
75
+
76
+ # Checks equality by comparing each attribute.
77
+ # @param [Object] Object to be compared
78
+ def ==(o)
79
+ return true if self.equal?(o)
80
+ self.class == o.class &&
81
+ tasks == o.tasks
82
+ end
83
+
84
+ # @see the `==` method
85
+ # @param [Object] Object to be compared
86
+ def eql?(o)
87
+ self == o
88
+ end
89
+
90
+ # Calculates hash code according to all attributes.
91
+ # @return [Fixnum] Hash code
92
+ def hash
93
+ [tasks].hash
94
+ end
95
+
96
+ # Builds the object from hash
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ # @return [Object] Returns the model itself
99
+ def build_from_hash(attributes)
100
+ return nil unless attributes.is_a?(Hash)
101
+ self.class.swagger_types.each_pair do |key, type|
102
+ if type =~ /^Array<(.*)>/i
103
+ # check to ensure the input is an array given that the the attribute
104
+ # is documented as an array but the input is not
105
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
106
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
107
+ end
108
+ elsif !attributes[self.class.attribute_map[key]].nil?
109
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
110
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
111
+ end
112
+
113
+ self
114
+ end
115
+
116
+ # Deserializes the data based on type
117
+ # @param string type Data type
118
+ # @param string value Value to be deserialized
119
+ # @return [Object] Deserialized data
120
+ def _deserialize(type, value)
121
+ case type.to_sym
122
+ when :DateTime
123
+ DateTime.parse(value)
124
+ when :Date
125
+ Date.parse(value)
126
+ when :String
127
+ value.to_s
128
+ when :Integer
129
+ value.to_i
130
+ when :Float
131
+ value.to_f
132
+ when :BOOLEAN
133
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
134
+ true
135
+ else
136
+ false
137
+ end
138
+ when :Object
139
+ # generic object (usually a Hash), return directly
140
+ value
141
+ when /\AArray<(?<inner_type>.+)>\z/
142
+ inner_type = Regexp.last_match[:inner_type]
143
+ value.map { |v| _deserialize(inner_type, v) }
144
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
145
+ k_type = Regexp.last_match[:k_type]
146
+ v_type = Regexp.last_match[:v_type]
147
+ {}.tap do |hash|
148
+ value.each do |k, v|
149
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
150
+ end
151
+ end
152
+ else # model
153
+ temp_model = ArtikCloud.const_get(type).new
154
+ temp_model.build_from_hash(value)
155
+ end
156
+ end
157
+
158
+ # Returns the string representation of the object
159
+ # @return [String] String presentation of the object
160
+ def to_s
161
+ to_hash.to_s
162
+ end
163
+
164
+ # to_body is an alias to to_hash (backward compatibility)
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_body
167
+ to_hash
168
+ end
169
+
170
+ # Returns the object in the form of hash
171
+ # @return [Hash] Returns the object in the form of hash
172
+ def to_hash
173
+ hash = {}
174
+ self.class.attribute_map.each_pair do |attr, param|
175
+ value = self.send(attr)
176
+ next if value.nil?
177
+ hash[param] = _to_hash(value)
178
+ end
179
+ hash
180
+ end
181
+
182
+ # Outputs non-array value in the form of hash
183
+ # For object, use to_hash. Otherwise, just return the value
184
+ # @param [Object] value Any valid value
185
+ # @return [Hash] Returns the value in the form of hash
186
+ def _to_hash(value)
187
+ if value.is_a?(Array)
188
+ value.compact.map{ |v| _to_hash(v) }
189
+ elsif value.is_a?(Hash)
190
+ {}.tap do |hash|
191
+ value.each { |k, v| hash[k] = _to_hash(v) }
192
+ end
193
+ elsif value.respond_to? :to_hash
194
+ value.to_hash
195
+ else
196
+ value
197
+ end
198
+ end
199
+
200
+ end
201
+
202
+ end
@@ -0,0 +1,230 @@
1
+ =begin
2
+ #ARTIK Cloud API
3
+
4
+ #No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module ArtikCloud
27
+ #
28
+ class TaskByDidListEnvelope
29
+ # Total number of tasks in list
30
+ attr_accessor :total
31
+
32
+ # Device task list envelope
33
+ attr_accessor :data
34
+
35
+ # Offset if using pagination
36
+ attr_accessor :offset
37
+
38
+ # Count for current result set
39
+ attr_accessor :count
40
+
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'total' => :'total',
46
+ :'data' => :'data',
47
+ :'offset' => :'offset',
48
+ :'count' => :'count'
49
+ }
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.swagger_types
54
+ {
55
+ :'total' => :'Integer',
56
+ :'data' => :'TaskByDidList',
57
+ :'offset' => :'Integer',
58
+ :'count' => :'Integer'
59
+ }
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ return unless attributes.is_a?(Hash)
66
+
67
+ # convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
69
+
70
+ if attributes.has_key?(:'total')
71
+ self.total = attributes[:'total']
72
+ end
73
+
74
+ if attributes.has_key?(:'data')
75
+ self.data = attributes[:'data']
76
+ end
77
+
78
+ if attributes.has_key?(:'offset')
79
+ self.offset = attributes[:'offset']
80
+ end
81
+
82
+ if attributes.has_key?(:'count')
83
+ self.count = attributes[:'count']
84
+ end
85
+
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properies with the reasons
90
+ def list_invalid_properties
91
+ invalid_properties = Array.new
92
+ return invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ return true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ total == o.total &&
107
+ data == o.data &&
108
+ offset == o.offset &&
109
+ count == o.count
110
+ end
111
+
112
+ # @see the `==` method
113
+ # @param [Object] Object to be compared
114
+ def eql?(o)
115
+ self == o
116
+ end
117
+
118
+ # Calculates hash code according to all attributes.
119
+ # @return [Fixnum] Hash code
120
+ def hash
121
+ [total, data, offset, count].hash
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+ self.class.swagger_types.each_pair do |key, type|
130
+ if type =~ /^Array<(.*)>/i
131
+ # check to ensure the input is an array given that the the attribute
132
+ # is documented as an array but the input is not
133
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
134
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
135
+ end
136
+ elsif !attributes[self.class.attribute_map[key]].nil?
137
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
138
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
139
+ end
140
+
141
+ self
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def _deserialize(type, value)
149
+ case type.to_sym
150
+ when :DateTime
151
+ DateTime.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :BOOLEAN
161
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ temp_model = ArtikCloud.const_get(type).new
182
+ temp_model.build_from_hash(value)
183
+ end
184
+ end
185
+
186
+ # Returns the string representation of the object
187
+ # @return [String] String presentation of the object
188
+ def to_s
189
+ to_hash.to_s
190
+ end
191
+
192
+ # to_body is an alias to to_hash (backward compatibility)
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_body
195
+ to_hash
196
+ end
197
+
198
+ # Returns the object in the form of hash
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_hash
201
+ hash = {}
202
+ self.class.attribute_map.each_pair do |attr, param|
203
+ value = self.send(attr)
204
+ next if value.nil?
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
@@ -0,0 +1,200 @@
1
+ =begin
2
+ #ARTIK Cloud API
3
+
4
+ #No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module ArtikCloud
27
+ #
28
+ class TaskEnvelope
29
+ # Task details envelope
30
+ attr_accessor :data
31
+
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'data' => :'data'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'data' => :'Task'
44
+ }
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ return unless attributes.is_a?(Hash)
51
+
52
+ # convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
54
+
55
+ if attributes.has_key?(:'data')
56
+ self.data = attributes[:'data']
57
+ end
58
+
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properies with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ return invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ return true
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(o)
77
+ return true if self.equal?(o)
78
+ self.class == o.class &&
79
+ data == o.data
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Fixnum] Hash code
90
+ def hash
91
+ [data].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def build_from_hash(attributes)
98
+ return nil unless attributes.is_a?(Hash)
99
+ self.class.swagger_types.each_pair do |key, type|
100
+ if type =~ /^Array<(.*)>/i
101
+ # check to ensure the input is an array given that the the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
104
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
105
+ end
106
+ elsif !attributes[self.class.attribute_map[key]].nil?
107
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
108
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
109
+ end
110
+
111
+ self
112
+ end
113
+
114
+ # Deserializes the data based on type
115
+ # @param string type Data type
116
+ # @param string value Value to be deserialized
117
+ # @return [Object] Deserialized data
118
+ def _deserialize(type, value)
119
+ case type.to_sym
120
+ when :DateTime
121
+ DateTime.parse(value)
122
+ when :Date
123
+ Date.parse(value)
124
+ when :String
125
+ value.to_s
126
+ when :Integer
127
+ value.to_i
128
+ when :Float
129
+ value.to_f
130
+ when :BOOLEAN
131
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
132
+ true
133
+ else
134
+ false
135
+ end
136
+ when :Object
137
+ # generic object (usually a Hash), return directly
138
+ value
139
+ when /\AArray<(?<inner_type>.+)>\z/
140
+ inner_type = Regexp.last_match[:inner_type]
141
+ value.map { |v| _deserialize(inner_type, v) }
142
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
143
+ k_type = Regexp.last_match[:k_type]
144
+ v_type = Regexp.last_match[:v_type]
145
+ {}.tap do |hash|
146
+ value.each do |k, v|
147
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
+ end
149
+ end
150
+ else # model
151
+ temp_model = ArtikCloud.const_get(type).new
152
+ temp_model.build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ # Returns the object in the form of hash
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_hash
171
+ hash = {}
172
+ self.class.attribute_map.each_pair do |attr, param|
173
+ value = self.send(attr)
174
+ next if value.nil?
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param [Object] value Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map{ |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ end