aspose_words_cloud 22.6.0 → 22.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82f2fe21cc7cfad88d426c8a7cfda7ac0aff06101e9e6c9c4ef4a6aa5110538e
4
- data.tar.gz: 3a8cc3f49e33cfa7976f06f28553e017fdbc39cda58367d0e500f980924f6deb
3
+ metadata.gz: 24d889c609459df4f949e996b07ff946f1181c96e2e9720e26233608a3d89524
4
+ data.tar.gz: 625556fca9af5c2500b5191453fb9b1f7cdfef2be0afd747a529ee3f282db5eb
5
5
  SHA512:
6
- metadata.gz: 65ec40476887045adfb1c130dd77c1297c4647e52378aac7eb648fc40c804c31f414b02959877a8f9cde39e5829b6d9473cc0e41f1552fa588e9af74be1cf1d7
7
- data.tar.gz: f30060192c4990da32c3f96c378f682f35dfafd254c8da7b955b06759b9d59d10b04e80879405365363bc49d575063c255699b5e5480d57af08ecc3ca95509d3
6
+ metadata.gz: 8f9f94eed382cde063c1c94ec6fcfdae4b366392e4565a165bbf80e64d2213bd2b1ca24e7ca346f1d495a0546cd3c632b81721368755ce9c004270ab0aa5d9c2
7
+ data.tar.gz: fbfa60687b53ce793c8a94b054c5b4e562ee8f6867a6bcc199bc1bc24e2f90c79048a650f7a10ec3a8edfc39ed1dee2c3c36e1537b3f29b528479a48101c02ca
@@ -1030,6 +1030,155 @@ module AsposeWordsCloud
1030
1030
  [mp_data, status_code, headers]
1031
1031
  end
1032
1032
 
