aspose_pdf_cloud 23.2.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.
@@ -0,0 +1,206 @@
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
+ # Documents data for organizing.
27
+ class OrganizeDocumentRequest
28
+ # List of document data for organizing.
29
+ attr_accessor :list
30
+
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'list' => :'List'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.swagger_types
41
+ {
42
+ :'list' => :'Array<OrganizeDocumentData>'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'List')
55
+ if (value = attributes[:'List']).is_a?(Array)
56
+ self.list = value
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+ # Show invalid properties with the reasons. Usually used together with valid?
63
+ # @return Array for valid properies with the reasons
64
+ def list_invalid_properties
65
+ invalid_properties = Array.new
66
+ if @list.nil?
67
+ invalid_properties.push("invalid value for 'list', list cannot be nil.")
68
+ end
69
+
70
+ return invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ return false if @list.nil?
77
+ return true
78
+ end
79
+
80
+ # Checks equality by comparing each attribute.
81
+ # @param [Object] Object to be compared
82
+ def ==(o)
83
+ return true if self.equal?(o)
84
+ self.class == o.class &&
85
+ list == o.list
86
+ end
87
+
88
+ # @see the `==` method
89
+ # @param [Object] Object to be compared
90
+ def eql?(o)
91
+ self == o
92
+ end
93
+
94
+ # Calculates hash code according to all attributes.
95
+ # @return [Fixnum] Hash code
96
+ def hash
97
+ [list].hash
98
+ end
99
+
100
+ # Builds the object from hash
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ # @return [Object] Returns the model itself
103
+ def build_from_hash(attributes)
104
+ return nil unless attributes.is_a?(Hash)
105
+ self.class.swagger_types.each_pair do |key, type|
106
+ if type =~ /\AArray<(.*)>/i
107
+ # check to ensure the input is an array given that the the attribute
108
+ # is documented as an array but the input is not
109
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
110
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
111
+ end
112
+ elsif !attributes[self.class.attribute_map[key]].nil?
113
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
114
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
115
+ end
116
+
117
+ self
118
+ end
119
+
120
+ # Deserializes the data based on type
121
+ # @param string type Data type
122
+ # @param string value Value to be deserialized
123
+ # @return [Object] Deserialized data
124
+ def _deserialize(type, value)
125
+ case type.to_sym
126
+ when :DateTime
127
+ DateTime.parse(value)
128
+ when :Date
129
+ Date.parse(value)
130
+ when :String
131
+ value.to_s
132
+ when :Integer
133
+ value.to_i
134
+ when :Float
135
+ value.to_f
136
+ when :BOOLEAN
137
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
138
+ true
139
+ else
140
+ false
141
+ end
142
+ when :Object
143
+ # generic object (usually a Hash), return directly
144
+ value
145
+ when /\AArray<(?<inner_type>.+)>\z/
146
+ inner_type = Regexp.last_match[:inner_type]
147
+ value.map { |v| _deserialize(inner_type, v) }
148
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
149
+ k_type = Regexp.last_match[:k_type]
150
+ v_type = Regexp.last_match[:v_type]
151
+ {}.tap do |hash|
152
+ value.each do |k, v|
153
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
154
+ end
155
+ end
156
+ else # model
157
+ temp_model = AsposePdfCloud.const_get(type).new
158
+ temp_model.build_from_hash(value)
159
+ end
160
+ end
161
+
162
+ # Returns the string representation of the object
163
+ # @return [String] String presentation of the object
164
+ def to_s
165
+ to_hash.to_s
166
+ end
167
+
168
+ # to_body is an alias to to_hash (backward compatibility)
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_body
171
+ to_hash
172
+ end
173
+
174
+ # Returns the object in the form of hash
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_hash
177
+ hash = {}
178
+ self.class.attribute_map.each_pair do |attr, param|
179
+ value = self.send(attr)
180
+ next if value.nil?
181
+ hash[param] = _to_hash(value)
182
+ end
183
+ hash
184
+ end
185
+
186
+ # Outputs non-array value in the form of hash
187
+ # For object, use to_hash. Otherwise, just return the value
188
+ # @param [Object] value Any valid value
189
+ # @return [Hash] Returns the value in the form of hash
190
+ def _to_hash(value)
191
+ if value.is_a?(Array)
192
+ value.compact.map{ |v| _to_hash(v) }
193
+ elsif value.is_a?(Hash)
194
+ {}.tap do |hash|
195
+ value.each { |k, v| hash[k] = _to_hash(v) }
196
+ end
197
+ elsif value.respond_to? :to_hash
198
+ value.to_hash
199
+ else
200
+ value
201
+ end
202
+ end
203
+
204
+ end
205
+
206
+ end
@@ -33,8 +33,8 @@ module AsposePdfCloud
33
33
  # Attribute mapping from ruby-style variable name to JSON key.
34
34
  def self.attribute_map
35
35
  {
36
- :'from' => :'from',
37
- :'to' => :'to'
36
+ :'from' => :'From',
37
+ :'to' => :'To'
38
38
  }
39
39
  end
40
40
 
@@ -54,12 +54,12 @@ module AsposePdfCloud
54
54
  # convert string to symbol for hash key
55
55
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
56
56
 
57
- if attributes.has_key?(:'from')
58
- self.from = attributes[:'from']
57
+ if attributes.has_key?(:'From')
58
+ self.from = attributes[:'From']
59
59
  end
60
60
 
61
- if attributes.has_key?(:'to')
62
- self.to = attributes[:'to']
61
+ if attributes.has_key?(:'To')
62
+ self.to = attributes[:'To']
63
63
  end
