cloudmersive-convert-api-client 1.5.2 → 1.5.3

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -5
  3. data/docs/DeleteDocxTableRowRequest.md +11 -0
  4. data/docs/DeleteDocxTableRowResponse.md +9 -0
  5. data/docs/EditDocumentApi.md +223 -3
  6. data/docs/GetDocxTableByIndexRequest.md +10 -0
  7. data/docs/GetDocxTableByIndexResponse.md +9 -0
  8. data/docs/GetDocxTableRowRequest.md +11 -0
  9. data/docs/GetDocxTableRowResponse.md +9 -0
  10. data/docs/PdfMetadata.md +1 -0
  11. data/docs/UpdateDocxTableRowRequest.md +12 -0
  12. data/docs/UpdateDocxTableRowResponse.md +9 -0
  13. data/lib/cloudmersive-convert-api-client.rb +8 -0
  14. data/lib/cloudmersive-convert-api-client/api/edit_document_api.rb +222 -2
  15. data/lib/cloudmersive-convert-api-client/models/delete_docx_table_row_request.rb +235 -0
  16. data/lib/cloudmersive-convert-api-client/models/delete_docx_table_row_response.rb +199 -0
  17. data/lib/cloudmersive-convert-api-client/models/get_docx_table_by_index_request.rb +225 -0
  18. data/lib/cloudmersive-convert-api-client/models/get_docx_table_by_index_response.rb +199 -0
  19. data/lib/cloudmersive-convert-api-client/models/get_docx_table_row_request.rb +235 -0
  20. data/lib/cloudmersive-convert-api-client/models/get_docx_table_row_response.rb +199 -0
  21. data/lib/cloudmersive-convert-api-client/models/pdf_metadata.rb +14 -4
  22. data/lib/cloudmersive-convert-api-client/models/update_docx_table_row_request.rb +245 -0
  23. data/lib/cloudmersive-convert-api-client/models/update_docx_table_row_response.rb +199 -0
  24. data/lib/cloudmersive-convert-api-client/version.rb +1 -1
  25. data/spec/api/edit_document_api_spec.rb +49 -1
  26. data/spec/models/delete_docx_table_row_request_spec.rb +60 -0
  27. data/spec/models/delete_docx_table_row_response_spec.rb +48 -0
  28. data/spec/models/get_docx_table_by_index_request_spec.rb +54 -0
  29. data/spec/models/get_docx_table_by_index_response_spec.rb +48 -0
  30. data/spec/models/get_docx_table_row_request_spec.rb +60 -0
  31. data/spec/models/get_docx_table_row_response_spec.rb +48 -0
  32. data/spec/models/pdf_metadata_spec.rb +6 -0
  33. data/spec/models/update_docx_table_row_request_spec.rb +66 -0
  34. data/spec/models/update_docx_table_row_response_spec.rb +48 -0
  35. metadata +26 -2
@@ -0,0 +1,9 @@
1
+ # CloudmersiveConvertApiClient::UpdateDocxTableRowResponse
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ **successful** | **BOOLEAN** | True if successful, false otherwise | [optional]
7
+ **edited_document_url** | **String** | URL to the edited DOCX file; file is stored in an in-memory cache and will be deleted. Call Finish-Editing to get the result document contents. | [optional]
8
+
9
+
@@ -22,6 +22,8 @@ require 'cloudmersive-convert-api-client/models/autodetect_document_validation_r
22
22
  require 'cloudmersive-convert-api-client/models/autodetect_get_info_result'
23
23
  require 'cloudmersive-convert-api-client/models/autodetect_to_png_result'
24
24
  require 'cloudmersive-convert-api-client/models/converted_png_page'
25
+ require 'cloudmersive-convert-api-client/models/delete_docx_table_row_request'
26
+ require 'cloudmersive-convert-api-client/models/delete_docx_table_row_response'
25
27
  require 'cloudmersive-convert-api-client/models/document_validation_error'
26
28
  require 'cloudmersive-convert-api-client/models/document_validation_result'
27
29
  require 'cloudmersive-convert-api-client/models/docx_body'
@@ -63,6 +65,10 @@ require 'cloudmersive-convert-api-client/models/get_docx_sections_request'
63
65
  require 'cloudmersive-convert-api-client/models/get_docx_sections_response'
64
66
  require 'cloudmersive-convert-api-client/models/get_docx_styles_request'
65
67
  require 'cloudmersive-convert-api-client/models/get_docx_styles_response'
