cloudmersive-convert-api-client 1.7.4 → 1.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -4
- data/docs/DocxParagraph.md +1 -1
- data/docs/DocxRun.md +1 -1
- data/docs/DocxText.md +1 -1
- data/docs/EditDocumentApi.md +110 -0
- data/docs/FindDocxParagraphRequest.md +11 -0
- data/docs/FindDocxParagraphResponse.md +10 -0
- data/docs/ReplaceDocxParagraphRequest.md +12 -0
- data/docs/ReplaceDocxParagraphResponse.md +9 -0
- data/docs/ValidateDocumentApi.md +220 -0
- data/docs/ZipArchiveApi.md +144 -5
- data/docs/ZipEncryptionAdvancedRequest.md +10 -0
- data/lib/cloudmersive-convert-api-client.rb +5 -0
- data/lib/cloudmersive-convert-api-client/api/edit_document_api.rb +110 -0
- data/lib/cloudmersive-convert-api-client/api/validate_document_api.rb +224 -0
- data/lib/cloudmersive-convert-api-client/api/zip_archive_api.rb +160 -6
- data/lib/cloudmersive-convert-api-client/models/docx_paragraph.rb +1 -1
- data/lib/cloudmersive-convert-api-client/models/docx_run.rb +1 -1
- data/lib/cloudmersive-convert-api-client/models/docx_text.rb +1 -1
- data/lib/cloudmersive-convert-api-client/models/find_docx_paragraph_request.rb +235 -0
- data/lib/cloudmersive-convert-api-client/models/find_docx_paragraph_response.rb +211 -0
- data/lib/cloudmersive-convert-api-client/models/replace_docx_paragraph_request.rb +245 -0
- data/lib/cloudmersive-convert-api-client/models/replace_docx_paragraph_response.rb +199 -0
- data/lib/cloudmersive-convert-api-client/models/zip_encryption_advanced_request.rb +225 -0
- data/lib/cloudmersive-convert-api-client/version.rb +1 -1
- data/spec/api/edit_document_api_spec.rb +24 -0
- data/spec/api/validate_document_api_spec.rb +48 -0
- data/spec/api/zip_archive_api_spec.rb +36 -1
- data/spec/models/find_docx_paragraph_request_spec.rb +60 -0
- data/spec/models/find_docx_paragraph_response_spec.rb +54 -0
- data/spec/models/replace_docx_paragraph_request_spec.rb +66 -0
- data/spec/models/replace_docx_paragraph_response_spec.rb +48 -0
- data/spec/models/zip_encryption_advanced_request_spec.rb +54 -0
- metadata +17 -2
@@ -22,21 +22,45 @@ module CloudmersiveConvertApiClient
|
|
22
22
|
|
23
23
|
# Compress files to create a new zip archive
|
24
24
|
# Create a new zip archive by compressing input files.
|
25
|
+
# @param input_file1 First input file to perform the operation on.
|
25
26
|
# @param [Hash] opts the optional parameters
|
26
|
-
# @
|
27
|
-
|
28
|
-
|
27
|
+
# @option opts [File] :input_file2 Second input file to perform the operation on.
|
28
|
+
# @option opts [File] :input_file3 Third input file to perform the operation on.
|
29
|
+
# @option opts [File] :input_file4 Fourth input file to perform the operation on.
|
30
|
+
# @option opts [File] :input_file5 Fifth input file to perform the operation on.
|
31
|
+
# @option opts [File] :input_file6 Sixth input file to perform the operation on.
|
32
|
+
# @option opts [File] :input_file7 Seventh input file to perform the operation on.
|
33
|
+
# @option opts [File] :input_file8 Eighth input file to perform the operation on.
|
34
|
+
# @option opts [File] :input_file9 Ninth input file to perform the operation on.
|
35
|
+
# @option opts [File] :input_file10 Tenth input file to perform the operation on.
|
36
|
+
# @return [String]
|
37
|
+
def zip_archive_zip_create(input_file1, opts = {})
|
38
|
+
data, _status_code, _headers = zip_archive_zip_create_with_http_info(input_file1, opts)
|
29
39
|
return data
|
30
40
|
end
|
31
41
|
|
32
42
|
# Compress files to create a new zip archive
|
33
43
|
# Create a new zip archive by compressing input files.
|
44
|
+
# @param input_file1 First input file to perform the operation on.
|
34
45
|
# @param [Hash] opts the optional parameters
|
35
|
-
# @
|
36
|
-
|
46
|
+
# @option opts [File] :input_file2 Second input file to perform the operation on.
|
47
|
+
# @option opts [File] :input_file3 Third input file to perform the operation on.
|
48
|
+
# @option opts [File] :input_file4 Fourth input file to perform the operation on.
|
49
|
+
# @option opts [File] :input_file5 Fifth input file to perform the operation on.
|
50
|
+
# @option opts [File] :input_file6 Sixth input file to perform the operation on.
|
51
|
+
# @option opts [File] :input_file7 Seventh input file to perform the operation on.
|
52
|
+
# @option opts [File] :input_file8 Eighth input file to perform the operation on.
|
53
|
+
# @option opts [File] :input_file9 Ninth input file to perform the operation on.
|
54
|
+
# @option opts [File] :input_file10 Tenth input file to perform the operation on.
|
55
|
+
# @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers
|
56
|
+
def zip_archive_zip_create_with_http_info(input_file1, opts = {})
|
37
57
|
if @api_client.config.debugging
|
38
58
|
@api_client.config.logger.debug "Calling API: ZipArchiveApi.zip_archive_zip_create ..."
|
39
59
|
end
|
60
|
+
# verify the required parameter 'input_file1' is set
|
61
|
+
if @api_client.config.client_side_validation && input_file1.nil?
|
62
|
+
fail ArgumentError, "Missing the required parameter 'input_file1' when calling ZipArchiveApi.zip_archive_zip_create"
|
63
|
+
end
|
40
64
|
# resource path
|
41
65
|
local_var_path = "/convert/archive/zip/create"
|
42
66
|
|
@@ -47,9 +71,21 @@ module CloudmersiveConvertApiClient
|
|
47
71
|
header_params = {}
|
48
72
|
# HTTP header 'Accept' (if needed)
|
49
73
|
header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream'])
|
74
|
+
# HTTP header 'Content-Type'
|
75
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
|
50
76
|
|
51
77
|
# form parameters
|
52
78
|
form_params = {}
|
79
|
+
form_params["inputFile1"] = input_file1
|
80
|
+
form_params["inputFile2"] = opts[:'input_file2'] if !opts[:'input_file2'].nil?
|
81
|
+
form_params["inputFile3"] = opts[:'input_file3'] if !opts[:'input_file3'].nil?
|
82
|
+
form_params["inputFile4"] = opts[:'input_file4'] if !opts[:'input_file4'].nil?
|
83
|
+
form_params["inputFile5"] = opts[:'input_file5'] if !opts[:'input_file5'].nil?
|
84
|
+
form_params["inputFile6"] = opts[:'input_file6'] if !opts[:'input_file6'].nil?
|
85
|
+
form_params["inputFile7"] = opts[:'input_file7'] if !opts[:'input_file7'].nil?
|
86
|
+
form_params["inputFile8"] = opts[:'input_file8'] if !opts[:'input_file8'].nil?
|
87
|
+
form_params["inputFile9"] = opts[:'input_file9'] if !opts[:'input_file9'].nil?
|
88
|
+
form_params["inputFile10"] = opts[:'input_file10'] if !opts[:'input_file10'].nil?
|
53
89
|
|
54
90
|
# http body (model)
|
55
91
|
post_body = nil
|
@@ -60,7 +96,7 @@ module CloudmersiveConvertApiClient
|
|
60
96
|
:form_params => form_params,
|
61
97
|
:body => post_body,
|
62
98
|
:auth_names => auth_names,
|
63
|
-
:return_type => '
|
99
|
+
:return_type => 'String')
|
64
100
|
if @api_client.config.debugging
|
65
101
|
@api_client.config.logger.debug "API called: ZipArchiveApi#zip_archive_zip_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
66
102
|
end
|
@@ -122,6 +158,124 @@ module CloudmersiveConvertApiClient
|
|
122
158
|
return data, status_code, headers
|
123
159
|
end
|
124
160
|
|
161
|
+
# Decrypt and remove password protection on a zip file
|
162
|
+
# Decrypts and removes password protection from an encrypted zip file with the specified password
|
163
|
+
# @param input_file Input file to perform the operation on.
|
164
|
+
# @param zip_password Required; Password for the input archive
|
165
|
+
# @param [Hash] opts the optional parameters
|
166
|
+
# @return [Object]
|
167
|
+
def zip_archive_zip_decrypt(input_file, zip_password, opts = {})
|
168
|
+
data, _status_code, _headers = zip_archive_zip_decrypt_with_http_info(input_file, zip_password, opts)
|
169
|
+
return data
|
170
|
+
end
|
171
|
+
|
172
|
+
# Decrypt and remove password protection on a zip file
|
173
|
+
# Decrypts and removes password protection from an encrypted zip file with the specified password
|
174
|
+
# @param input_file Input file to perform the operation on.
|
175
|
+
# @param zip_password Required; Password for the input archive
|
176
|
+
# @param [Hash] opts the optional parameters
|
177
|
+
# @return [Array<(Object, Fixnum, Hash)>] Object data, response status code and response headers
|
178
|
+
def zip_archive_zip_decrypt_with_http_info(input_file, zip_password, opts = {})
|
179
|
+
if @api_client.config.debugging
|
180
|
+
@api_client.config.logger.debug "Calling API: ZipArchiveApi.zip_archive_zip_decrypt ..."
|
181
|
+
end
|
182
|
+
# verify the required parameter 'input_file' is set
|
183
|
+
if @api_client.config.client_side_validation && input_file.nil?
|
184
|
+
fail ArgumentError, "Missing the required parameter 'input_file' when calling ZipArchiveApi.zip_archive_zip_decrypt"
|
185
|
+
end
|
186
|
+
# verify the required parameter 'zip_password' is set
|
187
|
+
if @api_client.config.client_side_validation && zip_password.nil?
|
188
|
+
fail ArgumentError, "Missing the required parameter 'zip_password' when calling ZipArchiveApi.zip_archive_zip_decrypt"
|
189
|
+
end
|
190
|
+
# resource path
|
191
|
+
local_var_path = "/convert/archive/zip/decrypt"
|
192
|
+
|
193
|
+
# query parameters
|
194
|
+
query_params = {}
|
195
|
+
|
196
|
+
# header parameters
|
197
|
+
header_params = {}
|
198
|
+
# HTTP header 'Accept' (if needed)
|
199
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
|
200
|
+
# HTTP header 'Content-Type'
|
201
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
|
202
|
+
header_params[:'zipPassword'] = zip_password
|
203
|
+
|
204
|
+
# form parameters
|
205
|
+
form_params = {}
|
206
|
+
form_params["inputFile"] = input_file
|
207
|
+
|
208
|
+
# http body (model)
|
209
|
+
post_body = nil
|
210
|
+
auth_names = ['Apikey']
|
211
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
212
|
+
:header_params => header_params,
|
213
|
+
:query_params => query_params,
|
214
|
+
:form_params => form_params,
|
215
|
+
:body => post_body,
|
216
|
+
:auth_names => auth_names,
|
217
|
+
:return_type => 'Object')
|
218
|
+
if @api_client.config.debugging
|
219
|
+
@api_client.config.logger.debug "API called: ZipArchiveApi#zip_archive_zip_decrypt\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
220
|
+
end
|
221
|
+
return data, status_code, headers
|
222
|
+
end
|
223
|
+
|
224
|
+
# Encrypt and password protect a zip file
|
225
|
+
# Encrypts and password protects an existing zip file with the specified password and encryption algorithm
|
226
|
+
# @param encryption_request Encryption request
|
227
|
+
# @param [Hash] opts the optional parameters
|
228
|
+
# @return [Object]
|
229
|
+
def zip_archive_zip_encrypt_advanced(encryption_request, opts = {})
|
230
|
+
data, _status_code, _headers = zip_archive_zip_encrypt_advanced_with_http_info(encryption_request, opts)
|
231
|
+
return data
|
232
|
+
end
|
233
|
+
|
234
|
+
# Encrypt and password protect a zip file
|
235
|
+
# Encrypts and password protects an existing zip file with the specified password and encryption algorithm
|
236
|
+
# @param encryption_request Encryption request
|
237
|
+
# @param [Hash] opts the optional parameters
|
238
|
+
# @return [Array<(Object, Fixnum, Hash)>] Object data, response status code and response headers
|
239
|
+
def zip_archive_zip_encrypt_advanced_with_http_info(encryption_request, opts = {})
|
240
|
+
if @api_client.config.debugging
|
241
|
+
@api_client.config.logger.debug "Calling API: ZipArchiveApi.zip_archive_zip_encrypt_advanced ..."
|
242
|
+
end
|
243
|
+
# verify the required parameter 'encryption_request' is set
|
244
|
+
if @api_client.config.client_side_validation && encryption_request.nil?
|
245
|
+
fail ArgumentError, "Missing the required parameter 'encryption_request' when calling ZipArchiveApi.zip_archive_zip_encrypt_advanced"
|
246
|
+
end
|
247
|
+
# resource path
|
248
|
+
local_var_path = "/convert/archive/zip/encrypt/advanced"
|
249
|
+
|
250
|
+
# query parameters
|
251
|
+
query_params = {}
|
252
|
+
|
253
|
+
# header parameters
|
254
|
+
header_params = {}
|
255
|
+
# HTTP header 'Accept' (if needed)
|
256
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
|
257
|
+
# HTTP header 'Content-Type'
|
258
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])
|
259
|
+
|
260
|
+
# form parameters
|
261
|
+
form_params = {}
|
262
|
+
|
263
|
+
# http body (model)
|
264
|
+
post_body = @api_client.object_to_http_body(encryption_request)
|
265
|
+
auth_names = ['Apikey']
|
266
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
267
|
+
:header_params => header_params,
|
268
|
+
:query_params => query_params,
|
269
|
+
:form_params => form_params,
|
270
|
+
:body => post_body,
|
271
|
+
:auth_names => auth_names,
|
272
|
+
:return_type => 'Object')
|
273
|
+
if @api_client.config.debugging
|
274
|
+
@api_client.config.logger.debug "API called: ZipArchiveApi#zip_archive_zip_encrypt_advanced\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
275
|
+
end
|
276
|
+
return data, status_code, headers
|
277
|
+
end
|
278
|
+
|
125
279
|
# Extract, decompress files and folders from a zip archive
|
126
280
|
# Extracts a zip archive by decompressing files, and folders.
|
127
281
|
# @param input_file Input file to perform the operation on.
|
@@ -18,7 +18,7 @@ module CloudmersiveConvertApiClient
|
|
18
18
|
# The index of the paragraph; 0-based
|
19
19
|
attr_accessor :paragraph_index
|
20
20
|
|
21
|
-
# The Path of the location of this object; leave blank
|
21
|
+
# The Path of the location of this Paragraph object; leave blank during creation
|
22
22
|
attr_accessor :path
|
23
23
|
|
24
24
|
# The content runs in the paragraph - this is where text is stored; similar to a span in HTML
|
@@ -18,7 +18,7 @@ module CloudmersiveConvertApiClient
|
|
18
18
|
# Index of the run, 0-based
|
19
19
|
attr_accessor :run_index
|
20
20
|
|
21
|
-
# The Path of the location of this object; leave blank for
|
21
|
+
# The Path of the location of this Run object; leave blank for creation
|
22
22
|
attr_accessor :path
|
23
23
|
|
24
24
|
# Text items inside the run; this is where the actual text content is stored
|
@@ -18,7 +18,7 @@ module CloudmersiveConvertApiClient
|
|
18
18
|
# Index of the text content in the run; 0-based
|
19
19
|
attr_accessor :text_index
|
20
20
|
|
21
|
-
# The Path of the location of this object; leave blank for
|
21
|
+
# The Path of the location of this Text object; leave blank for creation
|
22
22
|
attr_accessor :path
|
23
23
|
|
24
24
|
# Text string containing the text content of this text content item
|
@@ -0,0 +1,235 @@
|
|
1
|
+
=begin
|
2
|
+
#convertapi
|
3
|
+
|
4
|
+
#Convert API lets you effortlessly convert file formats and types.
|
5
|
+
|
6
|
+
OpenAPI spec version: v1
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CloudmersiveConvertApiClient
|
16
|
+
# Input to a request to find matching paragraphs in a Word DOCX document
|
17
|
+
class FindDocxParagraphRequest
|
18
|
+
# Optional: Bytes of the input file to operate on
|
19
|
+
attr_accessor :input_file_bytes
|
20
|
+
|
21
|
+
# Optional: URL of a file to operate on as input. This can be a public URL, or you can also use the begin-editing API to upload a document and pass in the secure URL result from that operation as the URL here (this URL is not public).
|
22
|
+
attr_accessor :input_file_url
|
23
|
+
|
24
|
+
# Required: The target string to search for in the paragraphs of the document
|
25
|
+
attr_accessor :find_string
|
26
|
+
|
27
|
+
# Optional: True to match case, false to ignore case when matching
|
28
|
+
attr_accessor :match_case
|
29
|
+
|
30
|
+
|
31
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
32
|
+
def self.attribute_map
|
33
|
+
{
|
34
|
+
:'input_file_bytes' => :'InputFileBytes',
|
35
|
+
:'input_file_url' => :'InputFileUrl',
|
36
|
+
:'find_string' => :'FindString',
|
37
|
+
:'match_case' => :'MatchCase'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
# Attribute type mapping.
|
42
|
+
def self.swagger_types
|
43
|
+
{
|
44
|
+
:'input_file_bytes' => :'String',
|
45
|
+
:'input_file_url' => :'String',
|
46
|
+
:'find_string' => :'String',
|
47
|
+
:'match_case' => :'BOOLEAN'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Initializes the object
|
52
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
53
|
+
def initialize(attributes = {})
|
54
|
+
return unless attributes.is_a?(Hash)
|
55
|
+
|
56
|
+
# convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
58
|
+
|
59
|
+
if attributes.has_key?(:'InputFileBytes')
|
60
|
+
self.input_file_bytes = attributes[:'InputFileBytes']
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.has_key?(:'InputFileUrl')
|
64
|
+
self.input_file_url = attributes[:'InputFileUrl']
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes.has_key?(:'FindString')
|
68
|
+
self.find_string = attributes[:'FindString']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.has_key?(:'MatchCase')
|
72
|
+
self.match_case = attributes[:'MatchCase']
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
78
|
+
# @return Array for valid properties with the reasons
|
79
|
+
def list_invalid_properties
|
80
|
+
invalid_properties = Array.new
|
81
|
+
if !@input_file_bytes.nil? && @input_file_bytes !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
|
82
|
+
invalid_properties.push("invalid value for 'input_file_bytes', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.")
|
83
|
+
end
|
84
|
+
|
85
|
+
return invalid_properties
|
86
|
+
end
|
87
|
+
|
88
|
+
# Check to see if the all the properties in the model are valid
|
89
|
+
# @return true if the model is valid
|
90
|
+
def valid?
|
91
|
+
return false if !@input_file_bytes.nil? && @input_file_bytes !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
|
92
|
+
return true
|
93
|
+
end
|
94
|
+
|
95
|
+
# Custom attribute writer method with validation
|
96
|
+
# @param [Object] input_file_bytes Value to be assigned
|
97
|
+
def input_file_bytes=(input_file_bytes)
|
98
|
+
|
99
|
+
if !input_file_bytes.nil? && input_file_bytes !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
|
100
|
+
fail ArgumentError, "invalid value for 'input_file_bytes', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/."
|
101
|
+
end
|
102
|
+
|
103
|
+
@input_file_bytes = input_file_bytes
|
104
|
+
end
|
105
|
+
|
106
|
+
# Checks equality by comparing each attribute.
|
107
|
+
# @param [Object] Object to be compared
|
108
|
+
def ==(o)
|
109
|
+
return true if self.equal?(o)
|
110
|
+
self.class == o.class &&
|
111
|
+
input_file_bytes == o.input_file_bytes &&
|
112
|
+
input_file_url == o.input_file_url &&
|
113
|
+
find_string == o.find_string &&
|
114
|
+
match_case == o.match_case
|
115
|
+
end
|
116
|
+
|
117
|
+
# @see the `==` method
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def eql?(o)
|
120
|
+
self == o
|
121
|
+
end
|
122
|
+
|
123
|
+
# Calculates hash code according to all attributes.
|
124
|
+
# @return [Fixnum] Hash code
|
125
|
+
def hash
|
126
|
+
[input_file_bytes, input_file_url, find_string, match_case].hash
|
127
|
+
end
|
128
|
+
|
129
|
+
# Builds the object from hash
|
130
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
131
|
+
# @return [Object] Returns the model itself
|
132
|
+
def build_from_hash(attributes)
|
133
|
+
return nil unless attributes.is_a?(Hash)
|
134
|
+
self.class.swagger_types.each_pair do |key, type|
|
135
|
+
if type =~ /\AArray<(.*)>/i
|
136
|
+
# check to ensure the input is an array given that the the attribute
|
137
|
+
# is documented as an array but the input is not
|
138
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
139
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
140
|
+
end
|
141
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
142
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
143
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
144
|
+
end
|
145
|
+
|
146
|
+
self
|
147
|
+
end
|
148
|
+
|
149
|
+
# Deserializes the data based on type
|
150
|
+
# @param string type Data type
|
151
|
+
# @param string value Value to be deserialized
|
152
|
+
# @return [Object] Deserialized data
|
153
|
+
def _deserialize(type, value)
|
154
|
+
case type.to_sym
|
155
|
+
when :DateTime
|
156
|
+
DateTime.parse(value)
|
157
|
+
when :Date
|
158
|
+
Date.parse(value)
|
159
|
+
when :String
|
160
|
+
value.to_s
|
161
|
+
when :Integer
|
162
|
+
value.to_i
|
163
|
+
when :Float
|
164
|
+
value.to_f
|
165
|
+
when :BOOLEAN
|
166
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
167
|
+
true
|
168
|
+
else
|
169
|
+
false
|
170
|
+
end
|
171
|
+
when :Object
|
172
|
+
# generic object (usually a Hash), return directly
|
173
|
+
value
|
174
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
175
|
+
inner_type = Regexp.last_match[:inner_type]
|
176
|
+
value.map { |v| _deserialize(inner_type, v) }
|
177
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
178
|
+
k_type = Regexp.last_match[:k_type]
|
179
|
+
v_type = Regexp.last_match[:v_type]
|
180
|
+
{}.tap do |hash|
|
181
|
+
value.each do |k, v|
|
182
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
else # model
|
186
|
+
temp_model = CloudmersiveConvertApiClient.const_get(type).new
|
187
|
+
temp_model.build_from_hash(value)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the string representation of the object
|
192
|
+
# @return [String] String presentation of the object
|
193
|
+
def to_s
|
194
|
+
to_hash.to_s
|
195
|
+
end
|
196
|
+
|
197
|
+
# to_body is an alias to to_hash (backward compatibility)
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_body
|
200
|
+
to_hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Returns the object in the form of hash
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
205
|
+
def to_hash
|
206
|
+
hash = {}
|
207
|
+
self.class.attribute_map.each_pair do |attr, param|
|
208
|
+
value = self.send(attr)
|
209
|
+
next if value.nil?
|
210
|
+
hash[param] = _to_hash(value)
|
211
|
+
end
|
212
|
+
hash
|
213
|
+
end
|
214
|
+
|
215
|
+
# Outputs non-array value in the form of hash
|
216
|
+
# For object, use to_hash. Otherwise, just return the value
|
217
|
+
# @param [Object] value Any valid value
|
218
|
+
# @return [Hash] Returns the value in the form of hash
|
219
|
+
def _to_hash(value)
|
220
|
+
if value.is_a?(Array)
|
221
|
+
value.compact.map{ |v| _to_hash(v) }
|
222
|
+
elsif value.is_a?(Hash)
|
223
|
+
{}.tap do |hash|
|
224
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
225
|
+
end
|
226
|
+
elsif value.respond_to? :to_hash
|
227
|
+
value.to_hash
|
228
|
+
else
|
229
|
+
value
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|