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,250 @@
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 DeviceTask
29
+ # Number of attempts
30
+ attr_accessor :num_attempts
31
+
32
+ # Error Message
33
+ attr_accessor :error_message
34
+
35
+ # Error Code
36
+ attr_accessor :error_code
37
+
38
+ # Device ID
39
+ attr_accessor :did
40
+
41
+ # Status
42
+ attr_accessor :status
43
+
44
+ # Timestamp of most recent status change
45
+ attr_accessor :ts
46
+
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'num_attempts' => :'numAttempts',
52
+ :'error_message' => :'errorMessage',
53
+ :'error_code' => :'errorCode',
54
+ :'did' => :'did',
55
+ :'status' => :'status',
56
+ :'ts' => :'ts'
57
+ }
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.swagger_types
62
+ {
63
+ :'num_attempts' => :'Integer',
64
+ :'error_message' => :'String',
65
+ :'error_code' => :'String',
66
+ :'did' => :'String',
67
+ :'status' => :'String',
68
+ :'ts' => :'Integer'
69
+ }
70
+ end
71
+
72
+ # Initializes the object
73
+ # @param [Hash] attributes Model attributes in the form of hash
74
+ def initialize(attributes = {})
75
+ return unless attributes.is_a?(Hash)
76
+
77
+ # convert string to symbol for hash key
78
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
79
+
80
+ if attributes.has_key?(:'numAttempts')
81
+ self.num_attempts = attributes[:'numAttempts']
82
+ end
83
+
84
+ if attributes.has_key?(:'errorMessage')
85
+ self.error_message = attributes[:'errorMessage']
86
+ end
87
+
88
+ if attributes.has_key?(:'errorCode')
89
+ self.error_code = attributes[:'errorCode']
90
+ end
91
+
92
+ if attributes.has_key?(:'did')
93
+ self.did = attributes[:'did']
94
+ end
95
+
96
+ if attributes.has_key?(:'status')
97
+ self.status = attributes[:'status']
98
+ end
99
+
100
+ if attributes.has_key?(:'ts')
101
+ self.ts = attributes[:'ts']
102
+ end
103
+
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properies with the reasons
108
+ def list_invalid_properties
109
+ invalid_properties = Array.new
110
+ return invalid_properties
111
+ end
112
+
113
+ # Check to see if the all the properties in the model are valid
114
+ # @return true if the model is valid
115
+ def valid?
116
+ return true
117
+ end
118
+
119
+ # Checks equality by comparing each attribute.
120
+ # @param [Object] Object to be compared
121
+ def ==(o)
122
+ return true if self.equal?(o)
123
+ self.class == o.class &&
124
+ num_attempts == o.num_attempts &&
125
+ error_message == o.error_message &&
126
+ error_code == o.error_code &&
127
+ did == o.did &&
128
+ status == o.status &&
129
+ ts == o.ts
130
+ end
131
+
132
+ # @see the `==` method
133
+ # @param [Object] Object to be compared
134
+ def eql?(o)
135
+ self == o
136
+ end
137
+
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Fixnum] Hash code
140
+ def hash
141
+ [num_attempts, error_message, error_code, did, status, ts].hash
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ self.class.swagger_types.each_pair do |key, type|
150
+ if type =~ /^Array<(.*)>/i
151
+ # check to ensure the input is an array given that the the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
154
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
155
+ end
156
+ elsif !attributes[self.class.attribute_map[key]].nil?
157
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
158
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
159
+ end
160
+
161
+ self
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def _deserialize(type, value)
169
+ case type.to_sym
170
+ when :DateTime
171
+ DateTime.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :BOOLEAN
181
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ temp_model = ArtikCloud.const_get(type).new
202
+ temp_model.build_from_hash(value)
203
+ end
204
+ end
205
+
206
+ # Returns the string representation of the object
207
+ # @return [String] String presentation of the object
208
+ def to_s
209
+ to_hash.to_s
210
+ end
211
+
212
+ # to_body is an alias to to_hash (backward compatibility)
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_body
215
+ to_hash
216
+ end
217
+
218
+ # Returns the object in the form of hash
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_hash
221
+ hash = {}
222
+ self.class.attribute_map.each_pair do |attr, param|
223
+ value = self.send(attr)
224
+ next if value.nil?
225
+ hash[param] = _to_hash(value)
226
+ end
227
+ hash
228
+ end
229
+
230
+ # Outputs non-array value in the form of hash
231
+ # For object, use to_hash. Otherwise, just return the value
232
+ # @param [Object] value Any valid value
233
+ # @return [Hash] Returns the value in the form of hash
234
+ def _to_hash(value)
235
+ if value.is_a?(Array)
236
+ value.compact.map{ |v| _to_hash(v) }
237
+ elsif value.is_a?(Hash)
238
+ {}.tap do |hash|
239
+ value.each { |k, v| hash[k] = _to_hash(v) }
240
+ end
241
+ elsif value.respond_to? :to_hash
242
+ value.to_hash
243
+ else
244
+ value
245
+ end
246
+ end
247
+
248
+ end
249
+
250
+ 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 DeviceTaskUpdateRequest
29
+ # Status
30
+ attr_accessor :status
31
+
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'status' => :'status'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'status' => :'String'
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?(:'status')
56
+ self.status = attributes[:'status']
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
+ status == o.status
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
+ [status].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
@@ -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 DeviceTaskUpdateResponse
29
+ # Task status
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' => :'TaskStatus'
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