aspose_storage_cloud 1.0.1 → 18.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/Aspose/Storage/api/storage_api.rb +982 -0
  3. data/lib/Aspose/Storage/api_client.rb +409 -0
  4. data/lib/Aspose/Storage/api_error.rb +54 -0
  5. data/lib/Aspose/Storage/configuration.rb +203 -0
  6. data/lib/Aspose/Storage/models/aspose_response.rb +215 -0
  7. data/lib/Aspose/Storage/models/copy_file_response.rb +215 -0
  8. data/lib/Aspose/Storage/models/create_folder_response.rb +215 -0
  9. data/lib/Aspose/Storage/models/disc_usage.rb +220 -0
  10. data/lib/Aspose/Storage/models/disc_usage_response.rb +224 -0
  11. data/lib/Aspose/Storage/models/file_exist.rb +220 -0
  12. data/lib/Aspose/Storage/models/file_exist_response.rb +224 -0
  13. data/lib/Aspose/Storage/models/file_response.rb +266 -0
  14. data/lib/Aspose/Storage/models/file_version.rb +284 -0
  15. data/lib/Aspose/Storage/models/file_versions_response.rb +226 -0
  16. data/lib/Aspose/Storage/models/files_response.rb +226 -0
  17. data/lib/Aspose/Storage/models/move_file_response.rb +215 -0
  18. data/lib/Aspose/Storage/models/move_folder_response.rb +215 -0
  19. data/lib/Aspose/Storage/models/remove_file_response.rb +215 -0
  20. data/lib/Aspose/Storage/models/remove_folder_response.rb +215 -0
  21. data/lib/Aspose/Storage/models/requests/delete_file_request.rb +57 -0
  22. data/lib/Aspose/Storage/models/requests/delete_folder_request.rb +57 -0
  23. data/lib/Aspose/Storage/models/requests/get_disc_usage_request.rb +47 -0
  24. data/lib/Aspose/Storage/models/requests/get_download_request.rb +57 -0
  25. data/lib/Aspose/Storage/models/requests/get_is_exist_request.rb +57 -0
  26. data/lib/Aspose/Storage/models/requests/get_is_storage_exist_request.rb +47 -0
  27. data/lib/Aspose/Storage/models/requests/get_list_file_versions_request.rb +52 -0
  28. data/lib/Aspose/Storage/models/requests/get_list_files_request.rb +52 -0
  29. data/lib/Aspose/Storage/models/requests/post_move_file_request.rb +67 -0
  30. data/lib/Aspose/Storage/models/requests/post_move_folder_request.rb +62 -0
  31. data/lib/Aspose/Storage/models/requests/put_copy_folder_request.rb +62 -0
  32. data/lib/Aspose/Storage/models/requests/put_copy_request.rb +67 -0
  33. data/lib/Aspose/Storage/models/requests/put_create_folder_request.rb +57 -0
  34. data/lib/Aspose/Storage/models/requests/put_create_request.rb +62 -0
  35. data/lib/Aspose/Storage/models/storage_exist_response.rb +224 -0
  36. data/lib/Aspose/Storage/models/upload_response.rb +215 -0
  37. data/lib/Aspose/Storage/version.rb +29 -0
  38. data/lib/aspose_storage_cloud.rb +71 -41
  39. metadata +62 -55
  40. data/.gitignore +0 -36
  41. data/LICENSE +0 -22
  42. data/README.md +0 -40
  43. data/aspose_storage_cloud.gemspec +0 -25
  44. data/lib/aspose_storage_cloud/api/storage_api.rb +0 -800
  45. data/lib/aspose_storage_cloud/api_client.rb +0 -333
  46. data/lib/aspose_storage_cloud/api_error.rb +0 -24
  47. data/lib/aspose_storage_cloud/aspose_app.rb +0 -20
  48. data/lib/aspose_storage_cloud/configuration.rb +0 -166
  49. data/lib/aspose_storage_cloud/models/base_object.rb +0 -88
  50. data/lib/aspose_storage_cloud/models/base_response.rb +0 -53
  51. data/lib/aspose_storage_cloud/models/disc_usage.rb +0 -45
  52. data/lib/aspose_storage_cloud/models/disc_usage_response.rb +0 -61
  53. data/lib/aspose_storage_cloud/models/file_exist.rb +0 -44
  54. data/lib/aspose_storage_cloud/models/file_exist_response.rb +0 -62
  55. data/lib/aspose_storage_cloud/models/file_response.rb +0 -69
  56. data/lib/aspose_storage_cloud/models/file_version.rb +0 -85
  57. data/lib/aspose_storage_cloud/models/file_versions_response.rb +0 -63
  58. data/lib/aspose_storage_cloud/models/folder_response.rb +0 -63
  59. data/lib/aspose_storage_cloud/models/storage_exist_response.rb +0 -61
  60. data/lib/aspose_storage_cloud/version.rb +0 -3
  61. data/test/data/SampleExecuteTemplate.doc +0 -0
  62. data/test/data/SampleExecuteTemplateData.txt +0 -49
  63. data/test/data/SampleWordDocument.docx +0 -0
  64. data/test/data/buzz.png +0 -0
  65. data/test/data/testfile.txt +0 -1
  66. data/test/storage_tests.rb +0 -134