68
+ require 'cloudmersive-convert-api-client/models/get_docx_table_by_index_request'
69
+ require 'cloudmersive-convert-api-client/models/get_docx_table_by_index_response'
70
+ require 'cloudmersive-convert-api-client/models/get_docx_table_row_request'
71
+ require 'cloudmersive-convert-api-client/models/get_docx_table_row_response'
66
72
  require 'cloudmersive-convert-api-client/models/get_docx_tables_request'
67
73
  require 'cloudmersive-convert-api-client/models/get_docx_tables_response'
68
74
  require 'cloudmersive-convert-api-client/models/get_image_info_result'
@@ -111,6 +117,8 @@ require 'cloudmersive-convert-api-client/models/set_pdf_metadata_request'
111
117
  require 'cloudmersive-convert-api-client/models/split_pdf_result'
112
118
  require 'cloudmersive-convert-api-client/models/split_xlsx_worksheet_result'
113
119
  require 'cloudmersive-convert-api-client/models/text_conversion_result'
120
+ require 'cloudmersive-convert-api-client/models/update_docx_table_row_request'
121
+ require 'cloudmersive-convert-api-client/models/update_docx_table_row_response'
114
122
  require 'cloudmersive-convert-api-client/models/viewer_response'
115
123
  require 'cloudmersive-convert-api-client/models/worksheet_result'
116
124
  require 'cloudmersive-convert-api-client/models/xlsx_image'
@@ -186,6 +186,61 @@ module CloudmersiveConvertApiClient
186
186
  return data, status_code, headers
187
187
  end
188
188
 
189
+ # Deletes a table row in an existing table in a Word DOCX document
190
+ # Deletes an existing table row in a Word DOCX Document and returns the result.
191
+ # @param req_config Document input request
192
+ # @param [Hash] opts the optional parameters
193
+ # @return [DeleteDocxTableRowResponse]
194
+ def edit_document_docx_delete_table_row(req_config, opts = {})
195
+ data, _status_code, _headers = edit_document_docx_delete_table_row_with_http_info(req_config, opts)
196
+ return data
197
+ end
198
+
199
+ # Deletes a table row in an existing table in a Word DOCX document
200
+ # Deletes an existing table row in a Word DOCX Document and returns the result.
201
+ # @param req_config Document input request
202
+ # @param [Hash] opts the optional parameters
203
+ # @return [Array<(DeleteDocxTableRowResponse, Fixnum, Hash)>] DeleteDocxTableRowResponse data, response status code and response headers
204
+ def edit_document_docx_delete_table_row_with_http_info(req_config, opts = {})
205
+ if @api_client.config.debugging
206
+ @api_client.config.logger.debug "Calling API: EditDocumentApi.edit_document_docx_delete_table_row ..."
207
+ end
208
+ # verify the required parameter 'req_config' is set
209
+ if @api_client.config.client_side_validation && req_config.nil?
210
+ fail ArgumentError, "Missing the required parameter 'req_config' when calling EditDocumentApi.edit_document_docx_delete_table_row"
211
+ end
212
+ # resource path
213
+ local_var_path = "/convert/edit/docx/delete-table-row"
214
+
215
+ # query parameters
216
+ query_params = {}
217
+
218
+ # header parameters
219
+ header_params = {}
220
+ # HTTP header 'Accept' (if needed)
221
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
222
+ # HTTP header 'Content-Type'
223
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])
224
+
225
+ # form parameters
226
+ form_params = {}
227
+
228
+ # http body (model)
229
+ post_body = @api_client.object_to_http_body(req_config)
230
+ auth_names = ['Apikey']
231
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
232
+ :header_params => header_params,
233
+ :query_params => query_params,
234
+ :form_params => form_params,
235
+ :body => post_body,
236
+ :auth_names => auth_names,
237
+ :return_type => 'DeleteDocxTableRowResponse')
238
+ if @api_client.config.debugging
239
+ @api_client.config.logger.debug "API called: EditDocumentApi#edit_document_docx_delete_table_row\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
240
+ end
241
+ return data, status_code, headers
242
+ end
243
+
189
244
  # Get content of a footer from a Word DOCX document
190
245
  # Returns the footer content from a Word Document (DOCX) format file
191
246
  # @param req_config Document input request
@@ -406,7 +461,117 @@ module CloudmersiveConvertApiClient
406
461
  return data, status_code, headers
407
462
  end
408
463
 
