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,302 @@
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 Task
29
+ # Filter
30
+ attr_accessor :filter
31
+
32
+ # Task type
33
+ attr_accessor :task_type
34
+
35
+ # Modified on
36
+ attr_accessor :modified_on
37
+
38
+ # Device Type ID
39
+ attr_accessor :dtid
40
+
41
+ # Status counts
42
+ attr_accessor :status_counts
43
+
44
+ # Property
45
+ attr_accessor :property
46
+
47
+ # Task ID
48
+ attr_accessor :id
49
+
50
+ # Device IDs
51
+ attr_accessor :dids
52
+
53
+ # Task parameters
54
+ attr_accessor :task_parameters
55
+
56
+ # Created on
57
+ attr_accessor :created_on
58
+
59
+ # Status
60
+ attr_accessor :status
61
+
62
+
63
+ # Attribute mapping from ruby-style variable name to JSON key.
64
+ def self.attribute_map
65
+ {
66
+ :'filter' => :'filter',
67
+ :'task_type' => :'taskType',
68
+ :'modified_on' => :'modifiedOn',
69
+ :'dtid' => :'dtid',
70
+ :'status_counts' => :'statusCounts',
71
+ :'property' => :'property',
72
+ :'id' => :'id',
73
+ :'dids' => :'dids',
74
+ :'task_parameters' => :'taskParameters',
75
+ :'created_on' => :'createdOn',
76
+ :'status' => :'status'
77
+ }
78
+ end
79
+
80
+ # Attribute type mapping.
81
+ def self.swagger_types
82
+ {
83
+ :'filter' => :'String',
84
+ :'task_type' => :'String',
85
+ :'modified_on' => :'Integer',
86
+ :'dtid' => :'String',
87
+ :'status_counts' => :'TaskStatusCounts',
88
+ :'property' => :'String',
89
+ :'id' => :'String',
90
+ :'dids' => :'Array<String>',
91
+ :'task_parameters' => :'TaskParameters',
92
+ :'created_on' => :'Integer',
93
+ :'status' => :'String'
94
+ }
95
+ end
96
+
97
+ # Initializes the object
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ def initialize(attributes = {})
100
+ return unless attributes.is_a?(Hash)
101
+
102
+ # convert string to symbol for hash key
103
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
104
+
105
+ if attributes.has_key?(:'filter')
106
+ self.filter = attributes[:'filter']
107
+ end
108
+
109
+ if attributes.has_key?(:'taskType')
110
+ self.task_type = attributes[:'taskType']
111
+ end
112
+
113
+ if attributes.has_key?(:'modifiedOn')
114
+ self.modified_on = attributes[:'modifiedOn']
115
+ end
116
+
117
+ if attributes.has_key?(:'dtid')
118
+ self.dtid = attributes[:'dtid']
119
+ end
120
+
121
+ if attributes.has_key?(:'statusCounts')
122
+ self.status_counts = attributes[:'statusCounts']
123
+ end
124
+
125
+ if attributes.has_key?(:'property')
126
+ self.property = attributes[:'property']
127
+ end
128
+
129
+ if attributes.has_key?(:'id')
130
+ self.id = attributes[:'id']
131
+ end
132
+
133
+ if attributes.has_key?(:'dids')
134
+ if (value = attributes[:'dids']).is_a?(Array)
135
+ self.dids = value
136
+ end
137
+ end
138
+
139
+ if attributes.has_key?(:'taskParameters')
140
+ self.task_parameters = attributes[:'taskParameters']
141
+ end
142
+
143
+ if attributes.has_key?(:'createdOn')
144
+ self.created_on = attributes[:'createdOn']
145
+ end
146
+
147
+ if attributes.has_key?(:'status')
148
+ self.status = attributes[:'status']
149
+ end
150
+
151
+ end
152
+
153
+ # Show invalid properties with the reasons. Usually used together with valid?
154
+ # @return Array for valid properies with the reasons
155
+ def list_invalid_properties
156
+ invalid_properties = Array.new
157
+ return invalid_properties
158
+ end
159
+
160
+ # Check to see if the all the properties in the model are valid
161
+ # @return true if the model is valid
162
+ def valid?
163
+ return true
164
+ end
165
+
166
+ # Checks equality by comparing each attribute.
167
+ # @param [Object] Object to be compared
168
+ def ==(o)
169
+ return true if self.equal?(o)
170
+ self.class == o.class &&
171
+ filter == o.filter &&
172
+ task_type == o.task_type &&
173
+ modified_on == o.modified_on &&
174
+ dtid == o.dtid &&
175
+ status_counts == o.status_counts &&
176
+ property == o.property &&
177
+ id == o.id &&
178
+ dids == o.dids &&
179
+ task_parameters == o.task_parameters &&
180
+ created_on == o.created_on &&
181
+ status == o.status
182
+ end
183
+
184
+ # @see the `==` method
185
+ # @param [Object] Object to be compared
186
+ def eql?(o)
187
+ self == o
188
+ end
189
+
190
+ # Calculates hash code according to all attributes.
191
+ # @return [Fixnum] Hash code
192
+ def hash
193
+ [filter, task_type, modified_on, dtid, status_counts, property, id, dids, task_parameters, created_on, status].hash
194
+ end
195
+
196
+ # Builds the object from hash
197
+ # @param [Hash] attributes Model attributes in the form of hash
198
+ # @return [Object] Returns the model itself
199
+ def build_from_hash(attributes)
200
+ return nil unless attributes.is_a?(Hash)
201
+ self.class.swagger_types.each_pair do |key, type|
202
+ if type =~ /^Array<(.*)>/i
203
+ # check to ensure the input is an array given that the the attribute
204
+ # is documented as an array but the input is not
205
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
206
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
207
+ end
208
+ elsif !attributes[self.class.attribute_map[key]].nil?
209
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
210
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
211
+ end
212
+
213
+ self
214
+ end
215
+
216
+ # Deserializes the data based on type
217
+ # @param string type Data type
218
+ # @param string value Value to be deserialized
219
+ # @return [Object] Deserialized data
220
+ def _deserialize(type, value)
221
+ case type.to_sym
222
+ when :DateTime
223
+ DateTime.parse(value)
224
+ when :Date
225
+ Date.parse(value)
226
+ when :String
227
+ value.to_s
228
+ when :Integer
229
+ value.to_i
230
+ when :Float
231
+ value.to_f
232
+ when :BOOLEAN
233
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
234
+ true
235
+ else
236
+ false
237
+ end
238
+ when :Object
239
+ # generic object (usually a Hash), return directly
240
+ value
241
+ when /\AArray<(?<inner_type>.+)>\z/
242
+ inner_type = Regexp.last_match[:inner_type]
243
+ value.map { |v| _deserialize(inner_type, v) }
244
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
245
+ k_type = Regexp.last_match[:k_type]
246
+ v_type = Regexp.last_match[:v_type]
247
+ {}.tap do |hash|
248
+ value.each do |k, v|
249
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
250
+ end
251
+ end
252
+ else # model
253
+ temp_model = ArtikCloud.const_get(type).new
254
+ temp_model.build_from_hash(value)
255
+ end
256
+ end
257
+
258
+ # Returns the string representation of the object
259
+ # @return [String] String presentation of the object
260
+ def to_s
261
+ to_hash.to_s
262
+ end
263
+
264
+ # to_body is an alias to to_hash (backward compatibility)
265
+ # @return [Hash] Returns the object in the form of hash
266
+ def to_body
267
+ to_hash
268
+ end
269
+
270
+ # Returns the object in the form of hash
271
+ # @return [Hash] Returns the object in the form of hash
272
+ def to_hash
273
+ hash = {}
274
+ self.class.attribute_map.each_pair do |attr, param|
275
+ value = self.send(attr)
276
+ next if value.nil?
277
+ hash[param] = _to_hash(value)
278
+ end
279
+ hash
280
+ end
281
+
282
+ # Outputs non-array value in the form of hash
283
+ # For object, use to_hash. Otherwise, just return the value
284
+ # @param [Object] value Any valid value
285
+ # @return [Hash] Returns the value in the form of hash
286
+ def _to_hash(value)
287
+ if value.is_a?(Array)
288
+ value.compact.map{ |v| _to_hash(v) }
289
+ elsif value.is_a?(Hash)
290
+ {}.tap do |hash|
291
+ value.each { |k, v| hash[k] = _to_hash(v) }
292
+ end
293
+ elsif value.respond_to? :to_hash
294
+ value.to_hash
295
+ else
296
+ value
297
+ end
298
+ end
299
+
300
+ end
301
+
302
+ end
@@ -0,0 +1,314 @@
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 TaskByDid
29
+ # Filter
30
+ attr_accessor :filter
31
+
32
+ # Task type
33
+ attr_accessor :task_type
34
+
35
+ # Modified on
36
+ attr_accessor :modified_on
37
+
38
+ # Device Type ID
39
+ attr_accessor :dtid
40
+
41
+ # Status counts
42
+ attr_accessor :status_counts
43
+
44
+ # Property
45
+ attr_accessor :property
46
+
47
+ # Last known device task status for the specified did
48
+ attr_accessor :statuses
49
+
50
+ # Task ID
51
+ attr_accessor :id
52
+
53
+ # Device IDs
54
+ attr_accessor :dids
55
+
56
+ # Task parameters
57
+ attr_accessor :task_parameters
58
+
59
+ # Created on
60
+ attr_accessor :created_on
61
+
62
+ # Status
63
+ attr_accessor :status
64
+
65
+
66
+ # Attribute mapping from ruby-style variable name to JSON key.
67
+ def self.attribute_map
68
+ {
69
+ :'filter' => :'filter',
70
+ :'task_type' => :'taskType',
71
+ :'modified_on' => :'modifiedOn',
72
+ :'dtid' => :'dtid',
73
+ :'status_counts' => :'statusCounts',
74
+ :'property' => :'property',
75
+ :'statuses' => :'statuses',
76
+ :'id' => :'id',
77
+ :'dids' => :'dids',
78
+ :'task_parameters' => :'taskParameters',
79
+ :'created_on' => :'createdOn',
80
+ :'status' => :'status'
81
+ }
82
+ end
83
+
84
+ # Attribute type mapping.
85
+ def self.swagger_types
86
+ {
87
+ :'filter' => :'String',
88
+ :'task_type' => :'String',
89
+ :'modified_on' => :'Integer',
90
+ :'dtid' => :'String',
91
+ :'status_counts' => :'TaskStatusCounts',
92
+ :'property' => :'String',
93
+ :'statuses' => :'Array<DeviceTask>',
94
+ :'id' => :'String',
95
+ :'dids' => :'Array<String>',
96
+ :'task_parameters' => :'TaskParameters',
97
+ :'created_on' => :'Integer',
98
+ :'status' => :'String'
99
+ }
100
+ end
101
+
102
+ # Initializes the object
103
+ # @param [Hash] attributes Model attributes in the form of hash
104
+ def initialize(attributes = {})
105
+ return unless attributes.is_a?(Hash)
106
+
107
+ # convert string to symbol for hash key
108
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
109
+
110
+ if attributes.has_key?(:'filter')
111
+ self.filter = attributes[:'filter']
112
+ end
113
+
114
+ if attributes.has_key?(:'taskType')
115
+ self.task_type = attributes[:'taskType']
116
+ end
117
+
118
+ if attributes.has_key?(:'modifiedOn')
119
+ self.modified_on = attributes[:'modifiedOn']
120
+ end
121
+
122
+ if attributes.has_key?(:'dtid')
123
+ self.dtid = attributes[:'dtid']
124
+ end
125
+
126
+ if attributes.has_key?(:'statusCounts')
127
+ self.status_counts = attributes[:'statusCounts']
128
+ end
129
+
130
+ if attributes.has_key?(:'property')
131
+ self.property = attributes[:'property']
132
+ end
133
+
134
+ if attributes.has_key?(:'statuses')
135
+ if (value = attributes[:'statuses']).is_a?(Array)
136
+ self.statuses = value
137
+ end
138
+ end
139
+
140
+ if attributes.has_key?(:'id')
141
+ self.id = attributes[:'id']
142
+ end
143
+
144
+ if attributes.has_key?(:'dids')
145
+ if (value = attributes[:'dids']).is_a?(Array)
146
+ self.dids = value
147
+ end
148
+ end
149
+
150
+ if attributes.has_key?(:'taskParameters')
151
+ self.task_parameters = attributes[:'taskParameters']
152
+ end
153
+
154
+ if attributes.has_key?(:'createdOn')
155
+ self.created_on = attributes[:'createdOn']
156
+ end
157
+
158
+ if attributes.has_key?(:'status')
159
+ self.status = attributes[:'status']
160
+ end
161
+
162
+ end
163
+
164
+ # Show invalid properties with the reasons. Usually used together with valid?
165
+ # @return Array for valid properies with the reasons
166
+ def list_invalid_properties
167
+ invalid_properties = Array.new
168
+ return invalid_properties
169
+ end
170
+
171
+ # Check to see if the all the properties in the model are valid
172
+ # @return true if the model is valid
173
+ def valid?
174
+ return true
175
+ end
176
+
177
+ # Checks equality by comparing each attribute.
178
+ # @param [Object] Object to be compared
179
+ def ==(o)
180
+ return true if self.equal?(o)
181
+ self.class == o.class &&
182
+ filter == o.filter &&
183
+ task_type == o.task_type &&
184
+ modified_on == o.modified_on &&
185
+ dtid == o.dtid &&
186
+ status_counts == o.status_counts &&
187
+ property == o.property &&
188
+ statuses == o.statuses &&
189
+ id == o.id &&
190
+ dids == o.dids &&
191
+ task_parameters == o.task_parameters &&
192
+ created_on == o.created_on &&
193
+ status == o.status
194
+ end
195
+
196
+ # @see the `==` method
197
+ # @param [Object] Object to be compared
198
+ def eql?(o)
199
+ self == o
200
+ end
201
+
202
+ # Calculates hash code according to all attributes.
203
+ # @return [Fixnum] Hash code
204
+ def hash
205
+ [filter, task_type, modified_on, dtid, status_counts, property, statuses, id, dids, task_parameters, created_on, status].hash
206
+ end
207
+
208
+ # Builds the object from hash
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ # @return [Object] Returns the model itself
211
+ def build_from_hash(attributes)
212
+ return nil unless attributes.is_a?(Hash)
213
+ self.class.swagger_types.each_pair do |key, type|
214
+ if type =~ /^Array<(.*)>/i
215
+ # check to ensure the input is an array given that the the attribute
216
+ # is documented as an array but the input is not
217
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
218
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
219
+ end
220
+ elsif !attributes[self.class.attribute_map[key]].nil?
221
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
222
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
223
+ end
224
+
225
+ self
226
+ end
227
+
228
+ # Deserializes the data based on type
229
+ # @param string type Data type
230
+ # @param string value Value to be deserialized
231
+ # @return [Object] Deserialized data
232
+ def _deserialize(type, value)
233
+ case type.to_sym
234
+ when :DateTime
235
+ DateTime.parse(value)
236
+ when :Date
237
+ Date.parse(value)
238
+ when :String
239
+ value.to_s
240
+ when :Integer
241
+ value.to_i
242
+ when :Float
243
+ value.to_f
244
+ when :BOOLEAN
245
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
246
+ true
247
+ else
248
+ false
249
+ end
250
+ when :Object
251
+ # generic object (usually a Hash), return directly
252
+ value
253
+ when /\AArray<(?<inner_type>.+)>\z/
254
+ inner_type = Regexp.last_match[:inner_type]
255
+ value.map { |v| _deserialize(inner_type, v) }
256
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
257
+ k_type = Regexp.last_match[:k_type]
258
+ v_type = Regexp.last_match[:v_type]
259
+ {}.tap do |hash|
260
+ value.each do |k, v|
261
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
262
+ end
263
+ end
264
+ else # model
265
+ temp_model = ArtikCloud.const_get(type).new
266
+ temp_model.build_from_hash(value)
267
+ end
268
+ end
269
+
270
+ # Returns the string representation of the object
271
+ # @return [String] String presentation of the object
272
+ def to_s
273
+ to_hash.to_s
274
+ end
275
+
276
+ # to_body is an alias to to_hash (backward compatibility)
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_body
279
+ to_hash
280
+ end
281
+
282
+ # Returns the object in the form of hash
283
+ # @return [Hash] Returns the object in the form of hash
284
+ def to_hash
285
+ hash = {}
286
+ self.class.attribute_map.each_pair do |attr, param|
287
+ value = self.send(attr)
288
+ next if value.nil?
289
+ hash[param] = _to_hash(value)
290
+ end
291
+ hash
292
+ end
293
+
294
+ # Outputs non-array value in the form of hash
295
+ # For object, use to_hash. Otherwise, just return the value
296
+ # @param [Object] value Any valid value
297
+ # @return [Hash] Returns the value in the form of hash
298
+ def _to_hash(value)
299
+ if value.is_a?(Array)
300
+ value.compact.map{ |v| _to_hash(v) }
301
+ elsif value.is_a?(Hash)
302
+ {}.tap do |hash|
303
+ value.each { |k, v| hash[k] = _to_hash(v) }
304
+ end
305
+ elsif value.respond_to? :to_hash
306
+ value.to_hash
307
+ else
308
+ value
309
+ end
310
+ end
311
+
312
+ end
313
+
314
+ end