groupdocs_parser_cloud 19.11

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 (64) hide show
  1. checksums.yaml +7 -0
  2. data/lib/groupdocs_parser_cloud.rb +91 -0
  3. data/lib/groupdocs_parser_cloud/api/file_api.rb +729 -0
  4. data/lib/groupdocs_parser_cloud/api/folder_api.rb +694 -0
  5. data/lib/groupdocs_parser_cloud/api/info_api.rb +363 -0
  6. data/lib/groupdocs_parser_cloud/api/parse_api.rb +411 -0
  7. data/lib/groupdocs_parser_cloud/api/storage_api.rb +541 -0
  8. data/lib/groupdocs_parser_cloud/api/template_api.rb +410 -0
  9. data/lib/groupdocs_parser_cloud/api_client.rb +380 -0
  10. data/lib/groupdocs_parser_cloud/api_error.rb +64 -0
  11. data/lib/groupdocs_parser_cloud/configuration.rb +95 -0
  12. data/lib/groupdocs_parser_cloud/models/container_item.rb +246 -0
  13. data/lib/groupdocs_parser_cloud/models/container_item_info.rb +224 -0
  14. data/lib/groupdocs_parser_cloud/models/container_options.rb +224 -0
  15. data/lib/groupdocs_parser_cloud/models/container_result.rb +216 -0
  16. data/lib/groupdocs_parser_cloud/models/coordinates.rb +264 -0
  17. data/lib/groupdocs_parser_cloud/models/create_template_options.rb +234 -0
  18. data/lib/groupdocs_parser_cloud/models/detector_parameters.rb +266 -0
  19. data/lib/groupdocs_parser_cloud/models/disc_usage.rb +234 -0
  20. data/lib/groupdocs_parser_cloud/models/error.rb +244 -0
  21. data/lib/groupdocs_parser_cloud/models/error_details.rb +229 -0
  22. data/lib/groupdocs_parser_cloud/models/field.rb +234 -0
  23. data/lib/groupdocs_parser_cloud/models/field_data.rb +249 -0
  24. data/lib/groupdocs_parser_cloud/models/field_position.rb +344 -0
  25. data/lib/groupdocs_parser_cloud/models/file_info.rb +234 -0
  26. data/lib/groupdocs_parser_cloud/models/file_type.rb +224 -0
  27. data/lib/groupdocs_parser_cloud/models/file_version.rb +289 -0
  28. data/lib/groupdocs_parser_cloud/models/file_versions.rb +216 -0
  29. data/lib/groupdocs_parser_cloud/models/files_list.rb +216 -0
  30. data/lib/groupdocs_parser_cloud/models/files_upload_result.rb +228 -0
  31. data/lib/groupdocs_parser_cloud/models/format.rb +224 -0
  32. data/lib/groupdocs_parser_cloud/models/formats_result.rb +216 -0
  33. data/lib/groupdocs_parser_cloud/models/formatted_text_options.rb +214 -0
  34. data/lib/groupdocs_parser_cloud/models/image.rb +224 -0
  35. data/lib/groupdocs_parser_cloud/models/image_page.rb +231 -0
  36. data/lib/groupdocs_parser_cloud/models/images_options.rb +254 -0
  37. data/lib/groupdocs_parser_cloud/models/images_result.rb +228 -0
  38. data/lib/groupdocs_parser_cloud/models/info_options.rb +224 -0
  39. data/lib/groupdocs_parser_cloud/models/info_result.rb +244 -0
  40. data/lib/groupdocs_parser_cloud/models/object_exist.rb +234 -0
  41. data/lib/groupdocs_parser_cloud/models/page.rb +229 -0
  42. data/lib/groupdocs_parser_cloud/models/page_area.rb +244 -0
  43. data/lib/groupdocs_parser_cloud/models/page_table_area.rb +246 -0
  44. data/lib/groupdocs_parser_cloud/models/page_table_area_cell.rb +274 -0
  45. data/lib/groupdocs_parser_cloud/models/page_text_area.rb +251 -0
  46. data/lib/groupdocs_parser_cloud/models/parse_options.rb +244 -0
  47. data/lib/groupdocs_parser_cloud/models/parse_result.rb +231 -0
  48. data/lib/groupdocs_parser_cloud/models/parser_options.rb +224 -0
  49. data/lib/groupdocs_parser_cloud/models/point.rb +234 -0
  50. data/lib/groupdocs_parser_cloud/models/rectangle.rb +234 -0
  51. data/lib/groupdocs_parser_cloud/models/size.rb +234 -0
  52. data/lib/groupdocs_parser_cloud/models/storage_exist.rb +219 -0
  53. data/lib/groupdocs_parser_cloud/models/storage_file.rb +264 -0
  54. data/lib/groupdocs_parser_cloud/models/table.rb +244 -0
  55. data/lib/groupdocs_parser_cloud/models/table_layout.rb +228 -0
  56. data/lib/groupdocs_parser_cloud/models/template.rb +228 -0
  57. data/lib/groupdocs_parser_cloud/models/template_options.rb +224 -0
  58. data/lib/groupdocs_parser_cloud/models/template_result.rb +224 -0
  59. data/lib/groupdocs_parser_cloud/models/text_options.rb +254 -0
  60. data/lib/groupdocs_parser_cloud/models/text_page.rb +229 -0
  61. data/lib/groupdocs_parser_cloud/models/text_result.rb +226 -0
  62. data/lib/groupdocs_parser_cloud/models/text_style.rb +269 -0
  63. data/lib/groupdocs_parser_cloud/version.rb +29 -0
  64. metadata +174 -0
