aspose_pdf_cloud 19.3.0 → 19.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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -5
  3. data/docs/BorderCornerStyle.md +11 -0
  4. data/docs/BorderInfo.md +13 -0
  5. data/docs/Cell.md +21 -0
  6. data/docs/ColumnAdjustment.md +12 -0
  7. data/docs/CryptoAlgorithm.md +14 -0
  8. data/docs/GraphInfo.md +19 -0
  9. data/docs/ImageFooter.md +23 -0
  10. data/docs/ImageHeader.md +23 -0
  11. data/docs/ImageStamp.md +5 -5
  12. data/docs/MarginInfo.md +5 -5
  13. data/docs/PageNumberStamp.md +24 -0
  14. data/docs/PdfApi.md +451 -27
  15. data/docs/PdfPageStamp.md +5 -5
  16. data/docs/PermissionsFlags.md +17 -0
  17. data/docs/Row.md +19 -0
  18. data/docs/StampBase.md +0 -5
  19. data/docs/Table.md +31 -0
  20. data/docs/TableBroken.md +12 -0
  21. data/docs/TextFooter.md +23 -0
  22. data/docs/TextHeader.md +23 -0
  23. data/docs/TextStamp.md +5 -5
  24. data/lib/aspose_pdf_cloud.rb +15 -0
  25. data/lib/aspose_pdf_cloud/api/pdf_api.rb +1530 -215
  26. data/lib/aspose_pdf_cloud/models/border_corner_style.rb +44 -0
  27. data/lib/aspose_pdf_cloud/models/border_info.rb +241 -0
  28. data/lib/aspose_pdf_cloud/models/cell.rb +323 -0
  29. data/lib/aspose_pdf_cloud/models/column_adjustment.rb +45 -0
  30. data/lib/aspose_pdf_cloud/models/crypto_algorithm.rb +46 -0
  31. data/lib/aspose_pdf_cloud/models/graph_info.rb +303 -0
  32. data/lib/aspose_pdf_cloud/models/image_footer.rb +343 -0
  33. data/lib/aspose_pdf_cloud/models/image_header.rb +343 -0
  34. data/lib/aspose_pdf_cloud/models/image_stamp.rb +54 -54
  35. data/lib/aspose_pdf_cloud/models/margin_info.rb +5 -21
  36. data/lib/aspose_pdf_cloud/models/page_number_stamp.rb +353 -0
  37. data/lib/aspose_pdf_cloud/models/pdf_page_stamp.rb +54 -54
  38. data/lib/aspose_pdf_cloud/models/permissions_flags.rb +50 -0
  39. data/lib/aspose_pdf_cloud/models/row.rb +308 -0
  40. data/lib/aspose_pdf_cloud/models/stamp_base.rb +1 -51
  41. data/lib/aspose_pdf_cloud/models/table.rb +425 -0
  42. data/lib/aspose_pdf_cloud/models/table_broken.rb +45 -0
  43. data/lib/aspose_pdf_cloud/models/text_footer.rb +343 -0
  44. data/lib/aspose_pdf_cloud/models/text_header.rb +343 -0
  45. data/lib/aspose_pdf_cloud/models/text_stamp.rb +54 -54
  46. data/lib/aspose_pdf_cloud/version.rb +1 -1
  47. data/test/pdf_tests.rb +407 -5
  48. data/test_data/4pagesEncrypted.pdf +0 -0
  49. metadata +33 -2