1033
+ # The default settings allows to reduce the size of the document without any visible degradation of images quality.
1034
+ # @param request CompressDocumentRequest
1035
+ # @return [CompressResponse]
1036
+ def compress_document(request)
1037
+ begin
1038
+ data, _status_code, _headers = compress_document_with_http_info(request)
1039
+ rescue ApiError => e
1040
+ if e.code == 401
1041
+ request_token
1042
+ data, _status_code, _headers = compress_document_with_http_info(request)
1043
+ else
1044
+ raise
1045
+ end
1046
+ end
1047
+ data
1048
+ end
1049
+
1050
+ # The default settings allows to reduce the size of the document without any visible degradation of images quality.
1051
+ # @param request CompressDocumentRequest
1052
+ # @return [Array<(CompressResponse, Fixnum, Hash)>]
1053
+ # CompressResponse, response status code and response headers
1054
+ private def compress_document_with_http_info(request)
1055
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? CompressDocumentRequest
1056
+
1057
+ @api_client.config.logger.debug 'Calling API: WordsApi.compress_document ...' if @api_client.config.debugging
1058
+ # verify the required parameter 'name' is set
1059
+ raise ArgumentError, 'Missing the required parameter name when calling WordsApi.compress_document' if @api_client.config.client_side_validation && request.name.nil?
1060
+ # verify the required parameter 'compress_options' is set
1061
+ raise ArgumentError, 'Missing the required parameter compress_options when calling WordsApi.compress_document' if @api_client.config.client_side_validation && request.compress_options.nil?
1062
+
1063
+ # resource path
1064
+ local_var_path = '/words/{name}/compress'[1..-1]
1065
+ local_var_path = local_var_path.sub('{' + downcase_first_letter('Name') + '}', request.name.nil? ? '' : request.name.to_s)
1066
+ local_var_path = local_var_path.sub('//', '/')
1067
+
1068
+ # query parameters
1069
+ query_params = {}
1070
+ query_params[downcase_first_letter('Folder')] = request.folder unless request.folder.nil?
1071
+ query_params[downcase_first_letter('Storage')] = request.storage unless request.storage.nil?
1072
+ query_params[downcase_first_letter('LoadEncoding')] = request.load_encoding unless request.load_encoding.nil?
1073
+ query_params[downcase_first_letter('Password')] = request.password unless request.password.nil?
1074
+ query_params[downcase_first_letter('EncryptedPassword')] = request.encrypted_password unless request.encrypted_password.nil?
1075
+ query_params[downcase_first_letter('DestFileName')] = request.dest_file_name unless request.dest_file_name.nil?
1076
+
1077
+ # header parameters
1078
+ header_params = {}
1079
+ # HTTP header 'Accept' (if needed)
1080
+ header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
1081
+ # HTTP header 'Content-Type'
1082
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/xml', 'application/json'])
1083
+
1084
+ # form parameters
1085
+ form_params = {}
1086
+
1087
+ # http body (model)
1088
+ post_body = @api_client.object_to_http_body(request.compress_options)
1089
+ auth_names = ['JWT']
1090
+
1091
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
1092
+ header_params: header_params,
1093
+ query_params: query_params,
1094
+ form_params: form_params,
1095
+ body: post_body,
1096
+ auth_names: auth_names,
1097
+ return_type: 'CompressResponse')
1098
+ if @api_client.config.debugging
1099
+ @api_client.config.logger.debug "API called:
1100
+ WordsApi#compress_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1101
+ end
1102
+
1103
+ [data, status_code, headers]
1104
+ end
1105
+
1106
+ # Compress and resize images inside the document.
1107
+ # @param request CompressDocumentOnlineRequest
1108
+ # @return [CompressDocumentOnlineResponse]
1109
+ def compress_document_online(request)
1110
+ begin
1111
+ data, _status_code, _headers = compress_document_online_with_http_info(request)
1112
+ rescue ApiError => e
1113
+ if e.code == 401
1114
+ request_token
1115
+ data, _status_code, _headers = compress_document_online_with_http_info(request)
1116
+ else
1117
+ raise
1118
+ end
1119
+ end
1120
+ data
1121
+ end
1122
+
1123
+ # Compress and resize images inside the document.
1124
+ # @param request CompressDocumentOnlineRequest
1125
+ # @return [Array<(CompressDocumentOnlineResponse, Fixnum, Hash)>]
1126
+ # CompressDocumentOnlineResponse, response status code and response headers
1127
+ private def compress_document_online_with_http_info(request)
1128
+ raise ArgumentError, 'Incorrect request type' unless request.is_a? CompressDocumentOnlineRequest
1129
+
1130
+ @api_client.config.logger.debug 'Calling API: WordsApi.compress_document_online ...' if @api_client.config.debugging
1131
+ # verify the required parameter 'document' is set
1132
+ raise ArgumentError, 'Missing the required parameter document when calling WordsApi.compress_document_online' if @api_client.config.client_side_validation && request.document.nil?
1133
+ # verify the required parameter 'compress_options' is set
1134
+ raise ArgumentError, 'Missing the required parameter compress_options when calling WordsApi.compress_document_online' if @api_client.config.client_side_validation && request.compress_options.nil?
1135
+
1136
+ # resource path
1137
+ local_var_path = '/words/online/put/compress'[1..-1]
1138
+ local_var_path = local_var_path.sub('//', '/')
1139
+
1140
+ # query parameters
1141
+ query_params = {}
1142
+ query_params[downcase_first_letter('LoadEncoding')] = request.load_encoding unless request.load_encoding.nil?
1143
+ query_params[downcase_first_letter('Password')] = request.password unless request.password.nil?
1144
+ query_params[downcase_first_letter('EncryptedPassword')] = request.encrypted_password unless request.encrypted_password.nil?
1145
+ query_params[downcase_first_letter('DestFileName')] = request.dest_file_name unless request.dest_file_name.nil?
1146
+
1147
+ # header parameters
1148
+ header_params = {}
1149
+ # HTTP header 'Accept' (if needed)
1150
+ header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
1151
+ # HTTP header 'Content-Type'
1152
+ header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
1153
+
1154
+ # form parameters
1155
+ form_params = {}
1156
+ form_params[downcase_first_letter('Document')] = request.document
1157
+ form_params[downcase_first_letter('CompressOptions')] = request.compress_options.to_body.to_json
1158
+
1159
+ # http body (model)
1160
+ post_body = nil
1161
+ auth_names = ['JWT']
1162
+
1163
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
1164
+ header_params: header_params,
1165
+ query_params: query_params,
1166
+ form_params: form_params,
1167
+ body: post_body,
1168
+ auth_names: auth_names,
1169
+ multipart_response: true,
1170
+ return_type: 'CompressDocumentOnlineResponse')
1171
+ if @api_client.config.debugging
1172
+ @api_client.config.logger.debug "API called:
1173
+ WordsApi#compress_document_online\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1174
+ end
1175
+
1176
+ mp_data = CompressDocumentOnlineResponse.new()
1177
+ mp_data.model = @api_client.deserialize(data['Model'][:data], data['Model'][:headers], 'CompressResponse')
1178
+ mp_data.document = @api_client.parse_files_collection(data['Document'][:data], data['Document'][:headers])
1179
+ [mp_data, status_code, headers]
1180
+ end
1181
+
1033
1182
  # Converts a document on a local drive to the specified format.
1034
1183
  # @param request ConvertDocumentRequest
1035
1184
  # @return [File]
@@ -141,24 +141,22 @@ module AsposeWordsCloud
141
141
  end