@@ -0,0 +1,203 @@
1
+ # --------------------------------------------------------------------------------------------------------------------
2
+ # <copyright company="Aspose Pty Ltd" file="configuration.rb">
3
+ # Copyright (c) 2018 Aspose.Storage for Cloud
4
+ # </copyright>
5
+ # <summary>
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ # </summary>
24
+ # --------------------------------------------------------------------------------------------------------------------
25
+
26
+ require 'uri'
27
+
28
+ module AsposeStorageCloud
29
+ #
30
+ # Class for storing API configuration info
31
+ #
32
+ class Configuration
33
+
34
+ # Defines v1 api version
35
+ V1_API_VERSION = '/v1'
36
+
37
+ # Defines v2 api version
38
+ V2_API_VERSION = '/v2'
39
+
40
+ # Defines v3 api version
41
+ V3_API_VERSION = '/v3'
42
+
43
+ # Defines v1.1 api version
44
+ V1_1_API_VERSION = '/v1.1'
45
+
46
+ # Defines url scheme
47
+ attr_accessor :scheme
48
+
49
+ # Defines url host
50
+ attr_accessor :host
51
+
52
+ # Defines url api version
53
+ attr_accessor :api_version
54
+
55
+ # Defines API keys used with API Key authentications.
56
+ #
57
+ # @return [Hash] key: parameter name, value: parameter value (API key)
58
+ #
59
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
60
+ # config.api_key['api_key'] = 'xxx'
61
+ attr_accessor :api_key
62
+
63
+ # Defines API key prefixes used with API Key authentications.
64
+ #
65
+ # @return [Hash] key: parameter name, value: API key prefix
66
+ #
67
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
68
+ # config.api_key_prefix['api_key'] = 'Token'
69
+ attr_accessor :api_key_prefix
70
+
71
+ # Defines the username used with HTTP basic authentication.
72
+ #
73
+ # @return [String]
74
+ attr_accessor :username
75
+
76
+ # Defines the password used with HTTP basic authentication.
77
+ #
78
+ # @return [String]
79
+ attr_accessor :password
80
+
81
+ # Defines the access token (Bearer) used with OAuth2.
82
+ attr_accessor :access_token
83
+
84
+ # Defines the refresh token (Bearer) used with OAuth2.
85
+ attr_accessor :refresh_token
86
+
87
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
88
+ # details will be logged with `logger.debug` (see the `logger` attribute).
89
+ # Default to false.
90
+ #
91
+ # @return [true, false]
92
+ attr_accessor :debugging
93
+
94
+ # Defines the logger used for debugging.
95
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
96
+ #
97
+ # @return [#debug]
98
+ attr_accessor :logger
99
+
100
+ # Defines the temporary folder to store downloaded files
101
+ # (for API endpoints that have file response).
102
+ # Default to use `Tempfile`.
103
+ #
104
+ # @return [String]
105
+ attr_accessor :temp_folder_path
106
+
107
+ # Set this to false to skip client side validation in the operation.
108
+ # Default to true.
109
+ # @return [true, false]
110
+ attr_accessor :client_side_validation
111
+
112
+
113
+ def initialize
114
+ @scheme = 'https'
115
+ @host = 'api.aspose.cloud'
116
+ @api_version = V1_API_VERSION
117
+ @api_key = {}
118
+ @api_key_prefix = {}
119
+ @client_side_validation = true
120
+ @debugging = false
121
+ @logger = Logger.new(STDOUT)
122
+
123
+ yield(self) if block_given?
124
+ end
125
+
126
+ # The default Configuration object.
127
+ def self.default
128
+ @@default ||= Configuration.new
129
+ end
130
+
131
+ # yield self
132
+ def configure
133
+ yield(self) if block_given?
134
+ end
135
+
136
+ # sets the scheme
137
+ def scheme=(scheme)
138
+ # remove :// from scheme
139
+ @scheme = scheme.sub(/:\/\//, '')
140
+ end
141
+
142
+ # sets the host
143
+ def host=(host)
144
+ # remove http(s):// and anything after a slash
145
+ @host = host.sub(/https?:\/\//, '').split('/').first
146
+ end
147
+
148
+ # sets the api_version
149
+ def api_version=(api_version)
150
+ # Add leading and trailing slashes to api_version
151
+ @api_version = "/#{api_version}".gsub(/\/+/, '/')
152
+ @api_version = "" if @api_version == "/"
153
+ end
154
+
155
+ # returns base url
156
+ def base_url
157
+ url = "#{scheme}://#{[host, api_version].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
158
+ URI.encode(url)
159
+ end
160
+
161
+ # Gets API key (with prefix if set).
162
+ # @param [String] param_name the parameter name of API key auth
163
+ def api_key_with_prefix(param_name)
164
+ if @api_key_prefix[param_name]
165
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
166
+ else
167
+ @api_key[param_name]
168
+ end
169
+ end
170
+
171
+ # Gets Basic Auth token string
172
+ def basic_auth_token
173
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
174
+ end
175
+
176
+ # Returns Auth Settings hash for api client.
177
+ def auth_settings
178
+ {
179
+ 'appsid' =>
180
+ {
181
+ type: 'api_key',
182
+ in: 'query',
183
+ key: 'appsid',
184
+ value: api_key_with_prefix('appsid')
185
+ },
186
+ 'oauth' =>
187
+ {
188
+ type: 'oauth2',
189
+ in: 'header',
190
+ key: 'Authorization',
191
+ value: "Bearer #{access_token}"
192
+ },
193
+ 'signature' =>
194
+ {
195
+ type: 'api_key',
196
+ in: 'query',
197
+ key: 'signature',
198
+ value: api_key_with_prefix('signature')
199
+ },
200
+ }
201
+ end
202
+ end
203
+ end
@@ -0,0 +1,215 @@
1
+ module AsposeStorageCloud
2
+ #
3
+ # --------------------------------------------------------------------------------------------------------------------
4
+ # <copyright company="Aspose Pty Ltd" file="AsposeResponse.rb">
5
+ # Copyright (c) 2018 Aspose.Storage for Cloud
6
+ # </copyright>
7
+ # <summary>
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+ # </summary>
26
+ # --------------------------------------------------------------------------------------------------------------------
27
+ #
28
+
29
+
30
+ class AsposeResponse
31
+ attr_accessor :code
32
+
33
+ attr_accessor :status
34
+
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'code' => :'Code',
40
+ :'status' => :'Status'
41
+ }
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.swagger_types
46
+ {
47
+ :'code' => :'Integer',
48
+ :'status' => :'String'
49
+ }
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ return unless attributes.is_a?(Hash)
56
+
57
+ # convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
59
+
60
+ if attributes.has_key?(:'Code')
61
+ self.code = attributes[:'Code']
62
+ end
63
+
64
+ if attributes.has_key?(:'Status')
65
+ self.status = attributes[:'Status']
66
+ end
67
+
68
+ end
69
+
70
+ # Show invalid properties with the reasons. Usually used together with valid?
71
+ # @return Array for valid properies with the reasons
72
+ def list_invalid_properties
73
+ invalid_properties = Array.new
74
+ if @code.nil?
75
+ invalid_properties.push("invalid value for 'code', code cannot be nil.")
76
+ end
77
+
78
+ return invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ return false if @code.nil?
85
+ return true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ code == o.code &&
94
+ status == o.status
95
+ end
96
+
97
+ # @see the `==` method
98
+ # @param [Object] Object to be compared
99
+ def eql?(o)
100
+ self == o
101
+ end
102
+
103
+ # Calculates hash code according to all attributes.
104
+ # @return [Fixnum] Hash code
105
+ def hash
106
+ [code, status].hash
107
+ end
108
+
109
+ # Builds the object from hash
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ # @return [Object] Returns the model itself
112
+ def build_from_hash(attributes)
113
+ return nil unless attributes.is_a?(Hash)
114
+ self.class.swagger_types.each_pair do |key, type|
115
+ if type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :DateTime
136
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
137
+ Time.strptime(value, format).utc.to_datetime
138
+ when :Date
139
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
140
+ Time.strptime(value, format).utc.to_datetime.to_date
141
+ when :String
142
+ value.to_s
143
+ when :Integer
144
+ value.to_i
145
+ when :Float
146
+ value.to_f
147
+ when :BOOLEAN
148
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
149
+ true
150
+ else
151
+ false
152
+ end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ else # model
168
+ temp_model = AsposeStorageCloud.const_get(type).new
169
+ temp_model.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ next if value.nil?
192
+ hash[param] = _to_hash(value)
193
+ end
194
+ hash
195
+ end
196
+
197
+ # Outputs non-array value in the form of hash
198
+ # For object, use to_hash. Otherwise, just return the value
199
+ # @param [Object] value Any valid value
200
+ # @return [Hash] Returns the value in the form of hash
201
+ def _to_hash(value)
202
+ if value.is_a?(Array)
203
+ value.compact.map{ |v| _to_hash(v) }
204
+ elsif value.is_a?(Hash)
205
+ {}.tap do |hash|
206
+ value.each { |k, v| hash[k] = _to_hash(v) }
207
+ end
208
+ elsif value.respond_to? :to_hash
209
+ value.to_hash
210
+ else
211
+ value
212
+ end
213
+ end
214
+ end
215
+ end
@@ -0,0 +1,215 @@
1
+ module AsposeStorageCloud
2
+ #
3
+ # --------------------------------------------------------------------------------------------------------------------
4
+ # <copyright company="Aspose Pty Ltd" file="CopyFileResponse.rb">
5
+ # Copyright (c) 2018 Aspose.Storage for Cloud
6
+ # </copyright>
7
+ # <summary>
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ # of this software and associated documentation files (the "Software"), to deal
10
+ # in the Software without restriction, including without limitation the rights
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ # copies of the Software, and to permit persons to whom the Software is
13
+ # furnished to do so, subject to the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included in all
16
+ # copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ # SOFTWARE.
25
+ # </summary>
26
+ # --------------------------------------------------------------------------------------------------------------------
27
+ #
28
+
29
+
30
+ class CopyFileResponse
31
+ attr_accessor :code
32
+
33
+ attr_accessor :status
34
+
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'code' => :'Code',
40
+ :'status' => :'Status'
41
+ }
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.swagger_types
46
+ {
47
+ :'code' => :'Integer',
48
+ :'status' => :'String'
49
+ }
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ return unless attributes.is_a?(Hash)
56
+
57
+ # convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
59
+
60
+ if attributes.has_key?(:'Code')
61
+ self.code = attributes[:'Code']
62
+ end
63
+
64
+ if attributes.has_key?(:'Status')
65
+ self.status = attributes[:'Status']
66
+ end
67
+
68
+ end
69
+
70
+ # Show invalid properties with the reasons. Usually used together with valid?
71
+ # @return Array for valid properies with the reasons
72
+ def list_invalid_properties
73
+ invalid_properties = Array.new
74
+ if @code.nil?
75
+ invalid_properties.push("invalid value for 'code', code cannot be nil.")
76
+ end
77
+
78
+ return invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ return false if @code.nil?
85
+ return true
86
+ end
87
+
88
+ # Checks equality by comparing each attribute.
89
+ # @param [Object] Object to be compared
90
+ def ==(o)
91
+ return true if self.equal?(o)
92
+ self.class == o.class &&
93
+ code == o.code &&
94
+ status == o.status
95
+ end
96
+
97
+ # @see the `==` method
98
+ # @param [Object] Object to be compared
99
+ def eql?(o)
100
+ self == o
101
+ end
102
+
103
+ # Calculates hash code according to all attributes.
104
+ # @return [Fixnum] Hash code
105
+ def hash
106
+ [code, status].hash
107
+ end
108
+
109
+ # Builds the object from hash
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ # @return [Object] Returns the model itself
112
+ def build_from_hash(attributes)
113
+ return nil unless attributes.is_a?(Hash)
114
+ self.class.swagger_types.each_pair do |key, type|
115
+ if type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :DateTime
136
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
137
+ Time.strptime(value, format).utc.to_datetime
138
+ when :Date
139
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
140
+ Time.strptime(value, format).utc.to_datetime.to_date
141
+ when :String
142
+ value.to_s
143
+ when :Integer
144
+ value.to_i
145
+ when :Float
146
+ value.to_f
147
+ when :BOOLEAN
148
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
149
+ true
150
+ else
151
+ false
152
+ end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ else # model
168
+ temp_model = AsposeStorageCloud.const_get(type).new
169
+ temp_model.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ next if value.nil?
192
+ hash[param] = _to_hash(value)
193
+ end
194
+ hash
195
+ end
196
+
197
+ # Outputs non-array value in the form of hash
198
+ # For object, use to_hash. Otherwise, just return the value
199
+ # @param [Object] value Any valid value
200
+ # @return [Hash] Returns the value in the form of hash
201
+ def _to_hash(value)
202
+ if value.is_a?(Array)
203
+ value.compact.map{ |v| _to_hash(v) }
204
+ elsif value.is_a?(Hash)
205
+ {}.tap do |hash|
206
+ value.each { |k, v| hash[k] = _to_hash(v) }
207
+ end
208
+ elsif value.respond_to? :to_hash
209
+ value.to_hash
210
+ else
211
+ value
212
+ end
213
+ end
214
+ end
215
+ end