64
64
 
65
65
  end
@@ -20,5 +20,5 @@ SOFTWARE.
20
20
  =end
21
21
 
22
22
  module AsposePdfCloud
23
- VERSION = "23.2.0"
23
+ VERSION = "23.4.0"
24
24
  end
@@ -92,6 +92,8 @@ require_relative 'aspose_pdf_cloud/models/merge_documents'
92
92
  require_relative 'aspose_pdf_cloud/models/object_exist'
93
93
  require_relative 'aspose_pdf_cloud/models/optimize_options'
94
94
  require_relative 'aspose_pdf_cloud/models/option'
95
+ require_relative 'aspose_pdf_cloud/models/organize_document_data'
96
+ require_relative 'aspose_pdf_cloud/models/organize_document_request'
95
97
  require_relative 'aspose_pdf_cloud/models/output_format'
96
98
  require_relative 'aspose_pdf_cloud/models/page_layout'
97
99
  require_relative 'aspose_pdf_cloud/models/page_mode'
data/test/pdf_tests.rb CHANGED
@@ -29,7 +29,6 @@ class PdfTests < Minitest::Test
29
29
  include MiniTest::Assertions
30
30
  include AsposePdfCloud
31
31
 
32
-
33
32
  def setup
34
33
  servercreds_json = File.read('../../../Settings/servercreds.json')
35
34
  creds = JSON.parse(servercreds_json)
@@ -41,17 +40,14 @@ class PdfTests < Minitest::Test
41
40
  config.scheme = 'https'
42
41
  end
43
42
 
44
-
45
43
  def teardown
46
44
  end
47
45
 
48
-
49
46
  def upload_file(file_name)
50
47
  response = @pdf_api.upload_file(@temp_folder + '/' + file_name, ::File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) } )
51
48
  assert(response, "Failed to upload #{file_name} file.")
52
49
  end
53
50
 
54
-
55
51
  # Annotations Tests
56
52
 
57
53
  def test_get_document_annotations
@@ -3821,6 +3817,36 @@ class PdfTests < Minitest::Test
3821
3817
  assert(response, 'Failed to update document display properties.')
3822
3818
  end
3823
3819
 
3820
+ def test_post_organize_document
3821
+ file_name = '4pages.pdf'
3822
+ upload_file(file_name)
3823
+ opts = {
3824
+ :folder => @temp_folder
3825
+ }
3826
+ response = @pdf_api.post_organize_document(file_name, '1,4-2', @temp_folder + '/' + file_name, opts)
3827
+ assert(response, 'Failed to organize document.')
3828
+ end
3829
+
3830
+ def test_post_organize_documents
3831
+ file_name1 = '4pages.pdf'
3832
+ upload_file(file_name1)
3833
+ file_name2 = 'marketing.pdf'
3834
+ upload_file(file_name2)
3835
+ data1 = OrganizeDocumentData.new
3836
+ data1.path = @temp_folder + '/' + file_name1
3837
+ data1.pages = '4-2'
3838
+ data2 = OrganizeDocumentData.new
3839
+ data2.path = @temp_folder + '/' + file_name2
3840
+ data2.pages = '2'
3841
+ data3 = OrganizeDocumentData.new
3842
+ data3.path = @temp_folder + '/' + file_name1
3843
+ data3.pages = '3,1'
3844
+ request = OrganizeDocumentRequest.new
3845
+ request.list = [data1, data2, data3]
3846
+ response = @pdf_api.post_organize_documents(request, @temp_folder + '/OrganizeMany.pdf')
3847
+ assert(response, 'Failed to organize documents.')
3848
+ end
3849
+
3824
3850
  # Fields Tests
3825
3851
 
3826
3852
  def test_get_field
@@ -3836,7 +3862,6 @@ class PdfTests < Minitest::Test
3836
3862
  assert(response, 'Failed to get document field by name.')
3837
3863
  end
3838
3864
 
3839
-
3840
3865
  def test_get_fields
3841
3866
  file_name = 'PdfWithAcroForm.pdf'
3842
3867
  upload_file(file_name)
@@ -3849,7 +3874,6 @@ class PdfTests < Minitest::Test
3849
3874
  assert(response, 'Failed to get document fields.')
3850
3875
  end
3851
3876
 
3852
-
3853
3877
  def test_post_create_field
3854
3878
  file_name = 'Hello_world.pdf'
3855
3879
  upload_file(file_name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aspose_pdf_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 23.2.0
4
+ version: 23.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aspose PDF Cloud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-27 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -334,6 +334,8 @@ files:
334
334
  - docs/ObjectExist.md
335
335
  - docs/OptimizeOptions.md
336
336
  - docs/Option.md
337
+ - docs/OrganizeDocumentData.md
338
+ - docs/OrganizeDocumentRequest.md
337
339
  - docs/OutputFormat.md
338
340
  - docs/Page.md
339
341
  - docs/PageLayout.md
@@ -622,6 +624,8 @@ files:
622
624
  - lib/aspose_pdf_cloud/models/object_exist.rb
623
625
  - lib/aspose_pdf_cloud/models/optimize_options.rb
624
626
  - lib/aspose_pdf_cloud/models/option.rb
627
+ - lib/aspose_pdf_cloud/models/organize_document_data.rb
628
+ - lib/aspose_pdf_cloud/models/organize_document_request.rb
625
629
  - lib/aspose_pdf_cloud/models/output_format.rb
626
630
  - lib/aspose_pdf_cloud/models/page.rb
627
631
  - lib/aspose_pdf_cloud/models/page_layout.rb