@@ -0,0 +1,44 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2019 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
+ class BorderCornerStyle
27
+
28
+ NONE = "None".freeze
29
+ ROUND = "Round".freeze
30
+
31
+ # Builds the enum from string
32
+ # @param [String] The enum value in the form of the string
33
+ # @return [String] The enum value
34
+ def build_from_hash(value)
35
+ # resolve issue with Concstant Name modification (ex: "FooName" to :FOO_NAME)
36
+ # consantValues = BorderCornerStyle.constants.select{|c| c.to_s == value}
37
+ constantValues = BorderCornerStyle.constants.select{ |const_name| BorderCornerStyle.const_get(const_name) == value}
38
+
39
+ raise "Invalid ENUM value #{value} for class #BorderCornerStyle" if constantValues.empty?
40
+ value
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,241 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2019 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
+ # This class represents border for graphics elements.
27
+ class BorderInfo
28
+ # Gets or sets a object that indicates left of the border.
29
+ attr_accessor :left
30
+
31
+ # Gets or sets a object that indicates right of the border.
32
+ attr_accessor :right
33
+
34
+ # Gets or sets a object that indicates the top border.
35
+ attr_accessor :top
36
+
37
+ # Gets or sets a object that indicates bottom of the border.
38
+ attr_accessor :bottom
39
+
40
+ # Gets or sets a rouded border radius
41
+ attr_accessor :rounded_border_radius
42
+
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'left' => :'Left',
48
+ :'right' => :'Right',
49
+ :'top' => :'Top',
50
+ :'bottom' => :'Bottom',
51
+ :'rounded_border_radius' => :'RoundedBorderRadius'
52
+ }
53
+ end
54
+
55
+ # Attribute type mapping.
56
+ def self.swagger_types
57
+ {
58
+ :'left' => :'GraphInfo',
59
+ :'right' => :'GraphInfo',
60
+ :'top' => :'GraphInfo',
61
+ :'bottom' => :'GraphInfo',
62
+ :'rounded_border_radius' => :'Float'
63
+ }
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ return unless attributes.is_a?(Hash)
70
+
71
+ # convert string to symbol for hash key
72
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
73
+
74
+ if attributes.has_key?(:'Left')
75
+ self.left = attributes[:'Left']
76
+ end
77
+
78
+ if attributes.has_key?(:'Right')
79
+ self.right = attributes[:'Right']
80
+ end
81
+
82
+ if attributes.has_key?(:'Top')
83
+ self.top = attributes[:'Top']
84
+ end
85
+
86
+ if attributes.has_key?(:'Bottom')
87
+ self.bottom = attributes[:'Bottom']
88
+ end
89
+
90
+ if attributes.has_key?(:'RoundedBorderRadius')
91
+ self.rounded_border_radius = attributes[:'RoundedBorderRadius']
92
+ end
93
+
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properies with the reasons
98
+ def list_invalid_properties
99
+ invalid_properties = Array.new
100
+ return invalid_properties
101
+ end
102
+
103
+ # Check to see if the all the properties in the model are valid
104
+ # @return true if the model is valid
105
+ def valid?
106
+ return true
107
+ end
108
+
109
+ # Checks equality by comparing each attribute.
110
+ # @param [Object] Object to be compared
111
+ def ==(o)
112
+ return true if self.equal?(o)
113
+ self.class == o.class &&
114
+ left == o.left &&
115
+ right == o.right &&
116
+ top == o.top &&
117
+ bottom == o.bottom &&
118
+ rounded_border_radius == o.rounded_border_radius
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(o)
124
+ self == o
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Fixnum] Hash code
129
+ def hash
130
+ [left, right, top, bottom, rounded_border_radius].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def build_from_hash(attributes)
137
+ return nil unless attributes.is_a?(Hash)
138
+ self.class.swagger_types.each_pair do |key, type|
139
+ if type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
143
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
144
+ end
145
+ elsif !attributes[self.class.attribute_map[key]].nil?
146
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
147
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
148
+ end
149
+
150
+ self
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def _deserialize(type, value)
158
+ case type.to_sym
159
+ when :DateTime
160
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
161
+ Time.strptime(value, format).utc.to_datetime
162
+ when :Date
163
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
164
+ Time.strptime(value, format).utc.to_datetime.to_date
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :BOOLEAN
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+ when :Object
178
+ # generic object (usually a Hash), return directly
179
+ value
180
+ when /\AArray<(?<inner_type>.+)>\z/
181
+ inner_type = Regexp.last_match[:inner_type]
182
+ value.map { |v| _deserialize(inner_type, v) }
183
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
184
+ k_type = Regexp.last_match[:k_type]
185
+ v_type = Regexp.last_match[:v_type]
186
+ {}.tap do |hash|
187
+ value.each do |k, v|
188
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
189
+ end
190
+ end
191
+ else # model
192
+ temp_model = AsposePdfCloud.const_get(type).new
193
+ temp_model.build_from_hash(value)
194
+ end
195
+ end
196
+
197
+ # Returns the string representation of the object
198
+ # @return [String] String presentation of the object
199
+ def to_s
200
+ to_hash.to_s
201
+ end
202
+
203
+ # to_body is an alias to to_hash (backward compatibility)
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_body
206
+ to_hash
207
+ end
208
+
209
+ # Returns the object in the form of hash
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_hash
212
+ hash = {}
213
+ self.class.attribute_map.each_pair do |attr, param|
214
+ value = self.send(attr)
215
+ next if value.nil?
216
+ hash[param] = _to_hash(value)
217
+ end
218
+ hash
219
+ end
220
+
221
+ # Outputs non-array value in the form of hash
222
+ # For object, use to_hash. Otherwise, just return the value
223
+ # @param [Object] value Any valid value
224
+ # @return [Hash] Returns the value in the form of hash
225
+ def _to_hash(value)
226
+ if value.is_a?(Array)
227
+ value.compact.map{ |v| _to_hash(v) }
228
+ elsif value.is_a?(Hash)
229
+ {}.tap do |hash|
230
+ value.each { |k, v| hash[k] = _to_hash(v) }
231
+ end
232
+ elsif value.respond_to? :to_hash
233
+ value.to_hash
234
+ else
235
+ value
236
+ end
237
+ end
238
+
239
+ end
240
+
241
+ end
@@ -0,0 +1,323 @@
1
+ =begin
2
+ --------------------------------------------------------------------------------------------------------------------
3
+ Copyright (c) 2019 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
+ # Represents a cell of the table's row.
27
+ class Cell
28
+ # Gets or sets the cell have border.
29
+ attr_accessor :is_no_border
30
+
31
+ # Gets or sets the padding.
32
+ attr_accessor :margin
33
+
34
+ # Gets or sets the border.
35
+ attr_accessor :border
36
+
37
+ # Gets or sets the background color.
38
+ attr_accessor :background_color
39
+
40
+ # Gets or sets the background image file.
41
+ attr_accessor :background_image_file
42
+
43
+ # Gets or sets the alignment.
44
+ attr_accessor :alignment
45
+
46
+ # Gets or sets the default cell text state.
47
+ attr_accessor :default_cell_text_state
48
+
49
+ # Gets or sets the cell's formatted text.
50
+ attr_accessor :paragraphs
51
+
52
+ # Gets or sets the cell's text word wrapped.
53
+ attr_accessor :is_word_wrapped
54
+
55
+ # Gets or sets the vertical alignment.
56
+ attr_accessor :vertical_alignment
57
+
58
+ # Gets or sets the column span.
59
+ attr_accessor :col_span
60
+
61
+ # Gets or sets the row span.
62
+ attr_accessor :row_span
63
+
64
+ # Gets or sets the column width.
65
+ attr_accessor :width
66
+
67
+
68
+ # Attribute mapping from ruby-style variable name to JSON key.
69
+ def self.attribute_map
70
+ {
71
+ :'is_no_border' => :'IsNoBorder',
72
+ :'margin' => :'Margin',
73
+ :'border' => :'Border',
74
+ :'background_color' => :'BackgroundColor',
75
+ :'background_image_file' => :'BackgroundImageFile',
76
+ :'alignment' => :'Alignment',
77
+ :'default_cell_text_state' => :'DefaultCellTextState',
78
+ :'paragraphs' => :'Paragraphs',
79
+ :'is_word_wrapped' => :'IsWordWrapped',
80
+ :'vertical_alignment' => :'VerticalAlignment',
81
+ :'col_span' => :'ColSpan',
82
+ :'row_span' => :'RowSpan',
83
+ :'width' => :'Width'
84
+ }
85
+ end
86
+
87
+ # Attribute type mapping.
88
+ def self.swagger_types
89
+ {
90
+ :'is_no_border' => :'BOOLEAN',
91
+ :'margin' => :'MarginInfo',
92
+ :'border' => :'BorderInfo',
93
+ :'background_color' => :'Color',
94
+ :'background_image_file' => :'String',
95
+ :'alignment' => :'HorizontalAlignment',
96
+ :'default_cell_text_state' => :'TextState',
97
+ :'paragraphs' => :'Array<TextRect>',
98
+ :'is_word_wrapped' => :'BOOLEAN',
99
+ :'vertical_alignment' => :'VerticalAlignment',
100
+ :'col_span' => :'Integer',
101
+ :'row_span' => :'Integer',
102
+ :'width' => :'Float'
103
+ }
104
+ end
105
+
106
+ # Initializes the object
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ def initialize(attributes = {})
109
+ return unless attributes.is_a?(Hash)
110
+
111
+ # convert string to symbol for hash key
112
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
113
+
114
+ if attributes.has_key?(:'IsNoBorder')
115
+ self.is_no_border = attributes[:'IsNoBorder']
116
+ end
117
+
118
+ if attributes.has_key?(:'Margin')
119
+ self.margin = attributes[:'Margin']
120
+ end
121
+
122
+ if attributes.has_key?(:'Border')
123
+ self.border = attributes[:'Border']
124
+ end
125
+
126
+ if attributes.has_key?(:'BackgroundColor')
127
+ self.background_color = attributes[:'BackgroundColor']
128
+ end
129
+
130
+ if attributes.has_key?(:'BackgroundImageFile')
131
+ self.background_image_file = attributes[:'BackgroundImageFile']
132
+ end
133
+
134
+ if attributes.has_key?(:'Alignment')
135
+ self.alignment = attributes[:'Alignment']
136
+ end
137
+
138
+ if attributes.has_key?(:'DefaultCellTextState')
139
+ self.default_cell_text_state = attributes[:'DefaultCellTextState']
140
+ end
141
+
142
+ if attributes.has_key?(:'Paragraphs')
143
+ if (value = attributes[:'Paragraphs']).is_a?(Array)
144
+ self.paragraphs = value
145
+ end
146
+ end
147
+
148
+ if attributes.has_key?(:'IsWordWrapped')
149
+ self.is_word_wrapped = attributes[:'IsWordWrapped']
150
+ end
151
+
152
+ if attributes.has_key?(:'VerticalAlignment')
153
+ self.vertical_alignment = attributes[:'VerticalAlignment']
154
+ end
155
+
156
+ if attributes.has_key?(:'ColSpan')
157
+ self.col_span = attributes[:'ColSpan']
158
+ end
159
+
160
+ if attributes.has_key?(:'RowSpan')
161
+ self.row_span = attributes[:'RowSpan']
162
+ end
163
+
164
+ if attributes.has_key?(:'Width')
165
+ self.width = attributes[:'Width']
166
+ end
167
+
168
+ end
169
+
170
+ # Show invalid properties with the reasons. Usually used together with valid?
171
+ # @return Array for valid properies with the reasons
172
+ def list_invalid_properties
173
+ invalid_properties = Array.new
174
+ return invalid_properties
175
+ end
176
+
177
+ # Check to see if the all the properties in the model are valid
178
+ # @return true if the model is valid
179
+ def valid?
180
+ return true
181
+ end
182
+
183
+ # Checks equality by comparing each attribute.
184
+ # @param [Object] Object to be compared
185
+ def ==(o)
186
+ return true if self.equal?(o)
187
+ self.class == o.class &&
188
+ is_no_border == o.is_no_border &&
189
+ margin == o.margin &&
190
+ border == o.border &&
191
+ background_color == o.background_color &&
192
+ background_image_file == o.background_image_file &&
193
+ alignment == o.alignment &&
194
+ default_cell_text_state == o.default_cell_text_state &&
195
+ paragraphs == o.paragraphs &&
196
+ is_word_wrapped == o.is_word_wrapped &&
197
+ vertical_alignment == o.vertical_alignment &&
198
+ col_span == o.col_span &&
199
+ row_span == o.row_span &&
200
+ width == o.width
201
+ end
202
+
203
+ # @see the `==` method
204
+ # @param [Object] Object to be compared
205
+ def eql?(o)
206
+ self == o
207
+ end
208
+
209
+ # Calculates hash code according to all attributes.
210
+ # @return [Fixnum] Hash code
211
+ def hash
212
+ [is_no_border, margin, border, background_color, background_image_file, alignment, default_cell_text_state, paragraphs, is_word_wrapped, vertical_alignment, col_span, row_span, width].hash
213
+ end
214
+
215
+ # Builds the object from hash
216
+ # @param [Hash] attributes Model attributes in the form of hash
217
+ # @return [Object] Returns the model itself
218
+ def build_from_hash(attributes)
219
+ return nil unless attributes.is_a?(Hash)
220
+ self.class.swagger_types.each_pair do |key, type|
221
+ if type =~ /\AArray<(.*)>/i
222
+ # check to ensure the input is an array given that the the attribute
223
+ # is documented as an array but the input is not
224
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
225
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
226
+ end
227
+ elsif !attributes[self.class.attribute_map[key]].nil?
228
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
229
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
230
+ end
231
+
232
+ self
233
+ end
234
+
235
+ # Deserializes the data based on type
236
+ # @param string type Data type
237
+ # @param string value Value to be deserialized
238
+ # @return [Object] Deserialized data
239
+ def _deserialize(type, value)
240
+ case type.to_sym
241
+ when :DateTime
242
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
243
+ Time.strptime(value, format).utc.to_datetime
244
+ when :Date
245
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
246
+ Time.strptime(value, format).utc.to_datetime.to_date
247
+ when :String
248
+ value.to_s
249
+ when :Integer
250
+ value.to_i
251
+ when :Float
252
+ value.to_f
253
+ when :BOOLEAN
254
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
255
+ true
256
+ else
257
+ false
258
+ end
259
+ when :Object
260
+ # generic object (usually a Hash), return directly
261
+ value
262
+ when /\AArray<(?<inner_type>.+)>\z/
263
+ inner_type = Regexp.last_match[:inner_type]
264
+ value.map { |v| _deserialize(inner_type, v) }
265
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
266
+ k_type = Regexp.last_match[:k_type]
267
+ v_type = Regexp.last_match[:v_type]
268
+ {}.tap do |hash|
269
+ value.each do |k, v|
270
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
271
+ end
272
+ end
273
+ else # model
274
+ temp_model = AsposePdfCloud.const_get(type).new
275
+ temp_model.build_from_hash(value)
276
+ end
277
+ end
278
+
279
+ # Returns the string representation of the object
280
+ # @return [String] String presentation of the object
281
+ def to_s
282
+ to_hash.to_s
283
+ end
284
+
285
+ # to_body is an alias to to_hash (backward compatibility)
286
+ # @return [Hash] Returns the object in the form of hash
287
+ def to_body
288
+ to_hash
289
+ end
290
+
291
+ # Returns the object in the form of hash
292
+ # @return [Hash] Returns the object in the form of hash
293
+ def to_hash
294
+ hash = {}
295
+ self.class.attribute_map.each_pair do |attr, param|
296
+ value = self.send(attr)
297
+ next if value.nil?
298
+ hash[param] = _to_hash(value)
299
+ end
300
+ hash
301
+ end
302
+
303
+ # Outputs non-array value in the form of hash
304
+ # For object, use to_hash. Otherwise, just return the value
305
+ # @param [Object] value Any valid value
306
+ # @return [Hash] Returns the value in the form of hash
307
+ def _to_hash(value)
308
+ if value.is_a?(Array)
309
+ value.compact.map{ |v| _to_hash(v) }
310
+ elsif value.is_a?(Hash)
311
+ {}.tap do |hash|
312
+ value.each { |k, v| hash[k] = _to_hash(v) }
313
+ end
314
+ elsif value.respond_to? :to_hash
315
+ value.to_hash
316
+ else
317
+ value
318
+ end
319
+ end
320
+
321
+ end
322
+
323
+ end