142
142
  end
143
143
 
144
- conn = Faraday.new url, { :params => query_params, :headers => header_params } do |f|
144
+ conn = Faraday.new url, { :params => query_params, :headers => header_params, request: { timeout: @config.timeout }} do |f|
145
145
  f.request :multipart
146
146
  f.request :url_encoded
147
147
  f.adapter Faraday.default_adapter
148
148
  end
149
149
 
150
- Timeout.timeout(@config.timeout) do
151
- case http_method
152
- when :post
153
- return conn.post url, req_opts[:body]
154
- when :put
155
- return conn.put url, req_opts[:body]
156
- when :get
157
- return conn.get url, req_opts[:body]
158
- else
159
- conn.delete url do |c|
160
- c.body = req_opts[:body]
161
- end
150
+ case http_method
151
+ when :post
152
+ return conn.post url, req_opts[:body]
153
+ when :put
154
+ return conn.put url, req_opts[:body]
155
+ when :get
156
+ return conn.get url, req_opts[:body]
157
+ else
158
+ conn.delete url do |c|
159
+ c.body = req_opts[:body]
162
160
  end
163
161
  end
164
162
  end
@@ -108,6 +108,7 @@ module AsposeWordsCloud
108
108
  @client_side_validation = true
109
109
  @debugging = false
110
110
  @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
111
+ @timeout = 60
111
112
 
112
113
  yield(self) if block_given?
113
114
  end