409
- # Get tables in Word DOCX document
464
+ # Get a specific table by index in a Word DOCX document
465
+ # Returns the specific table object by its 0-based index in an Office Word Document (DOCX)
466
+ # @param req_config Document input request
467
+ # @param [Hash] opts the optional parameters
468
+ # @return [GetDocxTableByIndexResponse]
469
+ def edit_document_docx_get_table_by_index(req_config, opts = {})
470
+ data, _status_code, _headers = edit_document_docx_get_table_by_index_with_http_info(req_config, opts)
471
+ return data
472
+ end
473
+
474
+ # Get a specific table by index in a Word DOCX document
475
+ # Returns the specific table object by its 0-based index in an Office Word Document (DOCX)
476
+ # @param req_config Document input request
477
+ # @param [Hash] opts the optional parameters
478
+ # @return [Array<(GetDocxTableByIndexResponse, Fixnum, Hash)>] GetDocxTableByIndexResponse data, response status code and response headers
479
+ def edit_document_docx_get_table_by_index_with_http_info(req_config, opts = {})
480
+ if @api_client.config.debugging
481
+ @api_client.config.logger.debug "Calling API: EditDocumentApi.edit_document_docx_get_table_by_index ..."
482
+ end
483
+ # verify the required parameter 'req_config' is set
484
+ if @api_client.config.client_side_validation && req_config.nil?
485
+ fail ArgumentError, "Missing the required parameter 'req_config' when calling EditDocumentApi.edit_document_docx_get_table_by_index"
486
+ end
487
+ # resource path
488
+ local_var_path = "/convert/edit/docx/get-table/by-index"
489
+
490
+ # query parameters
491
+ query_params = {}
492
+
493
+ # header parameters
494
+ header_params = {}
495
+ # HTTP header 'Accept' (if needed)
496
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
497
+ # HTTP header 'Content-Type'
498
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])
499
+
500
+ # form parameters
501
+ form_params = {}
502
+
503
+ # http body (model)
504
+ post_body = @api_client.object_to_http_body(req_config)
505
+ auth_names = ['Apikey']
506
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
507
+ :header_params => header_params,
508
+ :query_params => query_params,
509
+ :form_params => form_params,
510
+ :body => post_body,
511
+ :auth_names => auth_names,
512
+ :return_type => 'GetDocxTableByIndexResponse')
513
+ if @api_client.config.debugging
514
+ @api_client.config.logger.debug "API called: EditDocumentApi#edit_document_docx_get_table_by_index\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
515
+ end
516
+ return data, status_code, headers
517
+ end
518
+
519
+ # Gets the contents of an existing table row in an existing table in a Word DOCX document
520
+ # Gets the contents of an existing table row in a Word DOCX Document and returns the result.
521
+ # @param req_config Document input request
522
+ # @param [Hash] opts the optional parameters
523
+ # @return [GetDocxTableRowResponse]
524
+ def edit_document_docx_get_table_row(req_config, opts = {})
525
+ data, _status_code, _headers = edit_document_docx_get_table_row_with_http_info(req_config, opts)
526
+ return data
527
+ end
528
+
529
+ # Gets the contents of an existing table row in an existing table in a Word DOCX document
530
+ # Gets the contents of an existing table row in a Word DOCX Document and returns the result.
531
+ # @param req_config Document input request
532
+ # @param [Hash] opts the optional parameters
533
+ # @return [Array<(GetDocxTableRowResponse, Fixnum, Hash)>] GetDocxTableRowResponse data, response status code and response headers
534
+ def edit_document_docx_get_table_row_with_http_info(req_config, opts = {})
535
+ if @api_client.config.debugging
536
+ @api_client.config.logger.debug "Calling API: EditDocumentApi.edit_document_docx_get_table_row ..."
537
+ end
538
+ # verify the required parameter 'req_config' is set
539
+ if @api_client.config.client_side_validation && req_config.nil?
540
+ fail ArgumentError, "Missing the required parameter 'req_config' when calling EditDocumentApi.edit_document_docx_get_table_row"
541
+ end
542
+ # resource path
543
+ local_var_path = "/convert/edit/docx/get-table-row"
544
+
545
+ # query parameters
546
+ query_params = {}
547
+
548
+ # header parameters
549
+ header_params = {}
550
+ # HTTP header 'Accept' (if needed)
551
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
552
+ # HTTP header 'Content-Type'
553
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])
554
+
555
+ # form parameters
556
+ form_params = {}
557
+
558
+ # http body (model)
559
+ post_body = @api_client.object_to_http_body(req_config)
560
+ auth_names = ['Apikey']
561
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
562
+ :header_params => header_params,
563
+ :query_params => query_params,
564
+ :form_params => form_params,
565
+ :body => post_body,
566
+ :auth_names => auth_names,
567
+ :return_type => 'GetDocxTableRowResponse')
568
+ if @api_client.config.debugging
569
+ @api_client.config.logger.debug "API called: EditDocumentApi#edit_document_docx_get_table_row\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
570
+ end
571
+ return data, status_code, headers
572
+ end
573
+
574
+ # Get all tables in Word DOCX document
410
575
  # Returns all the table objects in an Office Word Document (docx)
