artikcloud 2.0.8 → 2.1.0

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 (197) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -2
  3. data/LICENSE +1 -1
  4. data/README.md +39 -4
  5. data/Rakefile +8 -0
  6. data/artikcloud.gemspec +5 -16
  7. data/docs/Device.md +2 -0
  8. data/docs/DeviceShareInfo.md +8 -0
  9. data/docs/DeviceSharing.md +11 -0
  10. data/docs/DeviceSharingArray.md +8 -0
  11. data/docs/DeviceSharingEnvelope.md +11 -0
  12. data/docs/DeviceSharingId.md +8 -0
  13. data/docs/DeviceStatus.md +9 -0
  14. data/docs/DeviceStatusBatch.md +11 -0
  15. data/docs/DeviceStatusData.md +12 -0
  16. data/docs/DeviceStatusPut.md +8 -0
  17. data/docs/DeviceStatusPutData.md +8 -0
  18. data/docs/DevicessharesApi.md +235 -0
  19. data/docs/DevicestatusApi.md +183 -0
  20. data/docs/NotifMessage.md +15 -0
  21. data/docs/NotifMessageArray.md +8 -0
  22. data/docs/NotifMessagesResponse.md +12 -0
  23. data/docs/Subscription.md +24 -0
  24. data/docs/SubscriptionArray.md +8 -0
  25. data/docs/SubscriptionEnvelope.md +8 -0
  26. data/docs/SubscriptionInfo.md +20 -0
  27. data/docs/SubscriptionsApi.md +342 -0
  28. data/docs/SubscriptionsEnvelope.md +11 -0
  29. data/docs/TaskParameters.md +2 -0
  30. data/docs/UpdateParameters.md +8 -0
  31. data/docs/UsersApi.md +67 -1
  32. data/docs/ValidationCallbackInfo.md +9 -0
  33. data/git_push.sh +0 -12
  34. data/lib/artikcloud.rb +24 -13
  35. data/lib/artikcloud/api/device_types_api.rb +7 -55
  36. data/lib/artikcloud/api/devices_api.rb +12 -66
  37. data/lib/artikcloud/api/devices_management_api.rb +16 -118
  38. data/lib/artikcloud/api/devicesshares_api.rb +244 -0
  39. data/lib/artikcloud/api/devicestatus_api.rb +190 -0
  40. data/lib/artikcloud/api/export_api.rb +5 -41
  41. data/lib/artikcloud/api/messages_api.rb +10 -76
  42. data/lib/artikcloud/api/registrations_api.rb +4 -34
  43. data/lib/artikcloud/api/rules_api.rb +5 -41
  44. data/lib/artikcloud/api/subscriptions_api.rb +346 -0
  45. data/lib/artikcloud/api/tags_api.rb +4 -34
  46. data/lib/artikcloud/api/tokens_api.rb +5 -33
  47. data/lib/artikcloud/api/users_api.rb +79 -67
  48. data/lib/artikcloud/api_client.rb +17 -20
  49. data/lib/artikcloud/api_error.rb +8 -18
  50. data/lib/artikcloud/configuration.rb +1 -13
  51. data/lib/artikcloud/models/ack_envelope.rb +4 -16
  52. data/lib/artikcloud/models/acknowledgement.rb +4 -16
  53. data/lib/artikcloud/models/action.rb +4 -16
  54. data/lib/artikcloud/models/action_array.rb +4 -16
  55. data/lib/artikcloud/models/action_details.rb +4 -16
  56. data/lib/artikcloud/models/action_details_array.rb +4 -16
  57. data/lib/artikcloud/models/action_in.rb +4 -16
  58. data/lib/artikcloud/models/action_out.rb +4 -16
  59. data/lib/artikcloud/models/actions.rb +4 -16
  60. data/lib/artikcloud/models/aggregate_data.rb +4 -16
  61. data/lib/artikcloud/models/aggregates_histogram_data.rb +4 -16
  62. data/lib/artikcloud/models/aggregates_histogram_response.rb +4 -16
  63. data/lib/artikcloud/models/aggregates_response.rb +4 -16
  64. data/lib/artikcloud/models/app_properties.rb +8 -16
  65. data/lib/artikcloud/models/check_token_message.rb +4 -16
  66. data/lib/artikcloud/models/check_token_response.rb +4 -16
  67. data/lib/artikcloud/models/device.rb +28 -20
  68. data/lib/artikcloud/models/device_array.rb +4 -16
  69. data/lib/artikcloud/models/device_envelope.rb +8 -16
  70. data/lib/artikcloud/models/device_reg_complete_request.rb +4 -16
  71. data/lib/artikcloud/models/device_reg_confirm_user_request.rb +4 -16
  72. data/lib/artikcloud/models/device_reg_confirm_user_response.rb +4 -16
  73. data/lib/artikcloud/models/device_reg_confirm_user_response_envelope.rb +4 -16
  74. data/lib/artikcloud/models/device_reg_status_response.rb +4 -16
  75. data/lib/artikcloud/models/device_reg_status_response_envelope.rb +4 -16
  76. data/lib/artikcloud/models/device_share_info.rb +188 -0
  77. data/lib/artikcloud/models/device_sharing.rb +218 -0
  78. data/lib/artikcloud/models/device_sharing_array.rb +189 -0
  79. data/lib/artikcloud/models/device_sharing_envelope.rb +214 -0
  80. data/lib/artikcloud/models/device_sharing_id.rb +188 -0
  81. data/lib/artikcloud/models/device_status.rb +196 -0
  82. data/lib/artikcloud/models/device_status_batch.rb +216 -0
  83. data/lib/artikcloud/models/device_status_data.rb +225 -0
  84. data/lib/artikcloud/models/device_status_put.rb +187 -0
  85. data/lib/artikcloud/models/device_status_put_data.rb +187 -0
  86. data/lib/artikcloud/models/device_task.rb +4 -16
  87. data/lib/artikcloud/models/device_task_update_request.rb +4 -16
  88. data/lib/artikcloud/models/device_task_update_response.rb +4 -16
  89. data/lib/artikcloud/models/device_token.rb +20 -16
  90. data/lib/artikcloud/models/device_token_envelope.rb +8 -16
  91. data/lib/artikcloud/models/device_type.rb +4 -16
  92. data/lib/artikcloud/models/device_type_array.rb +4 -16
  93. data/lib/artikcloud/models/device_type_envelope.rb +8 -16
  94. data/lib/artikcloud/models/device_type_info.rb +4 -16
  95. data/lib/artikcloud/models/device_type_info_envelope.rb +4 -16
  96. data/lib/artikcloud/models/device_types_envelope.rb +16 -16
  97. data/lib/artikcloud/models/device_types_info.rb +4 -16
  98. data/lib/artikcloud/models/device_types_info_envelope.rb +4 -16
  99. data/lib/artikcloud/models/devices_envelope.rb +16 -16
  100. data/lib/artikcloud/models/error_envelope.rb +4 -16
  101. data/lib/artikcloud/models/event_feed_data.rb +4 -16
  102. data/lib/artikcloud/models/export_data.rb +4 -16
  103. data/lib/artikcloud/models/export_data_array.rb +4 -16
  104. data/lib/artikcloud/models/export_history_response.rb +4 -16
  105. data/lib/artikcloud/models/export_normalized_messages_response.rb +4 -16
  106. data/lib/artikcloud/models/export_request.rb +4 -16
  107. data/lib/artikcloud/models/export_request_data.rb +4 -16
  108. data/lib/artikcloud/models/export_request_info.rb +4 -16
  109. data/lib/artikcloud/models/export_request_response.rb +4 -16
  110. data/lib/artikcloud/models/export_response.rb +4 -16
  111. data/lib/artikcloud/models/export_status_response.rb +4 -16
  112. data/lib/artikcloud/models/field_path.rb +4 -16
  113. data/lib/artikcloud/models/field_presence.rb +8 -16
  114. data/lib/artikcloud/models/field_presence_envelope.rb +32 -16
  115. data/lib/artikcloud/models/fields_actions.rb +4 -16
  116. data/lib/artikcloud/models/manifest_properties.rb +8 -16
  117. data/lib/artikcloud/models/manifest_properties_envelope.rb +8 -16
  118. data/lib/artikcloud/models/manifest_versions.rb +8 -16
  119. data/lib/artikcloud/models/manifest_versions_envelope.rb +8 -16
  120. data/lib/artikcloud/models/message.rb +4 -16
  121. data/lib/artikcloud/models/message_action.rb +4 -16
  122. data/lib/artikcloud/models/message_id.rb +4 -16
  123. data/lib/artikcloud/models/message_id_envelope.rb +4 -16
  124. data/lib/artikcloud/models/message_in.rb +4 -16
  125. data/lib/artikcloud/models/message_out.rb +4 -16
  126. data/lib/artikcloud/models/metadata_envelope.rb +4 -16
  127. data/lib/artikcloud/models/metadata_properties_envelope.rb +4 -16
  128. data/lib/artikcloud/models/metadata_query_envelope.rb +4 -16
  129. data/lib/artikcloud/models/non_empty_string.rb +4 -16
  130. data/lib/artikcloud/models/normalized_action.rb +36 -16
  131. data/lib/artikcloud/models/normalized_actions_envelope.rb +16 -16
  132. data/lib/artikcloud/models/normalized_message.rb +36 -16
  133. data/lib/artikcloud/models/normalized_messages_envelope.rb +16 -16
  134. data/lib/artikcloud/models/notif_message.rb +252 -0
  135. data/lib/artikcloud/models/notif_message_array.rb +189 -0
  136. data/lib/artikcloud/models/notif_messages_response.rb +223 -0
  137. data/lib/artikcloud/models/output_rule.rb +4 -16
  138. data/lib/artikcloud/models/presence_envelope.rb +4 -16
  139. data/lib/artikcloud/models/presence_model.rb +4 -16
  140. data/lib/artikcloud/models/properties_envelope.rb +8 -16
  141. data/lib/artikcloud/models/refresh_token_response.rb +4 -16
  142. data/lib/artikcloud/models/register_message.rb +4 -16
  143. data/lib/artikcloud/models/rule_array.rb +4 -16
  144. data/lib/artikcloud/models/rule_creation_info.rb +4 -16
  145. data/lib/artikcloud/models/rule_envelope.rb +4 -16
  146. data/lib/artikcloud/models/rule_error.rb +4 -16
  147. data/lib/artikcloud/models/rule_update_info.rb +4 -16
  148. data/lib/artikcloud/models/rule_warning_output.rb +4 -16
  149. data/lib/artikcloud/models/rules_envelope.rb +4 -16
  150. data/lib/artikcloud/models/snapshot_response.rb +4 -16
  151. data/lib/artikcloud/models/snapshot_responses.rb +4 -16
  152. data/lib/artikcloud/models/snapshots_response_envelope.rb +4 -16
  153. data/lib/artikcloud/models/subscription.rb +348 -0
  154. data/lib/artikcloud/models/subscription_array.rb +189 -0
  155. data/lib/artikcloud/models/subscription_envelope.rb +187 -0
  156. data/lib/artikcloud/models/subscription_info.rb +308 -0
  157. data/lib/artikcloud/models/subscriptions_envelope.rb +214 -0
  158. data/lib/artikcloud/models/tag.rb +4 -16
  159. data/lib/artikcloud/models/tag_array.rb +4 -16
  160. data/lib/artikcloud/models/tags_envelope.rb +4 -16
  161. data/lib/artikcloud/models/task.rb +4 -16
  162. data/lib/artikcloud/models/task_by_did.rb +4 -16
  163. data/lib/artikcloud/models/task_by_did_list.rb +4 -16
  164. data/lib/artikcloud/models/task_by_did_list_envelope.rb +4 -16
  165. data/lib/artikcloud/models/task_envelope.rb +4 -16
  166. data/lib/artikcloud/models/task_history.rb +4 -16
  167. data/lib/artikcloud/models/task_history_list.rb +4 -16
  168. data/lib/artikcloud/models/task_list.rb +4 -16
  169. data/lib/artikcloud/models/task_list_envelope.rb +4 -16
  170. data/lib/artikcloud/models/task_parameters.rb +25 -17
  171. data/lib/artikcloud/models/task_request.rb +4 -16
  172. data/lib/artikcloud/models/task_status.rb +4 -16
  173. data/lib/artikcloud/models/task_status_counts.rb +4 -16
  174. data/lib/artikcloud/models/task_statuses.rb +4 -16
  175. data/lib/artikcloud/models/task_statuses_envelope.rb +4 -16
  176. data/lib/artikcloud/models/task_statuses_history_envelope.rb +4 -16
  177. data/lib/artikcloud/models/task_update_request.rb +4 -16
  178. data/lib/artikcloud/models/task_update_response.rb +4 -16
  179. data/lib/artikcloud/models/tasks_status_counts.rb +4 -16
  180. data/lib/artikcloud/models/token.rb +4 -16
  181. data/lib/artikcloud/models/token_info.rb +4 -16
  182. data/lib/artikcloud/models/token_info_success_response.rb +4 -16
  183. data/lib/artikcloud/models/token_request.rb +4 -16
  184. data/lib/artikcloud/models/token_response.rb +4 -16
  185. data/lib/artikcloud/models/unregister_device_response.rb +4 -16
  186. data/lib/artikcloud/models/unregister_device_response_envelope.rb +4 -16
  187. data/lib/artikcloud/models/update_parameters.rb +188 -0
  188. data/lib/artikcloud/models/user.rb +28 -16
  189. data/lib/artikcloud/models/user_envelope.rb +8 -16
  190. data/lib/artikcloud/models/validation_callback_info.rb +198 -0
  191. data/lib/artikcloud/models/web_socket_error.rb +4 -16
  192. data/lib/artikcloud/version.rb +2 -14
  193. data/pom.xml +1 -1
  194. data/spec/api/devicesshares_api_spec.rb +87 -0
  195. data/spec/api/devicestatus_api_spec.rb +75 -0
  196. data/spec/api/subscriptions_api_spec.rb +112 -0
  197. metadata +58 -26
