aspose_pdf_cloud 23.3.0 → 23.4.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 +4 -4
- data/README.md +5 -665
- data/docs/OrganizeDocumentData.md +10 -0
- data/docs/OrganizeDocumentRequest.md +9 -0
- data/docs/PdfApi.md +52 -0
- data/lib/aspose_pdf_cloud/api/pdf_api.rb +173 -0
- data/lib/aspose_pdf_cloud/models/organize_document_data.rb +257 -0
- data/lib/aspose_pdf_cloud/models/organize_document_request.rb +206 -0
- data/lib/aspose_pdf_cloud/models/page_range.rb +6 -6
- data/lib/aspose_pdf_cloud/version.rb +1 -1
- data/lib/aspose_pdf_cloud.rb +2 -0
- data/test/pdf_tests.rb +30 -6
- metadata +6 -2
@@ -0,0 +1,10 @@
|
|
1
|
+
# AsposePdfCloud::OrganizeDocumentData
|
2
|
+
Data for document organizing.
|
3
|
+
|
4
|
+
## Properties
|
5
|
+
Name | Type | Description | Notes
|
6
|
+
------------ | ------------- | ------------- | -------------
|
7
|
+
**path** | **String** | Full filename of the document for organizing. |
|
8
|
+
**pages** | **String** | 1-based page numbers of the document that make up the resulting document. |
|
9
|
+
|
10
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# AsposePdfCloud::OrganizeDocumentRequest
|
2
|
+
Documents data for organizing.
|
3
|
+
|
4
|
+
## Properties
|
5
|
+
Name | Type | Description | Notes
|
6
|
+
------------ | ------------- | ------------- | -------------
|
7
|
+
**list** | [**Array<OrganizeDocumentData>**](OrganizeDocumentData.md) | List of document data for organizing. |
|
8
|
+
|
9
|
+
|
data/docs/PdfApi.md
CHANGED
@@ -214,6 +214,8 @@ Method | HTTP request | Description
|
|
214
214
|
[**post_list_box_fields**](PdfApi.md#post_list_box_fields) | **POST** /pdf/\{name}/fields/listbox | Add document listbox fields.
|
215
215
|
[**post_move_page**](PdfApi.md#post_move_page) | **POST** /pdf/\{name}/pages/\{pageNumber}/movePage | Move page to new position.
|
216
216
|
[**post_optimize_document**](PdfApi.md#post_optimize_document) | **POST** /pdf/\{name}/optimize | Optimize document.
|
217
|
+
[**post_organize_document**](PdfApi.md#post_organize_document) | **POST** /pdf/\{name}/organize | Merge selected pages of a document.
|
218
|
+
[**post_organize_documents**](PdfApi.md#post_organize_documents) | **POST** /pdf/organize | Merge selected pages of different documents.
|
217
219
|
[**post_page_caret_annotations**](PdfApi.md#post_page_caret_annotations) | **POST** /pdf/\{name}/pages/\{pageNumber}/annotations/caret | Add document page caret annotations.
|
218
220
|
[**post_page_certify**](PdfApi.md#post_page_certify) | **POST** /pdf/\{name}/pages/\{pageNumber}/certify | Certify document page.
|
219
221
|
[**post_page_circle_annotations**](PdfApi.md#post_page_circle_annotations) | **POST** /pdf/\{name}/pages/\{pageNumber}/annotations/circle | Add document page circle annotations.
|
@@ -5677,6 +5679,56 @@ Name | Type | Description | Notes
|
|
5677
5679
|
|
5678
5680
|
|
5679
5681
|
|
5682
|
+
# **post_organize_document**
|
5683
|
+
> AsposeResponse post_organize_document(name, pages, out_path, opts)
|
5684
|
+
|
5685
|
+
Merge selected pages of a document.
|
5686
|
+
|
5687
|
+
### Parameters
|
5688
|
+
|
5689
|
+
Name | Type | Description | Notes
|
5690
|
+
------------- | ------------- | ------------- | -------------
|
5691
|
+
**name** | **String**| The original document name. |
|
5692
|
+
**pages** | **String**| 1-based page numbers of the source document that make up the resulting document. |
|
5693
|
+
**out_path** | **String**| Full filename of the resulting document. |
|
5694
|
+
**storage** | **String**| The documents storage. | [optional]
|
5695
|
+
**folder** | **String**| The source document folder. | [optional]
|
5696
|
+
|
5697
|
+
### Return type
|
5698
|
+
|
5699
|
+
[**AsposeResponse**](AsposeResponse.md)
|
5700
|
+
|
5701
|
+
### HTTP request headers
|
5702
|
+
|
5703
|
+
- **Content-Type**: application/json
|
5704
|
+
- **Accept**: application/json
|
5705
|
+
|
5706
|
+
|
5707
|
+
|
5708
|
+
# **post_organize_documents**
|
5709
|
+
> AsposeResponse post_organize_documents(organize_documents, out_path, opts)
|
5710
|
+
|
5711
|
+
Merge selected pages of different documents.
|
5712
|
+
|
5713
|
+
### Parameters
|
5714
|
+
|
5715
|
+
Name | Type | Description | Notes
|
5716
|
+
------------- | ------------- | ------------- | -------------
|
5717
|
+
**organize_documents** | [**OrganizeDocumentRequest**](OrganizeDocumentRequest.md)| Array of OrganizeDocumentData to make up the resulting document. |
|
5718
|
+
**out_path** | **String**| Full filename of the resulting document. |
|
5719
|
+
**storage** | **String**| The documents storage. | [optional]
|
5720
|
+
|
5721
|
+
### Return type
|
5722
|
+
|
5723
|
+
[**AsposeResponse**](AsposeResponse.md)
|
5724
|
+
|
5725
|
+
### HTTP request headers
|
5726
|
+
|
5727
|
+
- **Content-Type**: application/json
|
5728
|
+
- **Accept**: application/json
|
5729
|
+
|
5730
|
+
|
5731
|
+
|
5680
5732
|
# **post_page_caret_annotations**
|
5681
5733
|
> AsposeResponse post_page_caret_annotations(name, page_number, annotations, opts)
|
5682
5734
|
|
@@ -16481,6 +16481,179 @@ module AsposePdfCloud
|
|
16481
16481
|
return data, status_code, headers
|
16482
16482
|
end
|
16483
16483
|
|
16484
|
+
# Merge selected pages of a document.
|
16485
|
+
#
|
16486
|
+
# @param name The original document name.
|
16487
|
+
# @param pages 1-based page numbers of the source document that make up the resulting document.
|
16488
|
+
# @param out_path Full filename of the resulting document.
|
16489
|
+
# @param [Hash] opts the optional parameters
|
16490
|
+
# @option opts [String] :storage The documents storage.
|
16491
|
+
# @option opts [String] :folder The source document folder.
|
16492
|
+
# @return [AsposeResponse]
|
16493
|
+
def post_organize_document(name, pages, out_path, opts = {})
|
16494
|
+
@api_client.request_token_if_needed
|
16495
|
+
data, _status_code, _headers = post_organize_document_with_http_info(name, pages, out_path, opts)
|
16496
|
+
rescue ApiError => error
|
16497
|
+
if error.code == 401
|
16498
|
+
@api_client.request_token_if_needed
|
16499
|
+
data, _status_code, _headers = post_organize_document_with_http_info(name, pages, out_path, opts)
|
16500
|
+
else
|
16501
|
+
raise
|
16502
|
+
end
|
16503
|
+
return data
|
16504
|
+
end
|
16505
|
+
|
16506
|
+
# Merge selected pages of a document.
|
16507
|
+
#
|
16508
|
+
# @param name The original document name.
|
16509
|
+
# @param pages 1-based page numbers of the source document that make up the resulting document.
|
16510
|
+
# @param out_path Full filename of the resulting document.
|
16511
|
+
# @param [Hash] opts the optional parameters
|
16512
|
+
# @option opts [String] :storage The documents storage.
|
16513
|
+
# @option opts [String] :folder The source document folder.
|
16514
|
+
# @return [Array<(AsposeResponse, Fixnum, Hash)>] AsposeResponse data, response status code and response headers
|
16515
|
+
def post_organize_document_with_http_info(name, pages, out_path, opts = {})
|
16516
|
+
if @api_client.config.debugging
|
16517
|
+
@api_client.config.logger.debug "Calling API: PdfApi.post_organize_document ..."
|
16518
|
+
end
|
16519
|
+
# verify the required parameter 'name' is set
|
16520
|
+
if @api_client.config.client_side_validation && name.nil?
|
16521
|
+
fail ArgumentError, "Missing the required parameter 'name' when calling PdfApi.post_organize_document"
|
16522
|
+
end
|
16523
|
+
# verify the required parameter 'pages' is set
|
16524
|
+
if @api_client.config.client_side_validation && pages.nil?
|
16525
|
+
fail ArgumentError, "Missing the required parameter 'pages' when calling PdfApi.post_organize_document"
|
16526
|
+
end
|
16527
|
+
if @api_client.config.client_side_validation && pages.to_s.length < 1
|
16528
|
+
fail ArgumentError, 'invalid value for "pages" when calling PdfApi.post_organize_document, the character length must be great than or equal to 1.'
|
16529
|
+
end
|
16530
|
+
|
16531
|
+
# verify the required parameter 'out_path' is set
|
16532
|
+
if @api_client.config.client_side_validation && out_path.nil?
|
16533
|
+
fail ArgumentError, "Missing the required parameter 'out_path' when calling PdfApi.post_organize_document"
|
16534
|
+
end
|
16535
|
+
if @api_client.config.client_side_validation && out_path.to_s.length < 1
|
16536
|
+
fail ArgumentError, 'invalid value for "out_path" when calling PdfApi.post_organize_document, the character length must be great than or equal to 1.'
|
16537
|
+
end
|
16538
|
+
|
16539
|
+
# resource path
|
16540
|
+
local_var_path = "/pdf/{name}/organize".sub('{' + 'name' + '}', name.to_s)
|
16541
|
+
|
16542
|
+
# query parameters
|
16543
|
+
query_params = {}
|
16544
|
+
query_params[:'pages'] = pages
|
16545
|
+
query_params[:'outPath'] = out_path
|
16546
|
+
query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?
|
16547
|
+
query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
|
16548
|
+
|
16549
|
+
# header parameters
|
16550
|
+
header_params = {}
|
16551
|
+
# HTTP header 'Accept' (if needed)
|
16552
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
16553
|
+
# HTTP header 'Content-Type'
|
16554
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
16555
|
+
|
16556
|
+
# form parameters
|
16557
|
+
form_params = {}
|
16558
|
+
# Fix header in file
|
16559
|
+
post_body = nil
|
16560
|
+
|
16561
|
+
# http body (model)
|
16562
|
+
# Fix header in file
|
16563
|
+
# post_body = nil
|
16564
|
+
auth_names = ['JWT']
|
16565
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
16566
|
+
:header_params => header_params,
|
16567
|
+
:query_params => query_params,
|
16568
|
+
:form_params => form_params,
|
16569
|
+
:body => post_body,
|
16570
|
+
:auth_names => auth_names,
|
16571
|
+
:return_type => 'AsposeResponse')
|
16572
|
+
if @api_client.config.debugging
|
16573
|
+
@api_client.config.logger.debug "API called: PdfApi#post_organize_document\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
16574
|
+
end
|
16575
|
+
return data, status_code, headers
|
16576
|
+
end
|
16577
|
+
|
16578
|
+
# Merge selected pages of different documents.
|
16579
|
+
#
|
16580
|
+
# @param organize_documents Array of OrganizeDocumentData to make up the resulting document.
|
16581
|
+
# @param out_path Full filename of the resulting document.
|
16582
|
+
# @param [Hash] opts the optional parameters
|
16583
|
+
# @option opts [String] :storage The documents storage.
|
16584
|
+
# @return [AsposeResponse]
|
16585
|
+
def post_organize_documents(organize_documents, out_path, opts = {})
|
16586
|
+
@api_client.request_token_if_needed
|
16587
|
+
data, _status_code, _headers = post_organize_documents_with_http_info(organize_documents, out_path, opts)
|
16588
|
+
rescue ApiError => error
|
16589
|
+
if error.code == 401
|
16590
|
+
@api_client.request_token_if_needed
|
16591
|
+
data, _status_code, _headers = post_organize_documents_with_http_info(organize_documents, out_path, opts)
|
16592
|
+
else
|
16593
|
+
raise
|
16594
|
+
end
|
16595
|
+
return data
|
16596
|
+
end
|
16597
|
+
|
16598
|
+
# Merge selected pages of different documents.
|
16599
|
+
#
|
16600
|
+
# @param organize_documents Array of OrganizeDocumentData to make up the resulting document.
|
16601
|
+
# @param out_path Full filename of the resulting document.
|
16602
|
+
# @param [Hash] opts the optional parameters
|
16603
|
+
# @option opts [String] :storage The documents storage.
|
16604
|
+
# @return [Array<(AsposeResponse, Fixnum, Hash)>] AsposeResponse data, response status code and response headers
|
16605
|
+
def post_organize_documents_with_http_info(organize_documents, out_path, opts = {})
|
16606
|
+
if @api_client.config.debugging
|
16607
|
+
@api_client.config.logger.debug "Calling API: PdfApi.post_organize_documents ..."
|
16608
|
+
end
|
16609
|
+
# verify the required parameter 'organize_documents' is set
|
16610
|
+
if @api_client.config.client_side_validation && organize_documents.nil?
|
16611
|
+
fail ArgumentError, "Missing the required parameter 'organize_documents' when calling PdfApi.post_organize_documents"
|
16612
|
+
end
|
16613
|
+
# verify the required parameter 'out_path' is set
|
16614
|
+
if @api_client.config.client_side_validation && out_path.nil?
|
16615
|
+
fail ArgumentError, "Missing the required parameter 'out_path' when calling PdfApi.post_organize_documents"
|
16616
|
+
end
|
16617
|
+
if @api_client.config.client_side_validation && out_path.to_s.length < 1
|
16618
|
+
fail ArgumentError, 'invalid value for "out_path" when calling PdfApi.post_organize_documents, the character length must be great than or equal to 1.'
|
16619
|
+
end
|
16620
|
+
|
16621
|
+
# resource path
|
16622
|
+
local_var_path = "/pdf/organize"
|
16623
|
+
|
16624
|
+
# query parameters
|
16625
|
+
query_params = {}
|
16626
|
+
query_params[:'outPath'] = out_path
|
16627
|
+
query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?
|
16628
|
+
|
16629
|
+
# header parameters
|
16630
|
+
header_params = {}
|
16631
|
+
# HTTP header 'Accept' (if needed)
|
16632
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
16633
|
+
# HTTP header 'Content-Type'
|
16634
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
16635
|
+
|
16636
|
+
# form parameters
|
16637
|
+
form_params = {}
|
16638
|
+
# Fix header in file
|
16639
|
+
post_body = nil
|
16640
|
+
|
16641
|
+
# http body (model)
|
16642
|
+
post_body = @api_client.object_to_http_body(organize_documents)
|
16643
|
+
auth_names = ['JWT']
|
16644
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
16645
|
+
:header_params => header_params,
|
16646
|
+
:query_params => query_params,
|
16647
|
+
:form_params => form_params,
|
16648
|
+
:body => post_body,
|
16649
|
+
:auth_names => auth_names,
|
16650
|
+
:return_type => 'AsposeResponse')
|
16651
|
+
if @api_client.config.debugging
|
16652
|
+
@api_client.config.logger.debug "API called: PdfApi#post_organize_documents\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
16653
|
+
end
|
16654
|
+
return data, status_code, headers
|
16655
|
+
end
|
16656
|
+
|
16484
16657
|
# Add document page caret annotations.
|
16485
16658
|
#
|
16486
16659
|
# @param name The document name.
|
@@ -0,0 +1,257 @@
|
|
1
|
+
=begin
|
2
|
+
--------------------------------------------------------------------------------------------------------------------
|
3
|
+
Copyright (c) 2023 Aspose.PDF Cloud
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
16
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
17
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
|
+
SOFTWARE.
|
19
|
+
--------------------------------------------------------------------------------------------------------------------
|
20
|
+
=end
|
21
|
+
|
22
|
+
require 'date'
|
23
|
+
require 'time'
|
24
|
+
|
25
|
+
module AsposePdfCloud
|
26
|
+
# Data for document organizing.
|
27
|
+
class OrganizeDocumentData
|
28
|
+
# Full filename of the document for organizing.
|
29
|
+
attr_accessor :path
|
30
|
+
|
31
|
+
# 1-based page numbers of the document that make up the resulting document.
|
32
|
+
attr_accessor :pages
|
33
|
+
|
34
|
+
|
35
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
36
|
+
def self.attribute_map
|
37
|
+
{
|
38
|
+
:'path' => :'Path',
|
39
|
+
:'pages' => :'Pages'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute type mapping.
|
44
|
+
def self.swagger_types
|
45
|
+
{
|
46
|
+
:'path' => :'String',
|
47
|
+
:'pages' => :'String'
|
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?(:'Path')
|
60
|
+
self.path = attributes[:'Path']
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.has_key?(:'Pages')
|
64
|
+
self.pages = attributes[:'Pages']
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
70
|
+
# @return Array for valid properies with the reasons
|
71
|
+
def list_invalid_properties
|
72
|
+
invalid_properties = Array.new
|
73
|
+
if @path.nil?
|
74
|
+
invalid_properties.push("invalid value for 'path', path cannot be nil.")
|
75
|
+
end
|
76
|
+
|
77
|
+
if @path.to_s.length < 1
|
78
|
+
invalid_properties.push("invalid value for 'path', the character length must be great than or equal to 1.")
|
79
|
+
end
|
80
|
+
|
81
|
+
if @pages.nil?
|
82
|
+
invalid_properties.push("invalid value for 'pages', pages cannot be nil.")
|
83
|
+
end
|
84
|
+
|
85
|
+
if @pages.to_s.length < 1
|
86
|
+
invalid_properties.push("invalid value for 'pages', the character length must be great than or equal to 1.")
|
87
|
+
end
|
88
|
+
|
89
|
+
return invalid_properties
|
90
|
+
end
|
91
|
+
|
92
|
+
# Check to see if the all the properties in the model are valid
|
93
|
+
# @return true if the model is valid
|
94
|
+
def valid?
|
95
|
+
return false if @path.nil?
|
96
|
+
return false if @path.to_s.length < 1
|
97
|
+
return false if @pages.nil?
|
98
|
+
return false if @pages.to_s.length < 1
|
99
|
+
return true
|
100
|
+
end
|
101
|
+
|
102
|
+
# Custom attribute writer method with validation
|
103
|
+
# @param [Object] path Value to be assigned
|
104
|
+
def path=(path)
|
105
|
+
if path.nil?
|
106
|
+
fail ArgumentError, "path cannot be nil"
|
107
|
+
end
|
108
|
+
|
109
|
+
if path.to_s.length < 1
|
110
|
+
fail ArgumentError, "invalid value for 'path', the character length must be great than or equal to 1."
|
111
|
+
end
|
112
|
+
|
113
|
+
@path = path
|
114
|
+
end
|
115
|
+
|
116
|
+
# Custom attribute writer method with validation
|
117
|
+
# @param [Object] pages Value to be assigned
|
118
|
+
def pages=(pages)
|
119
|
+
if pages.nil?
|
120
|
+
fail ArgumentError, "pages cannot be nil"
|
121
|
+
end
|
122
|
+
|
123
|
+
if pages.to_s.length < 1
|
124
|
+
fail ArgumentError, "invalid value for 'pages', the character length must be great than or equal to 1."
|
125
|
+
end
|
126
|
+
|
127
|
+
@pages = pages
|
128
|
+
end
|
129
|
+
|
130
|
+
# Checks equality by comparing each attribute.
|
131
|
+
# @param [Object] Object to be compared
|
132
|
+
def ==(o)
|
133
|
+
return true if self.equal?(o)
|
134
|
+
self.class == o.class &&
|
135
|
+
path == o.path &&
|
136
|
+
pages == o.pages
|
137
|
+
end
|
138
|
+
|
139
|
+
# @see the `==` method
|
140
|
+
# @param [Object] Object to be compared
|
141
|
+
def eql?(o)
|
142
|
+
self == o
|
143
|
+
end
|
144
|
+
|
145
|
+
# Calculates hash code according to all attributes.
|
146
|
+
# @return [Fixnum] Hash code
|
147
|
+
def hash
|
148
|
+
[path, pages].hash
|
149
|
+
end
|
150
|
+
|
151
|
+
# Builds the object from hash
|
152
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
153
|
+
# @return [Object] Returns the model itself
|
154
|
+
def build_from_hash(attributes)
|
155
|
+
return nil unless attributes.is_a?(Hash)
|
156
|
+
self.class.swagger_types.each_pair do |key, type|
|
157
|
+
if type =~ /\AArray<(.*)>/i
|
158
|
+
# check to ensure the input is an array given that the the attribute
|
159
|
+
# is documented as an array but the input is not
|
160
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
161
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
162
|
+
end
|
163
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
164
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
165
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
166
|
+
end
|
167
|
+
|
168
|
+
self
|
169
|
+
end
|
170
|
+
|
171
|
+
# Deserializes the data based on type
|
172
|
+
# @param string type Data type
|
173
|
+
# @param string value Value to be deserialized
|
174
|
+
# @return [Object] Deserialized data
|
175
|
+
def _deserialize(type, value)
|
176
|
+
case type.to_sym
|
177
|
+
when :DateTime
|
178
|
+
DateTime.parse(value)
|
179
|
+
when :Date
|
180
|
+
Date.parse(value)
|
181
|
+
when :String
|
182
|
+
value.to_s
|
183
|
+
when :Integer
|
184
|
+
value.to_i
|
185
|
+
when :Float
|
186
|
+
value.to_f
|
187
|
+
when :BOOLEAN
|
188
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
189
|
+
true
|
190
|
+
else
|
191
|
+
false
|
192
|
+
end
|
193
|
+
when :Object
|
194
|
+
# generic object (usually a Hash), return directly
|
195
|
+
value
|
196
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
197
|
+
inner_type = Regexp.last_match[:inner_type]
|
198
|
+
value.map { |v| _deserialize(inner_type, v) }
|
199
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
200
|
+
k_type = Regexp.last_match[:k_type]
|
201
|
+
v_type = Regexp.last_match[:v_type]
|
202
|
+
{}.tap do |hash|
|
203
|
+
value.each do |k, v|
|
204
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
else # model
|
208
|
+
temp_model = AsposePdfCloud.const_get(type).new
|
209
|
+
temp_model.build_from_hash(value)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
# Returns the string representation of the object
|
214
|
+
# @return [String] String presentation of the object
|
215
|
+
def to_s
|
216
|
+
to_hash.to_s
|
217
|
+
end
|
218
|
+
|
219
|
+
# to_body is an alias to to_hash (backward compatibility)
|
220
|
+
# @return [Hash] Returns the object in the form of hash
|
221
|
+
def to_body
|
222
|
+
to_hash
|
223
|
+
end
|
224
|
+
|
225
|
+
# Returns the object in the form of hash
|
226
|
+
# @return [Hash] Returns the object in the form of hash
|
227
|
+
def to_hash
|
228
|
+
hash = {}
|
229
|
+
self.class.attribute_map.each_pair do |attr, param|
|
230
|
+
value = self.send(attr)
|
231
|
+
next if value.nil?
|
232
|
+
hash[param] = _to_hash(value)
|
233
|
+
end
|
234
|
+
hash
|
235
|
+
end
|
236
|
+
|
237
|
+
# Outputs non-array value in the form of hash
|
238
|
+
# For object, use to_hash. Otherwise, just return the value
|
239
|
+
# @param [Object] value Any valid value
|
240
|
+
# @return [Hash] Returns the value in the form of hash
|
241
|
+
def _to_hash(value)
|
242
|
+
if value.is_a?(Array)
|
243
|
+
value.compact.map{ |v| _to_hash(v) }
|
244
|
+
elsif value.is_a?(Hash)
|
245
|
+
{}.tap do |hash|
|
246
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
247
|
+
end
|
248
|
+
elsif value.respond_to? :to_hash
|
249
|
+
value.to_hash
|
250
|
+
else
|
251
|
+
value
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|