411
576
  # @param req_config Document input request
412
577
  # @param [Hash] opts the optional parameters
@@ -416,7 +581,7 @@ module CloudmersiveConvertApiClient
416
581
  return data
417
582
  end
418
583
 
419
- # Get tables in Word DOCX document
584
+ # Get all tables in Word DOCX document
420
585
  # Returns all the table objects in an Office Word Document (docx)
421
586
  # @param req_config Document input request
422
587
  # @param [Hash] opts the optional parameters
@@ -1066,6 +1231,61 @@ module CloudmersiveConvertApiClient
1066
1231
  return data, status_code, headers
1067
1232
  end
1068
1233
 
1234
+ # Update, set contents of a table row in an existing table in a Word DOCX document
1235
+ # Sets the contents of a table row into a DOCX Document and returns the result. Call Finish Editing on the output URL to complete the operation.
1236
+ # @param req_config Document input request
1237
+ # @param [Hash] opts the optional parameters
1238
+ # @return [UpdateDocxTableRowResponse]
1239
+ def edit_document_docx_update_table_row(req_config, opts = {})
1240
+ data, _status_code, _headers = edit_document_docx_update_table_row_with_http_info(req_config, opts)
1241
+ return data
1242
+ end
1243
+
1244
+ # Update, set contents of a table row in an existing table in a Word DOCX document
1245
+ # Sets the contents of a table row into a DOCX Document and returns the result. Call Finish Editing on the output URL to complete the operation.
1246
+ # @param req_config Document input request
1247
+ # @param [Hash] opts the optional parameters
1248
+ # @return [Array<(UpdateDocxTableRowResponse, Fixnum, Hash)>] UpdateDocxTableRowResponse data, response status code and response headers
1249
+ def edit_document_docx_update_table_row_with_http_info(req_config, opts = {})
1250
+ if @api_client.config.debugging
1251
+ @api_client.config.logger.debug "Calling API: EditDocumentApi.edit_document_docx_update_table_row ..."
1252
+ end
1253
+ # verify the required parameter 'req_config' is set
1254
+ if @api_client.config.client_side_validation && req_config.nil?
1255
+ fail ArgumentError, "Missing the required parameter 'req_config' when calling EditDocumentApi.edit_document_docx_update_table_row"
1256
+ end
1257
+ # resource path
1258
+ local_var_path = "/convert/edit/docx/update-table-row"
1259
+
1260
+ # query parameters
1261
+ query_params = {}
1262
+
1263
+ # header parameters
1264
+ header_params = {}
1265
+ # HTTP header 'Accept' (if needed)
1266
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml'])
1267
+ # HTTP header 'Content-Type'
1268
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded'])
1269
+
1270
+ # form parameters
1271
+ form_params = {}
1272
+
1273
+ # http body (model)
1274
+ post_body = @api_client.object_to_http_body(req_config)
1275
+ auth_names = ['Apikey']
1276
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
1277
+ :header_params => header_params,
1278
+ :query_params => query_params,
1279
+ :form_params => form_params,
1280
+ :body => post_body,
1281
+ :auth_names => auth_names,
1282
+ :return_type => 'UpdateDocxTableRowResponse')
1283
+ if @api_client.config.debugging
1284
+ @api_client.config.logger.debug "API called: EditDocumentApi#edit_document_docx_update_table_row\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
1285
+ end
1286
+ return data, status_code, headers
1287
+ end
1288
+
1069
1289
  # Download result from document editing
1070
1290
  # Once done editing a document, download the result. Begin editing a document by calling begin-editing, then perform operations, then call finish-editing to get the result.
1071
1291
  # @param req_config Cloudmersive Document URL to complete editing on
@@ -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 delete DOCX table row request
17
+ class DeleteDocxTableRowRequest
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
+ # Path to the table to delete the row from
25
+ attr_accessor :table_path
26
+
27
+ # 0-based index of the row to delete (e.g. 0, 1, 2, ...) in the table
28
+ attr_accessor :table_row_row_index
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
+ :'table_path' => :'TablePath',
37
+ :'table_row_row_index' => :'TableRowRowIndex'
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
+ :'table_path' => :'String',
47
+ :'table_row_row_index' => :'Integer'
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?(:'TablePath')
68
+ self.table_path = attributes[:'TablePath']
69
+ end
70
+
71
+ if attributes.has_key?(:'TableRowRowIndex')
72
+ self.table_row_row_index = attributes[:'TableRowRowIndex']
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
+ table_path == o.table_path &&
114
+ table_row_row_index == o.table_row_row_index
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, table_path, table_row_row_index].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