@@ -0,0 +1,249 @@
1
+ #
2
+ # --------------------------------------------------------------------------------------------------------------------
3
+ # <copyright company="Aspose Pty Ltd" file="field_data.rb">
4
+ # Copyright (c) 2003-2019 Aspose Pty Ltd
5
+ # </copyright>
6
+ # <summary>
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ # </summary>
25
+ # --------------------------------------------------------------------------------------------------------------------
26
+ #
27
+
28
+ require 'date'
29
+
30
+ module GroupDocsParserCloud
31
+ # Class for document field data.
32
+ class FieldData
33
+
34
+ # Gets or sets the field name.
35
+ attr_accessor :name
36
+
37
+ # Gets or sets the index of the page.
38
+ attr_accessor :page_index
39
+
40
+ # Gets or sets the value of the field.
41
+ attr_accessor :page_area
42
+
43
+ # Gets or sets the linked data field.
44
+ attr_accessor :linked_field
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'name' => :'Name',
50
+ :'page_index' => :'PageIndex',
51
+ :'page_area' => :'PageArea',
52
+ :'linked_field' => :'LinkedField'
53
+ }
54
+ end
55
+
56
+ # Attribute type mapping.
57
+ def self.swagger_types
58
+ {
59
+ :'name' => :'String',
60
+ :'page_index' => :'Integer',
61
+ :'page_area' => :'PageArea',
62
+ :'linked_field' => :'FieldData'
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.key?(:'Name')
75
+ self.name = attributes[:'Name']
76
+ end
77
+
78
+ if attributes.key?(:'PageIndex')
79
+ self.page_index = attributes[:'PageIndex']
80
+ end
81
+
82
+ if attributes.key?(:'PageArea')
83
+ self.page_area = attributes[:'PageArea']
84
+ end
85
+
86
+ if attributes.key?(:'LinkedField')
87
+ self.linked_field = attributes[:'LinkedField']
88
+ end
89
+
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properies with the reasons
94
+ def list_invalid_properties
95
+ invalid_properties = []
96
+ if @page_index.nil?
97
+ invalid_properties.push("invalid value for 'page_index', page_index cannot be nil.")
98
+ end
99
+
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 false if @page_index.nil?
107
+ return true
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(other)
113
+ return true if self.equal?(other)
114
+ self.class == other.class &&
115
+ name == other.name &&
116
+ page_index == other.page_index &&
117
+ page_area == other.page_area &&
118
+ linked_field == other.linked_field
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(other)
124
+ self == other
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Fixnum] Hash code
129
+ def hash
130
+ [name, page_index, page_area, linked_field].hash
131
+ end
132
+
133
+ # Downcases first letter.
134
+ # @return downcased string
135
+ def uncap(str)
136
+ str[0, 1].downcase + str[1..-1]
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def build_from_hash(attributes)
143
+ return nil unless attributes.is_a?(Hash)
144
+ self.class.swagger_types.each_pair do |key, type|
145
+ pname = uncap(self.class.attribute_map[key]).intern
146
+ value = attributes[pname]
147
+ if type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the the attribute
149
+ # is documented as an array but the input is not
150
+ if value.is_a?(Array)
151
+ self.send("#{key}=", value.map { |v| _deserialize($1, v) })
152
+ end
153
+ elsif !value.nil?
154
+ self.send("#{key}=", _deserialize(type, value))
155
+ end
156
+ # or else data not found in attributes(hash), not an issue as the data can be optional
157
+ end
158
+
159
+ self
160
+ end
161
+
162
+ # Deserializes the data based on type
163
+ # @param string type Data type
164
+ # @param string value Value to be deserialized
165
+ # @return [Object] Deserialized data
166
+ def _deserialize(type, value)
167
+ case type.to_sym
168
+ when :DateTime
169
+ Date.parse value
170
+ when :Date
171
+ Date.parse value
172
+ when :String
173
+ value.to_s
174
+ when :Integer
175
+ value.to_i
176
+ when :Float
177
+ value.to_f
178
+ when :BOOLEAN
179
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
180
+ true
181
+ else
182
+ false
183
+ end
184
+ when :Object
185
+ # generic object (usually a Hash), return directly
186
+ value
187
+ when /\AArray<(?<inner_type>.+)>\z/
188
+ inner_type = Regexp.last_match[:inner_type]
189
+ value.map { |v| _deserialize(inner_type, v) }
190
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
191
+ k_type = Regexp.last_match[:k_type]
192
+ v_type = Regexp.last_match[:v_type]
193
+ {}.tap do |hash|
194
+ value.each do |k, v|
195
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
196
+ end
197
+ end
198
+ else
199
+ # model
200
+ temp_model = GroupDocsParserCloud.const_get(type).new
201
+ temp_model.build_from_hash(value)
202
+ end
203
+ end
204
+
205
+ # Returns the string representation of the object
206
+ # @return [String] String presentation of the object
207
+ def to_s
208
+ to_hash.to_s
209
+ end
210
+
211
+ # to_body is an alias to to_hash (backward compatibility)
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_body
214
+ to_hash
215
+ end
216
+
217
+ # Returns the object in the form of hash
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_hash
220
+ hash = {}
221
+ self.class.attribute_map.each_pair do |attr, param|
222
+ value = self.send(attr)
223
+ next if value.nil?
224
+ hash[param] = _to_hash(value)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Outputs non-array value in the form of hash
230
+ # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
233
+ def _to_hash(value)
234
+ if value.is_a?(Array)
235
+ value.compact.map { |v| _to_hash(v) }
236
+ elsif value.is_a?(Hash)
237
+ {}.tap do |hash|
238
+ value.each { |k, v| hash[k] = _to_hash(v) }
239
+ end
240
+ elsif value.respond_to? :to_hash
241
+ value.to_hash
242
+ else
243
+ value
244
+ end
245
+ end
246
+
247
+ end
248
+
249
+ end
@@ -0,0 +1,344 @@
1
+ #
2
+ # --------------------------------------------------------------------------------------------------------------------
3
+ # <copyright company="Aspose Pty Ltd" file="field_position.rb">
4
+ # Copyright (c) 2003-2019 Aspose Pty Ltd
5
+ # </copyright>
6
+ # <summary>
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+ # </summary>
25
+ # --------------------------------------------------------------------------------------------------------------------
26
+ #
27
+
28
+ require 'date'
29
+
30
+ module GroupDocsParserCloud
31
+ # Field position class.
32
+ class FieldPosition
33
+
34
+ # Provides a template field position.
35
+ attr_accessor :field_position_type
36
+
37
+ # Rectangular area on the page that bounds the field value.
38
+ attr_accessor :rectangle
39
+
40
+ # Gets or sets the regular expression.
41
+ attr_accessor :regex
42
+
43
+ # Gets or sets the value that indicates whether a text case isn't ignored.
44
+ attr_accessor :match_case
45
+
46
+ # Gets or sets the name of the linked field.
47
+ attr_accessor :linked_field_name
48
+
49
+ # Gets or sets the value that indicates whether a field is searched by the left from the linked field.
50
+ attr_accessor :is_left_linked
51
+
52
+ # Gets or sets a value indicating whether this instance is right linked.
53
+ attr_accessor :is_right_linked
54
+
55
+ # Gets or sets a value indicating whether this instance is top linked.
56
+ attr_accessor :is_top_linked
57
+
58
+ # Gets or sets a value indicating whether this instance is bottom linked.
59
+ attr_accessor :is_bottom_linked
60
+
61
+ # Gets or sets the size of the area where a field is searched.
62
+ attr_accessor :search_area
63
+
64
+ # Gets or sets Gets the value that indicates whether SearchArea is scaled by the linked field size.
65
+ attr_accessor :auto_scale
66
+
67
+ # Attribute mapping from ruby-style variable name to JSON key.
68
+ def self.attribute_map
69
+ {
70
+ :'field_position_type' => :'FieldPositionType',
71
+ :'rectangle' => :'Rectangle',
72
+ :'regex' => :'Regex',
73
+ :'match_case' => :'MatchCase',
74
+ :'linked_field_name' => :'LinkedFieldName',
75
+ :'is_left_linked' => :'IsLeftLinked',
76
+ :'is_right_linked' => :'IsRightLinked',
77
+ :'is_top_linked' => :'IsTopLinked',
78
+ :'is_bottom_linked' => :'IsBottomLinked',
79
+ :'search_area' => :'SearchArea',
80
+ :'auto_scale' => :'AutoScale'
81
+ }
82
+ end
83
+
84
+ # Attribute type mapping.
85
+ def self.swagger_types
86
+ {
87
+ :'field_position_type' => :'String',
88
+ :'rectangle' => :'Rectangle',
89
+ :'regex' => :'String',
90
+ :'match_case' => :'BOOLEAN',
91
+ :'linked_field_name' => :'String',
92
+ :'is_left_linked' => :'BOOLEAN',
93
+ :'is_right_linked' => :'BOOLEAN',
94
+ :'is_top_linked' => :'BOOLEAN',
95
+ :'is_bottom_linked' => :'BOOLEAN',
96
+ :'search_area' => :'Size',
97
+ :'auto_scale' => :'BOOLEAN'
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.key?(:'FieldPositionType')
110
+ self.field_position_type = attributes[:'FieldPositionType']
111
+ end
112
+
113
+ if attributes.key?(:'Rectangle')
114
+ self.rectangle = attributes[:'Rectangle']
115
+ end
116
+
117
+ if attributes.key?(:'Regex')
118
+ self.regex = attributes[:'Regex']
119
+ end
120
+
121
+ if attributes.key?(:'MatchCase')
122
+ self.match_case = attributes[:'MatchCase']
123
+ end
124
+
125
+ if attributes.key?(:'LinkedFieldName')
126
+ self.linked_field_name = attributes[:'LinkedFieldName']
127
+ end
128
+
129
+ if attributes.key?(:'IsLeftLinked')
130
+ self.is_left_linked = attributes[:'IsLeftLinked']
131
+ end
132
+
133
+ if attributes.key?(:'IsRightLinked')
134
+ self.is_right_linked = attributes[:'IsRightLinked']
135
+ end
136
+
137
+ if attributes.key?(:'IsTopLinked')
138
+ self.is_top_linked = attributes[:'IsTopLinked']
139
+ end
140
+
141
+ if attributes.key?(:'IsBottomLinked')
142
+ self.is_bottom_linked = attributes[:'IsBottomLinked']
143
+ end
144
+
145
+ if attributes.key?(:'SearchArea')
146
+ self.search_area = attributes[:'SearchArea']
147
+ end
148
+
149
+ if attributes.key?(:'AutoScale')
150
+ self.auto_scale = attributes[:'AutoScale']
151
+ end
152
+
153
+ end
154
+
155
+ # Show invalid properties with the reasons. Usually used together with valid?
156
+ # @return Array for valid properies with the reasons
157
+ def list_invalid_properties
158
+ invalid_properties = []
159
+ if @match_case.nil?
160
+ invalid_properties.push("invalid value for 'match_case', match_case cannot be nil.")
161
+ end
162
+
163
+ if @is_left_linked.nil?
164
+ invalid_properties.push("invalid value for 'is_left_linked', is_left_linked cannot be nil.")
165
+ end
166
+
167
+ if @is_right_linked.nil?
168
+ invalid_properties.push("invalid value for 'is_right_linked', is_right_linked cannot be nil.")
169
+ end
170
+
171
+ if @is_top_linked.nil?
172
+ invalid_properties.push("invalid value for 'is_top_linked', is_top_linked cannot be nil.")
173
+ end
174
+
175
+ if @is_bottom_linked.nil?
176
+ invalid_properties.push("invalid value for 'is_bottom_linked', is_bottom_linked cannot be nil.")
177
+ end
178
+
179
+ if @auto_scale.nil?
180
+ invalid_properties.push("invalid value for 'auto_scale', auto_scale cannot be nil.")
181
+ end
182
+
183
+ return invalid_properties
184
+ end
185
+
186
+ # Check to see if the all the properties in the model are valid
187
+ # @return true if the model is valid
188
+ def valid?
189
+ return false if @match_case.nil?
190
+ return false if @is_left_linked.nil?
191
+ return false if @is_right_linked.nil?
192
+ return false if @is_top_linked.nil?
193
+ return false if @is_bottom_linked.nil?
194
+ return false if @auto_scale.nil?
195
+ return true
196
+ end
197
+
198
+ # Checks equality by comparing each attribute.
199
+ # @param [Object] Object to be compared
200
+ def ==(other)
201
+ return true if self.equal?(other)
202
+ self.class == other.class &&
203
+ field_position_type == other.field_position_type &&
204
+ rectangle == other.rectangle &&
205
+ regex == other.regex &&
206
+ match_case == other.match_case &&
207
+ linked_field_name == other.linked_field_name &&
208
+ is_left_linked == other.is_left_linked &&
209
+ is_right_linked == other.is_right_linked &&
210
+ is_top_linked == other.is_top_linked &&
211
+ is_bottom_linked == other.is_bottom_linked &&
212
+ search_area == other.search_area &&
213
+ auto_scale == other.auto_scale
214
+ end
215
+
216
+ # @see the `==` method
217
+ # @param [Object] Object to be compared
218
+ def eql?(other)
219
+ self == other
220
+ end
221
+
222
+ # Calculates hash code according to all attributes.
223
+ # @return [Fixnum] Hash code
224
+ def hash
225
+ [field_position_type, rectangle, regex, match_case, linked_field_name, is_left_linked, is_right_linked, is_top_linked, is_bottom_linked, search_area, auto_scale].hash
226
+ end
227
+
228
+ # Downcases first letter.
229
+ # @return downcased string
230
+ def uncap(str)
231
+ str[0, 1].downcase + str[1..-1]
232
+ end
233
+
234
+ # Builds the object from hash
235
+ # @param [Hash] attributes Model attributes in the form of hash
236
+ # @return [Object] Returns the model itself
237
+ def build_from_hash(attributes)
238
+ return nil unless attributes.is_a?(Hash)
239
+ self.class.swagger_types.each_pair do |key, type|
240
+ pname = uncap(self.class.attribute_map[key]).intern
241
+ value = attributes[pname]
242
+ if type =~ /\AArray<(.*)>/i
243
+ # check to ensure the input is an array given that the the attribute
244
+ # is documented as an array but the input is not
245
+ if value.is_a?(Array)
246
+ self.send("#{key}=", value.map { |v| _deserialize($1, v) })
247
+ end
248
+ elsif !value.nil?
249
+ self.send("#{key}=", _deserialize(type, value))
250
+ end
251
+ # or else data not found in attributes(hash), not an issue as the data can be optional
252
+ end
253
+
254
+ self
255
+ end
256
+
257
+ # Deserializes the data based on type
258
+ # @param string type Data type
259
+ # @param string value Value to be deserialized
260
+ # @return [Object] Deserialized data
261
+ def _deserialize(type, value)
262
+ case type.to_sym
263
+ when :DateTime
264
+ Date.parse value
265
+ when :Date
266
+ Date.parse value
267
+ when :String
268
+ value.to_s
269
+ when :Integer
270
+ value.to_i
271
+ when :Float
272
+ value.to_f
273
+ when :BOOLEAN
274
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
275
+ true
276
+ else
277
+ false
278
+ end
279
+ when :Object
280
+ # generic object (usually a Hash), return directly
281
+ value
282
+ when /\AArray<(?<inner_type>.+)>\z/
283
+ inner_type = Regexp.last_match[:inner_type]
284
+ value.map { |v| _deserialize(inner_type, v) }
285
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
286
+ k_type = Regexp.last_match[:k_type]
287
+ v_type = Regexp.last_match[:v_type]
288
+ {}.tap do |hash|
289
+ value.each do |k, v|
290
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
291
+ end
292
+ end
293
+ else
294
+ # model
295
+ temp_model = GroupDocsParserCloud.const_get(type).new
296
+ temp_model.build_from_hash(value)
297
+ end
298
+ end
299
+
300
+ # Returns the string representation of the object
301
+ # @return [String] String presentation of the object
302
+ def to_s
303
+ to_hash.to_s
304
+ end
305
+
306
+ # to_body is an alias to to_hash (backward compatibility)
307
+ # @return [Hash] Returns the object in the form of hash
308
+ def to_body
309
+ to_hash
310
+ end
311
+
312
+ # Returns the object in the form of hash
313
+ # @return [Hash] Returns the object in the form of hash
314
+ def to_hash
315
+ hash = {}
316
+ self.class.attribute_map.each_pair do |attr, param|
317
+ value = self.send(attr)
318
+ next if value.nil?
319
+ hash[param] = _to_hash(value)
320
+ end
321
+ hash
322
+ end
323
+
324
+ # Outputs non-array value in the form of hash
325
+ # For object, use to_hash. Otherwise, just return the value
326
+ # @param [Object] value Any valid value
327
+ # @return [Hash] Returns the value in the form of hash
328
+ def _to_hash(value)
329
+ if value.is_a?(Array)
330
+ value.compact.map { |v| _to_hash(v) }
331
+ elsif value.is_a?(Hash)
332
+ {}.tap do |hash|
333
+ value.each { |k, v| hash[k] = _to_hash(v) }
334
+ end
335
+ elsif value.respond_to? :to_hash
336
+ value.to_hash
337
+ else
338
+ value
339
+ end
340
+ end
341
+
342
+ end
343
+
344
+ end