@@ -0,0 +1,201 @@
1
+ # ------------------------------------------------------------------------------------
2
+ # <copyright company="Aspose" file="base_entry.rb">
3
+ # Copyright (c) 2022 Aspose.Words 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 'date'
27
+
28
+ module AsposeWordsCloud
29
+
30
+ # Represents a entry which will be appended to the original resource document.
31
+ class BaseEntry
32
+ # Gets or sets the path to entry to append at the server.
33
+ attr_accessor :href
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'href' => :'Href'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.swagger_types
43
+ {
44
+ :'href' => :'String'
45
+ }
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ return unless attributes.is_a?(Hash)
52
+
53
+ # convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
55
+
56
+ if attributes.key?(:'Href')
57
+ self.href = attributes[:'Href']
58
+ end
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 = []
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 ==(other)
77
+ return true if self.equal?(other)
78
+ self.class == other.class &&
79
+ href == other.href
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(other)
85
+ self == other
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Fixnum] Hash code
90
+ def hash
91
+ [href].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 =~ /\AArray<(.*)>/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
109
+ # or else data not found in attributes(hash), not an issue as the data can be optional
110
+ end
111
+
112
+ self
113
+ end
114
+
115
+ # Deserializes the data based on type
116
+ # @param string type Data type
117
+ # @param string value Value to be deserialized
118
+ # @return [Object] Deserialized data
119
+ def _deserialize(type, value)
120
+ case type.to_sym
121
+ when :DateTime
122
+ Time.at(/\d/.match(value)[0].to_f).to_datetime
123
+ when :Date
124
+ Time.at(/\d/.match(value)[0].to_f).to_date
125
+ when :String
126
+ value.to_s
127
+ when :Integer
128
+ value.to_i
129
+ when :Float
130
+ value.to_f
131
+ when :BOOLEAN
132
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
133
+ true
134
+ else
135
+ false
136
+ end
137
+ when :Object
138
+ # generic object (usually a Hash), return directly
139
+ value
140
+ when /\AArray<(?<inner_type>.+)>\z/
141
+ inner_type = Regexp.last_match[:inner_type]
142
+ value.map { |v| _deserialize(inner_type, v) }
143
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
144
+ k_type = Regexp.last_match[:k_type]
145
+ v_type = Regexp.last_match[:v_type]
146
+ {}.tap do |hash|
147
+ value.each do |k, v|
148
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
149
+ end
150
+ end
151
+ else
152
+ # model
153
+ temp_model = AsposeWordsCloud.const_get(type).new
154
+ temp_model.build_from_hash(value)
155
+ end
156
+ end
157
+
158
+ # Returns the string representation of the object
159
+ # @return [String] String presentation of the object
160
+ def to_s
161
+ to_hash.to_s
162
+ end
163
+
164
+ # to_body is an alias to to_hash (backward compatibility)
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_body
167
+ to_hash
168
+ end
169
+
170
+ # Returns the object in the form of hash
171
+ # @return [Hash] Returns the object in the form of hash
172
+ def to_hash
173
+ hash = {}
174
+ self.class.attribute_map.each_pair do |attr, param|
175
+ value = self.send(attr)
176
+ next if value.nil?
177
+ hash[param] = _to_hash(value)
178
+ end
179
+ hash
180
+ end
181
+
182
+ # Outputs non-array value in the form of hash
183
+ # For object, use to_hash. Otherwise, just return the value
184
+ # @param [Object] value Any valid value
185
+ # @return [Hash] Returns the value in the form of hash
186
+ def _to_hash(value)
187
+ if value.is_a?(Array)
188
+ value.compact.map { |v| _to_hash(v) }
189
+ elsif value.is_a?(Hash)
190
+ {}.tap do |hash|
191
+ value.each { |k, v| hash[k] = _to_hash(v) }
192
+ end
193
+ elsif value.respond_to? :to_hash
194
+ value.to_hash
195
+ else
196
+ value
197
+ end
198
+ end
199
+
200
+ end
201
+ end
@@ -0,0 +1,213 @@
1
+ # ------------------------------------------------------------------------------------
2
+ # <copyright company="Aspose" file="compress_options.rb">
3
+ # Copyright (c) 2022 Aspose.Words 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 'date'
27
+
28
+ module AsposeWordsCloud
29
+
30
+ # Options of document compress.
31
+ class CompressOptions
32
+ # Gets or sets the quality level of images from 0 to 100. Default value is 75.
33
+ attr_accessor :images_quality
34
+
35
+ # Gets or sets the resize factor of images.
36
+ # This value determines how many times the size of the images in the document will be reduced.
37
+ # The parameter value must be greater than 1 for resizing. Default value is 1 and has no effect on images size.
38
+ attr_accessor :images_reduce_size_factor
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'images_quality' => :'ImagesQuality',
43
+ :'images_reduce_size_factor' => :'ImagesReduceSizeFactor'
44
+ }
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.swagger_types
49
+ {
50
+ :'images_quality' => :'Integer',
51
+ :'images_reduce_size_factor' => :'Integer'
52
+ }
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ return unless attributes.is_a?(Hash)
59
+
60
+ # convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
62
+
63
+ if attributes.key?(:'ImagesQuality')
64
+ self.images_quality = attributes[:'ImagesQuality']
65
+ end
66
+
67
+ if attributes.key?(:'ImagesReduceSizeFactor')
68
+ self.images_reduce_size_factor = attributes[:'ImagesReduceSizeFactor']
69
+ end
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 = []
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 ==(other)
88
+ return true if self.equal?(other)
89
+ self.class == other.class &&
90
+ images_quality == other.images_quality &&
91
+ images_reduce_size_factor == other.images_reduce_size_factor
92
+ end
93
+
94
+ # @see the `==` method
95
+ # @param [Object] Object to be compared
96
+ def eql?(other)
97
+ self == other
98
+ end
99
+
100
+ # Calculates hash code according to all attributes.
101
+ # @return [Fixnum] Hash code
102
+ def hash
103
+ [images_quality, images_reduce_size_factor].hash
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ self.class.swagger_types.each_pair do |key, type|
112
+ if type =~ /\AArray<(.*)>/i
113
+ # check to ensure the input is an array given that the the attribute
114
+ # is documented as an array but the input is not
115
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
116
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
117
+ end
118
+ elsif !attributes[self.class.attribute_map[key]].nil?
119
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
+ end
121
+ # or else data not found in attributes(hash), not an issue as the data can be optional
122
+ end
123
+
124
+ self
125
+ end
126
+
127
+ # Deserializes the data based on type
128
+ # @param string type Data type
129
+ # @param string value Value to be deserialized
130
+ # @return [Object] Deserialized data
131
+ def _deserialize(type, value)
132
+ case type.to_sym
133
+ when :DateTime
134
+ Time.at(/\d/.match(value)[0].to_f).to_datetime
135
+ when :Date
136
+ Time.at(/\d/.match(value)[0].to_f).to_date
137
+ when :String
138
+ value.to_s
139
+ when :Integer
140
+ value.to_i
141
+ when :Float
142
+ value.to_f
143
+ when :BOOLEAN
144
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
145
+ true
146
+ else
147
+ false
148
+ end
149
+ when :Object
150
+ # generic object (usually a Hash), return directly
151
+ value
152
+ when /\AArray<(?<inner_type>.+)>\z/
153
+ inner_type = Regexp.last_match[:inner_type]
154
+ value.map { |v| _deserialize(inner_type, v) }
155
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
156
+ k_type = Regexp.last_match[:k_type]
157
+ v_type = Regexp.last_match[:v_type]
158
+ {}.tap do |hash|
159
+ value.each do |k, v|
160
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
161
+ end
162
+ end
163
+ else
164
+ # model
165
+ temp_model = AsposeWordsCloud.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
+ end