@@ -0,0 +1,218 @@
1
+ =begin
2
+ #ARTIK Cloud API
3
+
4
+ #No description 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
+ =end
11
+
12
+ require 'date'
13
+
14
+ module ArtikCloud
15
+ #
16
+ class DeviceSharing
17
+ # Share ID
18
+ attr_accessor :id
19
+
20
+ # Email
21
+ attr_accessor :email
22
+
23
+ # Status
24
+ attr_accessor :status
25
+
26
+ # Shared on
27
+ attr_accessor :shared_on
28
+
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'id' => :'id',
34
+ :'email' => :'email',
35
+ :'status' => :'status',
36
+ :'shared_on' => :'sharedOn'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'id' => :'String',
44
+ :'email' => :'String',
45
+ :'status' => :'String',
46
+ :'shared_on' => :'Integer'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ return unless attributes.is_a?(Hash)
54
+
55
+ # convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
57
+
58
+ if attributes.has_key?(:'id')
59
+ self.id = attributes[:'id']
60
+ end
61
+
62
+ if attributes.has_key?(:'email')
63
+ self.email = attributes[:'email']
64
+ end
65
+
66
+ if attributes.has_key?(:'status')
67
+ self.status = attributes[:'status']
68
+ end
69
+
70
+ if attributes.has_key?(:'sharedOn')
71
+ self.shared_on = attributes[:'sharedOn']
72
+ end
73
+
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properies with the reasons
78
+ def list_invalid_properties
79
+ invalid_properties = Array.new
80
+ return invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ return true
87
+ end
88
+
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
91
+ def ==(o)
92
+ return true if self.equal?(o)
93
+ self.class == o.class &&
94
+ id == o.id &&
95
+ email == o.email &&
96
+ status == o.status &&
97
+ shared_on == o.shared_on
98
+ end
99
+
100
+ # @see the `==` method
101
+ # @param [Object] Object to be compared
102
+ def eql?(o)
103
+ self == o
104
+ end
105
+
106
+ # Calculates hash code according to all attributes.
107
+ # @return [Fixnum] Hash code
108
+ def hash
109
+ [id, email, status, shared_on].hash
110
+ end
111
+
112
+ # Builds the object from hash
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ # @return [Object] Returns the model itself
115
+ def build_from_hash(attributes)
116
+ return nil unless attributes.is_a?(Hash)
117
+ self.class.swagger_types.each_pair do |key, type|
118
+ if type =~ /\AArray<(.*)>/i
119
+ # check to ensure the input is an array given that the the attribute
120
+ # is documented as an array but the input is not
121
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
122
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
123
+ end
124
+ elsif !attributes[self.class.attribute_map[key]].nil?
125
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
126
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
127
+ end
128
+
129
+ self
130
+ end
131
+
132
+ # Deserializes the data based on type
133
+ # @param string type Data type
134
+ # @param string value Value to be deserialized
135
+ # @return [Object] Deserialized data
136
+ def _deserialize(type, value)
137
+ case type.to_sym
138
+ when :DateTime
139
+ DateTime.parse(value)
140
+ when :Date
141
+ Date.parse(value)
142
+ when :String
143
+ value.to_s
144
+ when :Integer
145
+ value.to_i
146
+ when :Float
147
+ value.to_f
148
+ when :BOOLEAN
149
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
150
+ true
151
+ else
152
+ false
153
+ end
154
+ when :Object
155
+ # generic object (usually a Hash), return directly
156
+ value
157
+ when /\AArray<(?<inner_type>.+)>\z/
158
+ inner_type = Regexp.last_match[:inner_type]
159
+ value.map { |v| _deserialize(inner_type, v) }
160
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
161
+ k_type = Regexp.last_match[:k_type]
162
+ v_type = Regexp.last_match[:v_type]
163
+ {}.tap do |hash|
164
+ value.each do |k, v|
165
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
166
+ end
167
+ end
168
+ else # model
169
+ temp_model = ArtikCloud.const_get(type).new
170
+ temp_model.build_from_hash(value)
171
+ end
172
+ end
173
+
174
+ # Returns the string representation of the object
175
+ # @return [String] String presentation of the object
176
+ def to_s
177
+ to_hash.to_s
178
+ end
179
+
180
+ # to_body is an alias to to_hash (backward compatibility)
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_body
183
+ to_hash
184
+ end
185
+
186
+ # Returns the object in the form of hash
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_hash
189
+ hash = {}
190
+ self.class.attribute_map.each_pair do |attr, param|
191
+ value = self.send(attr)
192
+ next if value.nil?
193
+ hash[param] = _to_hash(value)
194
+ end
195
+ hash
196
+ end
197
+
198
+ # Outputs non-array value in the form of hash
199
+ # For object, use to_hash. Otherwise, just return the value
200
+ # @param [Object] value Any valid value
201
+ # @return [Hash] Returns the value in the form of hash
202
+ def _to_hash(value)
203
+ if value.is_a?(Array)
204
+ value.compact.map{ |v| _to_hash(v) }
205
+ elsif value.is_a?(Hash)
206
+ {}.tap do |hash|
207
+ value.each { |k, v| hash[k] = _to_hash(v) }
208
+ end
209
+ elsif value.respond_to? :to_hash
210
+ value.to_hash
211
+ else
212
+ value
213
+ end
214
+ end
215
+
216
+ end
217
+
218
+ end
@@ -0,0 +1,189 @@
1
+ =begin
2
+ #ARTIK Cloud API
3
+
4
+ #No description 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
+ =end
11
+
12
+ require 'date'
13
+
14
+ module ArtikCloud
15
+ #
16
+ class DeviceSharingArray
17
+ attr_accessor :shares
18
+
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'shares' => :'shares'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.swagger_types
29
+ {
30
+ :'shares' => :'Array<DeviceSharing>'
31
+ }
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
41
+
42
+ if attributes.has_key?(:'shares')
43
+ if (value = attributes[:'shares']).is_a?(Array)
44
+ self.shares = value
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+ # Show invalid properties with the reasons. Usually used together with valid?
51
+ # @return Array for valid properies with the reasons
52
+ def list_invalid_properties
53
+ invalid_properties = Array.new
54
+ return invalid_properties
55
+ end
56
+
57
+ # Check to see if the all the properties in the model are valid
58
+ # @return true if the model is valid
59
+ def valid?
60
+ return true
61
+ end
62
+
63
+ # Checks equality by comparing each attribute.
64
+ # @param [Object] Object to be compared
65
+ def ==(o)
66
+ return true if self.equal?(o)
67
+ self.class == o.class &&
68
+ shares == o.shares
69
+ end
70
+
71
+ # @see the `==` method
72
+ # @param [Object] Object to be compared
73
+ def eql?(o)
74
+ self == o
75
+ end
76
+
77
+ # Calculates hash code according to all attributes.
78
+ # @return [Fixnum] Hash code
79
+ def hash
80
+ [shares].hash
81
+ end
82
+
83
+ # Builds the object from hash
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ # @return [Object] Returns the model itself
86
+ def build_from_hash(attributes)
87
+ return nil unless attributes.is_a?(Hash)
88
+ self.class.swagger_types.each_pair do |key, type|
89
+ if type =~ /\AArray<(.*)>/i
90
+ # check to ensure the input is an array given that the the attribute
91
+ # is documented as an array but the input is not
92
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
93
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
94
+ end
95
+ elsif !attributes[self.class.attribute_map[key]].nil?
96
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
97
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
98
+ end
99
+
100
+ self
101
+ end
102
+
103
+ # Deserializes the data based on type
104
+ # @param string type Data type
105
+ # @param string value Value to be deserialized
106
+ # @return [Object] Deserialized data
107
+ def _deserialize(type, value)
108
+ case type.to_sym
109
+ when :DateTime
110
+ DateTime.parse(value)
111
+ when :Date
112
+ Date.parse(value)
113
+ when :String
114
+ value.to_s
115
+ when :Integer
116
+ value.to_i
117
+ when :Float
118
+ value.to_f
119
+ when :BOOLEAN
120
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
121
+ true
122
+ else
123
+ false
124
+ end
125
+ when :Object
126
+ # generic object (usually a Hash), return directly
127
+ value
128
+ when /\AArray<(?<inner_type>.+)>\z/
129
+ inner_type = Regexp.last_match[:inner_type]
130
+ value.map { |v| _deserialize(inner_type, v) }
131
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
132
+ k_type = Regexp.last_match[:k_type]
133
+ v_type = Regexp.last_match[:v_type]
134
+ {}.tap do |hash|
135
+ value.each do |k, v|
136
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
137
+ end
138
+ end
139
+ else # model
140
+ temp_model = ArtikCloud.const_get(type).new
141
+ temp_model.build_from_hash(value)
142
+ end
143
+ end
144
+
145
+ # Returns the string representation of the object
146
+ # @return [String] String presentation of the object
147
+ def to_s
148
+ to_hash.to_s
149
+ end
150
+
151
+ # to_body is an alias to to_hash (backward compatibility)
152
+ # @return [Hash] Returns the object in the form of hash
153
+ def to_body
154
+ to_hash
155
+ end
156
+
157
+ # Returns the object in the form of hash
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_hash
160
+ hash = {}
161
+ self.class.attribute_map.each_pair do |attr, param|
162
+ value = self.send(attr)
163
+ next if value.nil?
164
+ hash[param] = _to_hash(value)
165
+ end
166
+ hash
167
+ end
168
+
169
+ # Outputs non-array value in the form of hash
170
+ # For object, use to_hash. Otherwise, just return the value
171
+ # @param [Object] value Any valid value
172
+ # @return [Hash] Returns the value in the form of hash
173
+ def _to_hash(value)
174
+ if value.is_a?(Array)
175
+ value.compact.map{ |v| _to_hash(v) }
176
+ elsif value.is_a?(Hash)
177
+ {}.tap do |hash|
178
+ value.each { |k, v| hash[k] = _to_hash(v) }
179
+ end
180
+ elsif value.respond_to? :to_hash
181
+ value.to_hash
182
+ else
183
+ value
184
+ end
185
+ end
186
+
187
+ end
188
+
189
+ end
@@ -0,0 +1,214 @@
1
+ =begin
2
+ #ARTIK Cloud API
3
+
4
+ #No description 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
+ =end
11
+
12
+ require 'date'
13
+
14
+ module ArtikCloud
15
+ #
16
+ class DeviceSharingEnvelope
17
+ attr_accessor :total
18
+
19
+ attr_accessor :offset
20
+
21
+ attr_accessor :data
22
+
23
+ attr_accessor :count
24
+
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'total' => :'total',
30
+ :'offset' => :'offset',
31
+ :'data' => :'data',
32
+ :'count' => :'count'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.swagger_types
38
+ {
39
+ :'total' => :'Integer',
40
+ :'offset' => :'Integer',
41
+ :'data' => :'DeviceSharingArray',
42
+ :'count' => :'Integer'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'total')
55
+ self.total = attributes[:'total']
56
+ end
57
+
58
+ if attributes.has_key?(:'offset')
59
+ self.offset = attributes[:'offset']
60
+ end
61
+
62
+ if attributes.has_key?(:'data')
63
+ self.data = attributes[:'data']
64
+ end
65
+
66
+ if attributes.has_key?(:'count')
67
+ self.count = attributes[:'count']
68
+ end
69
+
70
+ end
71
+
72
+ # Show invalid properties with the reasons. Usually used together with valid?
73
+ # @return Array for valid properies with the reasons
74
+ def list_invalid_properties
75
+ invalid_properties = Array.new
76
+ return invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ return true
83
+ end
84
+
85
+ # Checks equality by comparing each attribute.
86
+ # @param [Object] Object to be compared
87
+ def ==(o)
88
+ return true if self.equal?(o)
89
+ self.class == o.class &&
90
+ total == o.total &&
91
+ offset == o.offset &&
92
+ data == o.data &&
93
+ count == o.count
94
+ end
95
+
96
+ # @see the `==` method
97
+ # @param [Object] Object to be compared
98
+ def eql?(o)
99
+ self == o
100
+ end
101
+
102
+ # Calculates hash code according to all attributes.
103
+ # @return [Fixnum] Hash code
104
+ def hash
105
+ [total, offset, data, count].hash
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def build_from_hash(attributes)
112
+ return nil unless attributes.is_a?(Hash)
113
+ self.class.swagger_types.each_pair do |key, type|
114
+ if type =~ /\AArray<(.*)>/i
115
+ # check to ensure the input is an array given that the the attribute
116
+ # is documented as an array but the input is not
117
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
118
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
119
+ end
120
+ elsif !attributes[self.class.attribute_map[key]].nil?
121
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
122
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
123
+ end
124
+
125
+ self
126
+ end
127
+
128
+ # Deserializes the data based on type
129
+ # @param string type Data type
130
+ # @param string value Value to be deserialized
131
+ # @return [Object] Deserialized data
132
+ def _deserialize(type, value)
133
+ case type.to_sym
134
+ when :DateTime
135
+ DateTime.parse(value)
136
+ when :Date
137
+ Date.parse(value)
138
+ when :String
139
+ value.to_s
140
+ when :Integer
141
+ value.to_i
142
+ when :Float
143
+ value.to_f
144
+ when :BOOLEAN
145
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
146
+ true
147
+ else
148
+ false
149
+ end
150
+ when :Object
151
+ # generic object (usually a Hash), return directly
152
+ value
153
+ when /\AArray<(?<inner_type>.+)>\z/
154
+ inner_type = Regexp.last_match[:inner_type]
155
+ value.map { |v| _deserialize(inner_type, v) }
156
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
157
+ k_type = Regexp.last_match[:k_type]
158
+ v_type = Regexp.last_match[:v_type]
159
+ {}.tap do |hash|
160
+ value.each do |k, v|
161
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
162
+ end
163
+ end
164
+ else # model
165
+ temp_model = ArtikCloud.const_get(type).new
166
+ temp_model.build_from_hash(value)
167
+ end
168
+ end
169
+
170
+ # Returns the string representation of the object
171
+ # @return [String] String presentation of the object
172
+ def to_s
173
+ to_hash.to_s
174
+ end
175
+
176
+ # to_body is an alias to to_hash (backward compatibility)
177
+ # @return [Hash] Returns the object in the form of hash
178
+ def to_body
179
+ to_hash
180
+ end
181
+
182
+ # Returns the object in the form of hash
183
+ # @return [Hash] Returns the object in the form of hash
184
+ def to_hash
185
+ hash = {}
186
+ self.class.attribute_map.each_pair do |attr, param|
187
+ value = self.send(attr)
188
+ next if value.nil?
189
+ hash[param] = _to_hash(value)
190
+ end
191
+ hash
192
+ end
193
+
194
+ # Outputs non-array value in the form of hash
195
+ # For object, use to_hash. Otherwise, just return the value
196
+ # @param [Object] value Any valid value
197
+ # @return [Hash] Returns the value in the form of hash
198
+ def _to_hash(value)
199
+ if value.is_a?(Array)
200
+ value.compact.map{ |v| _to_hash(v) }
201
+ elsif value.is_a?(Hash)
202
+ {}.tap do |hash|
203
+ value.each { |k, v| hash[k] = _to_hash(v) }
204
+ end
205
+ elsif value.respond_to? :to_hash
206
+ value.to_hash
207
+ else
208
+ value
209
+ end
210
+ end
211
+
212
+ end
213
+
214
+ end