aspose_pdf_cloud 19.7.0 → 19.8.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,329 @@
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
+ # An abstract class which represents signature custon appearance object.
27
+ class SignatureCustomAppearance
28
+ # Gets/sets font family name. It should be existed in the document. Default value: Arial.
29
+ attr_accessor :font_family_name
30
+
31
+ # Gets/sets font size. Default value: 10.
32
+ attr_accessor :font_size
33
+
34
+ # Gets/sets contact info visibility. Default value: true.
35
+ attr_accessor :show_contact_info
36
+
37
+ # Gets/sets reason visibility. Default value: true.
38
+ attr_accessor :show_reason
39
+
40
+ # Gets/sets location visibility. Default value: true.
41
+ attr_accessor :show_location
42
+
43
+ # Gets/sets contact info label. Default value: \"Contact\".
44
+ attr_accessor :contact_info_label
45
+
46
+ # Gets/sets reason label. Default value: \"Reason\".
47
+ attr_accessor :reason_label
48
+
49
+ # Gets/sets location label. Default value: \"Location\".
50
+ attr_accessor :location_label
51
+
52
+ # Gets/sets digital signed label. Default value: \"Digitally signed by\".
53
+ attr_accessor :digital_signed_label
54
+
55
+ # Gets/sets date signed label. Default value: \"Date\".
56
+ attr_accessor :date_signed_at_label
57
+
58
+ # Gets/sets datetime local format. Default value: \"yyyy.MM.dd HH:mm:ss zzz\".
59
+ attr_accessor :date_time_local_format
60
+
61
+ # Gets/sets datetime format. Default value: \"yyyy.MM.dd HH:mm:ss\".
62
+ attr_accessor :date_time_format
63
+
64
+
65
+ # Attribute mapping from ruby-style variable name to JSON key.
66
+ def self.attribute_map
67
+ {
68
+ :'font_family_name' => :'FontFamilyName',
69
+ :'font_size' => :'FontSize',
70
+ :'show_contact_info' => :'ShowContactInfo',
71
+ :'show_reason' => :'ShowReason',
72
+ :'show_location' => :'ShowLocation',
73
+ :'contact_info_label' => :'ContactInfoLabel',
74
+ :'reason_label' => :'ReasonLabel',
75
+ :'location_label' => :'LocationLabel',
76
+ :'digital_signed_label' => :'DigitalSignedLabel',
77
+ :'date_signed_at_label' => :'DateSignedAtLabel',
78
+ :'date_time_local_format' => :'DateTimeLocalFormat',
79
+ :'date_time_format' => :'DateTimeFormat'
80
+ }
81
+ end
82
+
83
+ # Attribute type mapping.
84
+ def self.swagger_types
85
+ {
86
+ :'font_family_name' => :'String',
87
+ :'font_size' => :'Float',
88
+ :'show_contact_info' => :'BOOLEAN',
89
+ :'show_reason' => :'BOOLEAN',
90
+ :'show_location' => :'BOOLEAN',
91
+ :'contact_info_label' => :'String',
92
+ :'reason_label' => :'String',
93
+ :'location_label' => :'String',
94
+ :'digital_signed_label' => :'String',
95
+ :'date_signed_at_label' => :'String',
96
+ :'date_time_local_format' => :'String',
97
+ :'date_time_format' => :'String'
98
+ }
99
+ end
100
+
101
+ # Initializes the object
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ def initialize(attributes = {})
104
+ return unless attributes.is_a?(Hash)
105
+
106
+ # convert string to symbol for hash key
107
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
108
+
109
+ if attributes.has_key?(:'FontFamilyName')
110
+ self.font_family_name = attributes[:'FontFamilyName']
111
+ end
112
+
113
+ if attributes.has_key?(:'FontSize')
114
+ self.font_size = attributes[:'FontSize']
115
+ end
116
+
117
+ if attributes.has_key?(:'ShowContactInfo')
118
+ self.show_contact_info = attributes[:'ShowContactInfo']
119
+ end
120
+
121
+ if attributes.has_key?(:'ShowReason')
122
+ self.show_reason = attributes[:'ShowReason']
123
+ end
124
+
125
+ if attributes.has_key?(:'ShowLocation')
126
+ self.show_location = attributes[:'ShowLocation']
127
+ end
128
+
129
+ if attributes.has_key?(:'ContactInfoLabel')
130
+ self.contact_info_label = attributes[:'ContactInfoLabel']
131
+ end
132
+
133
+ if attributes.has_key?(:'ReasonLabel')
134
+ self.reason_label = attributes[:'ReasonLabel']
135
+ end
136
+
137
+ if attributes.has_key?(:'LocationLabel')
138
+ self.location_label = attributes[:'LocationLabel']
139
+ end
140
+
141
+ if attributes.has_key?(:'DigitalSignedLabel')
142
+ self.digital_signed_label = attributes[:'DigitalSignedLabel']
143
+ end
144
+
145
+ if attributes.has_key?(:'DateSignedAtLabel')
146
+ self.date_signed_at_label = attributes[:'DateSignedAtLabel']
147
+ end
148
+
149
+ if attributes.has_key?(:'DateTimeLocalFormat')
150
+ self.date_time_local_format = attributes[:'DateTimeLocalFormat']
151
+ end
152
+
153
+ if attributes.has_key?(:'DateTimeFormat')
154
+ self.date_time_format = attributes[:'DateTimeFormat']
155
+ end
156
+
157
+ end
158
+
159
+ # Show invalid properties with the reasons. Usually used together with valid?
160
+ # @return Array for valid properies with the reasons
161
+ def list_invalid_properties
162
+ invalid_properties = Array.new
163
+ if @font_size.nil?
164
+ invalid_properties.push("invalid value for 'font_size', font_size cannot be nil.")
165
+ end
166
+
167
+ if @show_contact_info.nil?
168
+ invalid_properties.push("invalid value for 'show_contact_info', show_contact_info cannot be nil.")
169
+ end
170
+
171
+ if @show_reason.nil?
172
+ invalid_properties.push("invalid value for 'show_reason', show_reason cannot be nil.")
173
+ end
174
+
175
+ if @show_location.nil?
176
+ invalid_properties.push("invalid value for 'show_location', show_location cannot be nil.")
177
+ end
178
+
179
+ return invalid_properties
180
+ end
181
+
182
+ # Check to see if the all the properties in the model are valid
183
+ # @return true if the model is valid
184
+ def valid?
185
+ return false if @font_size.nil?
186
+ return false if @show_contact_info.nil?
187
+ return false if @show_reason.nil?
188
+ return false if @show_location.nil?
189
+ return true
190
+ end
191
+
192
+ # Checks equality by comparing each attribute.
193
+ # @param [Object] Object to be compared
194
+ def ==(o)
195
+ return true if self.equal?(o)
196
+ self.class == o.class &&
197
+ font_family_name == o.font_family_name &&
198
+ font_size == o.font_size &&
199
+ show_contact_info == o.show_contact_info &&
200
+ show_reason == o.show_reason &&
201
+ show_location == o.show_location &&
202
+ contact_info_label == o.contact_info_label &&
203
+ reason_label == o.reason_label &&
204
+ location_label == o.location_label &&
205
+ digital_signed_label == o.digital_signed_label &&
206
+ date_signed_at_label == o.date_signed_at_label &&
207
+ date_time_local_format == o.date_time_local_format &&
208
+ date_time_format == o.date_time_format
209
+ end
210
+
211
+ # @see the `==` method
212
+ # @param [Object] Object to be compared
213
+ def eql?(o)
214
+ self == o
215
+ end
216
+
217
+ # Calculates hash code according to all attributes.
218
+ # @return [Fixnum] Hash code
219
+ def hash
220
+ [font_family_name, font_size, show_contact_info, show_reason, show_location, contact_info_label, reason_label, location_label, digital_signed_label, date_signed_at_label, date_time_local_format, date_time_format].hash
221
+ end
222
+
223
+ # Builds the object from hash
224
+ # @param [Hash] attributes Model attributes in the form of hash
225
+ # @return [Object] Returns the model itself
226
+ def build_from_hash(attributes)
227
+ return nil unless attributes.is_a?(Hash)
228
+ self.class.swagger_types.each_pair do |key, type|
229
+ if type =~ /\AArray<(.*)>/i
230
+ # check to ensure the input is an array given that the the attribute
231
+ # is documented as an array but the input is not
232
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
233
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
234
+ end
235
+ elsif !attributes[self.class.attribute_map[key]].nil?
236
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
237
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
238
+ end
239
+
240
+ self
241
+ end
242
+
243
+ # Deserializes the data based on type
244
+ # @param string type Data type
245
+ # @param string value Value to be deserialized
246
+ # @return [Object] Deserialized data
247
+ def _deserialize(type, value)
248
+ case type.to_sym
249
+ when :DateTime
250
+ DateTime.parse(value)
251
+ when :Date
252
+ Date.parse(value)
253
+ when :String
254
+ value.to_s
255
+ when :Integer
256
+ value.to_i
257
+ when :Float
258
+ value.to_f
259
+ when :BOOLEAN
260
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
261
+ true
262
+ else
263
+ false
264
+ end
265
+ when :Object
266
+ # generic object (usually a Hash), return directly
267
+ value
268
+ when /\AArray<(?<inner_type>.+)>\z/
269
+ inner_type = Regexp.last_match[:inner_type]
270
+ value.map { |v| _deserialize(inner_type, v) }
271
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
272
+ k_type = Regexp.last_match[:k_type]
273
+ v_type = Regexp.last_match[:v_type]
274
+ {}.tap do |hash|
275
+ value.each do |k, v|
276
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
277
+ end
278
+ end
279
+ else # model
280
+ temp_model = AsposePdfCloud.const_get(type).new
281
+ temp_model.build_from_hash(value)
282
+ end
283
+ end
284
+
285
+ # Returns the string representation of the object
286
+ # @return [String] String presentation of the object
287
+ def to_s
288
+ to_hash.to_s
289
+ end
290
+
291
+ # to_body is an alias to to_hash (backward compatibility)
292
+ # @return [Hash] Returns the object in the form of hash
293
+ def to_body
294
+ to_hash
295
+ end
296
+
297
+ # Returns the object in the form of hash
298
+ # @return [Hash] Returns the object in the form of hash
299
+ def to_hash
300
+ hash = {}
301
+ self.class.attribute_map.each_pair do |attr, param|
302
+ value = self.send(attr)
303
+ next if value.nil?
304
+ hash[param] = _to_hash(value)
305
+ end
306
+ hash
307
+ end
308
+
309
+ # Outputs non-array value in the form of hash
310
+ # For object, use to_hash. Otherwise, just return the value
311
+ # @param [Object] value Any valid value
312
+ # @return [Hash] Returns the value in the form of hash
313
+ def _to_hash(value)
314
+ if value.is_a?(Array)
315
+ value.compact.map{ |v| _to_hash(v) }
316
+ elsif value.is_a?(Hash)
317
+ {}.tap do |hash|
318
+ value.each { |k, v| hash[k] = _to_hash(v) }
319
+ end
320
+ elsif value.respond_to? :to_hash
321
+ value.to_hash
322
+ else
323
+ value
324
+ end
325
+ end
326
+
327
+ end
328
+
329
+ end
@@ -0,0 +1,393 @@
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
+ # Provides SignatureField.
27
+ class SignatureField
28
+ # Link to the document.
29
+ attr_accessor :links
30
+
31
+ # Field name.
32
+ attr_accessor :partial_name
33
+
34
+ # Field rectangle.
35
+ attr_accessor :rect
36
+
37
+ # Field value.
38
+ attr_accessor :value
39
+
40
+ # Page index.
41
+ attr_accessor :page_index
42
+
43
+ # Gets or sets height of the field.
44
+ attr_accessor :height
45
+
46
+ # Gets or sets width of the field.
47
+ attr_accessor :width
48
+
49
+ # Z index.
50
+ attr_accessor :z_index
51
+
52
+ # Is group.
53
+ attr_accessor :is_group
54
+
55
+ # Gets field parent.
56
+ attr_accessor :parent
57
+
58
+ # Property for Generator support. Used when field is added to header or footer. If true, this field will created once and it's appearance will be visible on all pages of the document. If false, separated field will be created for every document page.
59
+ attr_accessor :is_shared_field
60
+
61
+ # Gets Flags of the field.
62
+ attr_accessor :flags
63
+
64
+ # Color of the annotation.
65
+ attr_accessor :color
66
+
67
+ # Get the field content.
68
+ attr_accessor :contents
69
+
70
+ # Gets or sets a outer margin for paragraph (for pdf generation)
71
+ attr_accessor :margin
72
+
73
+ # Field highlighting mode.
74
+ attr_accessor :highlighting
75
+
76
+ # Gets HorizontalAlignment of the field.
77
+ attr_accessor :horizontal_alignment
78
+
79
+ # Gets VerticalAlignment of the field.
80
+ attr_accessor :vertical_alignment
81
+
82
+ # Gets signature object. This object contains signature data regarding public-key cryptographic standards. Classes PKCS1, PKCS7 and PKCS7Detached represent all supported types of signature objects.
83
+ attr_accessor :signature
84
+
85
+
86
+ # Attribute mapping from ruby-style variable name to JSON key.
87
+ def self.attribute_map
88
+ {
89
+ :'links' => :'Links',
90
+ :'partial_name' => :'PartialName',
91
+ :'rect' => :'Rect',
92
+ :'value' => :'Value',
93
+ :'page_index' => :'PageIndex',
94
+ :'height' => :'Height',
95
+ :'width' => :'Width',
96
+ :'z_index' => :'ZIndex',
97
+ :'is_group' => :'IsGroup',
98
+ :'parent' => :'Parent',
99
+ :'is_shared_field' => :'IsSharedField',
100
+ :'flags' => :'Flags',
101
+ :'color' => :'Color',
102
+ :'contents' => :'Contents',
103
+ :'margin' => :'Margin',
104
+ :'highlighting' => :'Highlighting',
105
+ :'horizontal_alignment' => :'HorizontalAlignment',
106
+ :'vertical_alignment' => :'VerticalAlignment',
107
+ :'signature' => :'Signature'
108
+ }
109
+ end
110
+
111
+ # Attribute type mapping.
112
+ def self.swagger_types
113
+ {
114
+ :'links' => :'Array<Link>',
115
+ :'partial_name' => :'String',
116
+ :'rect' => :'Rectangle',
117
+ :'value' => :'String',
118
+ :'page_index' => :'Integer',
119
+ :'height' => :'Float',
120
+ :'width' => :'Float',
121
+ :'z_index' => :'Integer',
122
+ :'is_group' => :'BOOLEAN',
123
+ :'parent' => :'FormField',
124
+ :'is_shared_field' => :'BOOLEAN',
125
+ :'flags' => :'Array<AnnotationFlags>',
126
+ :'color' => :'Color',
127
+ :'contents' => :'String',
128
+ :'margin' => :'MarginInfo',
129
+ :'highlighting' => :'LinkHighlightingMode',
130
+ :'horizontal_alignment' => :'HorizontalAlignment',
131
+ :'vertical_alignment' => :'VerticalAlignment',
132
+ :'signature' => :'Signature'
133
+ }
134
+ end
135
+
136
+ # Initializes the object
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ def initialize(attributes = {})
139
+ return unless attributes.is_a?(Hash)
140
+
141
+ # convert string to symbol for hash key
142
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
143
+
144
+ if attributes.has_key?(:'Links')
145
+ if (value = attributes[:'Links']).is_a?(Array)
146
+ self.links = value
147
+ end
148
+ end
149
+
150
+ if attributes.has_key?(:'PartialName')
151
+ self.partial_name = attributes[:'PartialName']
152
+ end
153
+
154
+ if attributes.has_key?(:'Rect')
155
+ self.rect = attributes[:'Rect']
156
+ end
157
+
158
+ if attributes.has_key?(:'Value')
159
+ self.value = attributes[:'Value']
160
+ end
161
+
162
+ if attributes.has_key?(:'PageIndex')
163
+ self.page_index = attributes[:'PageIndex']
164
+ end
165
+
166
+ if attributes.has_key?(:'Height')
167
+ self.height = attributes[:'Height']
168
+ end
169
+
170
+ if attributes.has_key?(:'Width')
171
+ self.width = attributes[:'Width']
172
+ end
173
+
174
+ if attributes.has_key?(:'ZIndex')
175
+ self.z_index = attributes[:'ZIndex']
176
+ end
177
+
178
+ if attributes.has_key?(:'IsGroup')
179
+ self.is_group = attributes[:'IsGroup']
180
+ end
181
+
182
+ if attributes.has_key?(:'Parent')
183
+ self.parent = attributes[:'Parent']
184
+ end
185
+
186
+ if attributes.has_key?(:'IsSharedField')
187
+ self.is_shared_field = attributes[:'IsSharedField']
188
+ end
189
+
190
+ if attributes.has_key?(:'Flags')
191
+ if (value = attributes[:'Flags']).is_a?(Array)
192
+ self.flags = value
193
+ end
194
+ end
195
+
196
+ if attributes.has_key?(:'Color')
197
+ self.color = attributes[:'Color']
198
+ end
199
+
200
+ if attributes.has_key?(:'Contents')
201
+ self.contents = attributes[:'Contents']
202
+ end
203
+
204
+ if attributes.has_key?(:'Margin')
205
+ self.margin = attributes[:'Margin']
206
+ end
207
+
208
+ if attributes.has_key?(:'Highlighting')
209
+ self.highlighting = attributes[:'Highlighting']
210
+ end
211
+
212
+ if attributes.has_key?(:'HorizontalAlignment')
213
+ self.horizontal_alignment = attributes[:'HorizontalAlignment']
214
+ end
215
+
216
+ if attributes.has_key?(:'VerticalAlignment')
217
+ self.vertical_alignment = attributes[:'VerticalAlignment']
218
+ end
219
+
220
+ if attributes.has_key?(:'Signature')
221
+ self.signature = attributes[:'Signature']
222
+ end
223
+
224
+ end
225
+
226
+ # Show invalid properties with the reasons. Usually used together with valid?
227
+ # @return Array for valid properies with the reasons
228
+ def list_invalid_properties
229
+ invalid_properties = Array.new
230
+ if @page_index.nil?
231
+ invalid_properties.push("invalid value for 'page_index', page_index cannot be nil.")
232
+ end
233
+
234
+ if @is_group.nil?
235
+ invalid_properties.push("invalid value for 'is_group', is_group cannot be nil.")
236
+ end
237
+
238
+ return invalid_properties
239
+ end
240
+
241
+ # Check to see if the all the properties in the model are valid
242
+ # @return true if the model is valid
243
+ def valid?
244
+ return false if @page_index.nil?
245
+ return false if @is_group.nil?
246
+ return true
247
+ end
248
+
249
+ # Checks equality by comparing each attribute.
250
+ # @param [Object] Object to be compared
251
+ def ==(o)
252
+ return true if self.equal?(o)
253
+ self.class == o.class &&
254
+ links == o.links &&
255
+ partial_name == o.partial_name &&
256
+ rect == o.rect &&
257
+ value == o.value &&
258
+ page_index == o.page_index &&
259
+ height == o.height &&
260
+ width == o.width &&
261
+ z_index == o.z_index &&
262
+ is_group == o.is_group &&
263
+ parent == o.parent &&
264
+ is_shared_field == o.is_shared_field &&
265
+ flags == o.flags &&
266
+ color == o.color &&
267
+ contents == o.contents &&
268
+ margin == o.margin &&
269
+ highlighting == o.highlighting &&
270
+ horizontal_alignment == o.horizontal_alignment &&
271
+ vertical_alignment == o.vertical_alignment &&
272
+ signature == o.signature
273
+ end
274
+
275
+ # @see the `==` method
276
+ # @param [Object] Object to be compared
277
+ def eql?(o)
278
+ self == o
279
+ end
280
+
281
+ # Calculates hash code according to all attributes.
282
+ # @return [Fixnum] Hash code
283
+ def hash
284
+ [links, partial_name, rect, value, page_index, height, width, z_index, is_group, parent, is_shared_field, flags, color, contents, margin, highlighting, horizontal_alignment, vertical_alignment, signature].hash
285
+ end
286
+
287
+ # Builds the object from hash
288
+ # @param [Hash] attributes Model attributes in the form of hash
289
+ # @return [Object] Returns the model itself
290
+ def build_from_hash(attributes)
291
+ return nil unless attributes.is_a?(Hash)
292
+ self.class.swagger_types.each_pair do |key, type|
293
+ if type =~ /\AArray<(.*)>/i
294
+ # check to ensure the input is an array given that the the attribute
295
+ # is documented as an array but the input is not
296
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
297
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
298
+ end
299
+ elsif !attributes[self.class.attribute_map[key]].nil?
300
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
301
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
302
+ end
303
+
304
+ self
305
+ end
306
+
307
+ # Deserializes the data based on type
308
+ # @param string type Data type
309
+ # @param string value Value to be deserialized
310
+ # @return [Object] Deserialized data
311
+ def _deserialize(type, value)
312
+ case type.to_sym
313
+ when :DateTime
314
+ DateTime.parse(value)
315
+ when :Date
316
+ Date.parse(value)
317
+ when :String
318
+ value.to_s
319
+ when :Integer
320
+ value.to_i
321
+ when :Float
322
+ value.to_f
323
+ when :BOOLEAN
324
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
325
+ true
326
+ else
327
+ false
328
+ end
329
+ when :Object
330
+ # generic object (usually a Hash), return directly
331
+ value
332
+ when /\AArray<(?<inner_type>.+)>\z/
333
+ inner_type = Regexp.last_match[:inner_type]
334
+ value.map { |v| _deserialize(inner_type, v) }
335
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
336
+ k_type = Regexp.last_match[:k_type]
337
+ v_type = Regexp.last_match[:v_type]
338
+ {}.tap do |hash|
339
+ value.each do |k, v|
340
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
341
+ end
342
+ end
343
+ else # model
344
+ temp_model = AsposePdfCloud.const_get(type).new
345
+ temp_model.build_from_hash(value)
346
+ end
347
+ end
348
+
349
+ # Returns the string representation of the object
350
+ # @return [String] String presentation of the object
351
+ def to_s
352
+ to_hash.to_s
353
+ end
354
+
355
+ # to_body is an alias to to_hash (backward compatibility)
356
+ # @return [Hash] Returns the object in the form of hash
357
+ def to_body
358
+ to_hash
359
+ end
360
+
361
+ # Returns the object in the form of hash
362
+ # @return [Hash] Returns the object in the form of hash
363
+ def to_hash
364
+ hash = {}
365
+ self.class.attribute_map.each_pair do |attr, param|
366
+ value = self.send(attr)
367
+ next if value.nil?
368
+ hash[param] = _to_hash(value)
369
+ end
370
+ hash
371
+ end
372
+
373
+ # Outputs non-array value in the form of hash
374
+ # For object, use to_hash. Otherwise, just return the value
375
+ # @param [Object] value Any valid value
376
+ # @return [Hash] Returns the value in the form of hash
377
+ def _to_hash(value)
378
+ if value.is_a?(Array)
379
+ value.compact.map{ |v| _to_hash(v) }
380
+ elsif value.is_a?(Hash)
381
+ {}.tap do |hash|
382
+ value.each { |k, v| hash[k] = _to_hash(v) }
383
+ end
384
+ elsif value.respond_to? :to_hash
385
+ value.to_hash
386
+ else
387
+ value
388
+ end
389
+ end
390
+
391
+ end
392
+
393
+ end