aspose_pdf_cloud 19.2.0 → 19.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -5
  3. data/docs/CellRecognized.md +10 -0
  4. data/docs/ImageStamp.md +25 -0
  5. data/docs/PdfApi.md +419 -3
  6. data/docs/PdfPageStamp.md +24 -0
  7. data/docs/Position.md +10 -0
  8. data/docs/RowRecognized.md +10 -0
  9. data/docs/StampBase.md +22 -0
  10. data/docs/StampInfo.md +16 -0
  11. data/docs/StampsInfo.md +10 -0
  12. data/docs/StampsInfoResponse.md +11 -0
  13. data/docs/TableRecognized.md +13 -0
  14. data/docs/TableRecognizedResponse.md +11 -0
  15. data/docs/TablesRecognized.md +10 -0
  16. data/docs/TablesRecognizedResponse.md +11 -0
  17. data/docs/TextRect.md +6 -1
  18. data/docs/TextStamp.md +25 -0
  19. data/lib/aspose_pdf_cloud.rb +14 -0
  20. data/lib/aspose_pdf_cloud/api/pdf_api.rb +1450 -204
  21. data/lib/aspose_pdf_cloud/models/cell_recognized.rb +211 -0
  22. data/lib/aspose_pdf_cloud/models/image_stamp.rb +363 -0
  23. data/lib/aspose_pdf_cloud/models/pdf_page_stamp.rb +353 -0
  24. data/lib/aspose_pdf_cloud/models/position.rb +221 -0
  25. data/lib/aspose_pdf_cloud/models/row_recognized.rb +213 -0
  26. data/lib/aspose_pdf_cloud/models/stamp_base.rb +333 -0
  27. data/lib/aspose_pdf_cloud/models/stamp_info.rb +273 -0
  28. data/lib/aspose_pdf_cloud/models/stamps_info.rb +215 -0
  29. data/lib/aspose_pdf_cloud/models/stamps_info_response.rb +226 -0
  30. data/lib/aspose_pdf_cloud/models/table_recognized.rb +245 -0
  31. data/lib/aspose_pdf_cloud/models/table_recognized_response.rb +226 -0
  32. data/lib/aspose_pdf_cloud/models/tables_recognized.rb +215 -0
  33. data/lib/aspose_pdf_cloud/models/tables_recognized_response.rb +226 -0
  34. data/lib/aspose_pdf_cloud/models/text_rect.rb +54 -9
  35. data/lib/aspose_pdf_cloud/models/text_stamp.rb +363 -0
  36. data/lib/aspose_pdf_cloud/version.rb +1 -1
  37. data/test/pdf_tests.rb +260 -3
  38. data/test_data/PageNumberStamp.pdf +0 -0
  39. data/test_data/PdfWithTable.pdf +0 -0
  40. metadata +32 -2
@@ -0,0 +1,211 @@
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
+
27
+ class CellRecognized
28
+ # Gets collection of objects that describes text containing in the cell
29
+ attr_accessor :text_rects
30
+
31
+ # Gets rectangle that describes position of the cell on page
32
+ attr_accessor :rectangle
33
+
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'text_rects' => :'TextRects',
39
+ :'rectangle' => :'Rectangle'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.swagger_types
45
+ {
46
+ :'text_rects' => :'TextRects',
47
+ :'rectangle' => :'Rectangle'
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?(:'TextRects')
60
+ self.text_rects = attributes[:'TextRects']
61
+ end
62
+
63
+ if attributes.has_key?(:'Rectangle')
64
+ self.rectangle = attributes[:'Rectangle']
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
+ return invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ return true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ text_rects == o.text_rects &&
88
+ rectangle == o.rectangle
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Fixnum] Hash code
99
+ def hash
100
+ [text_rects, rectangle].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def build_from_hash(attributes)
107
+ return nil unless attributes.is_a?(Hash)
108
+ self.class.swagger_types.each_pair do |key, type|
109
+ if type =~ /\AArray<(.*)>/i
110
+ # check to ensure the input is an array given that the the attribute
111
+ # is documented as an array but the input is not
112
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
113
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
114
+ end
115
+ elsif !attributes[self.class.attribute_map[key]].nil?
116
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
117
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
118
+ end
119
+
120
+ self
121
+ end
122
+
123
+ # Deserializes the data based on type
124
+ # @param string type Data type
125
+ # @param string value Value to be deserialized
126
+ # @return [Object] Deserialized data
127
+ def _deserialize(type, value)
128
+ case type.to_sym
129
+ when :DateTime
130
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
131
+ Time.strptime(value, format).utc.to_datetime
132
+ when :Date
133
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
134
+ Time.strptime(value, format).utc.to_datetime.to_date
135
+ when :String
136
+ value.to_s
137
+ when :Integer
138
+ value.to_i
139
+ when :Float
140
+ value.to_f
141
+ when :BOOLEAN
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
+ true
144
+ else
145
+ false
146
+ end
147
+ when :Object
148
+ # generic object (usually a Hash), return directly
149
+ value
150
+ when /\AArray<(?<inner_type>.+)>\z/
151
+ inner_type = Regexp.last_match[:inner_type]
152
+ value.map { |v| _deserialize(inner_type, v) }
153
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
+ k_type = Regexp.last_match[:k_type]
155
+ v_type = Regexp.last_match[:v_type]
156
+ {}.tap do |hash|
157
+ value.each do |k, v|
158
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
+ end
160
+ end
161
+ else # model
162
+ temp_model = AsposePdfCloud.const_get(type).new
163
+ temp_model.build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ next if value.nil?
186
+ hash[param] = _to_hash(value)
187
+ end
188
+ hash
189
+ end
190
+
191
+ # Outputs non-array value in the form of hash
192
+ # For object, use to_hash. Otherwise, just return the value
193
+ # @param [Object] value Any valid value
194
+ # @return [Hash] Returns the value in the form of hash
195
+ def _to_hash(value)
196
+ if value.is_a?(Array)
197
+ value.compact.map{ |v| _to_hash(v) }
198
+ elsif value.is_a?(Hash)
199
+ {}.tap do |hash|
200
+ value.each { |k, v| hash[k] = _to_hash(v) }
201
+ end
202
+ elsif value.respond_to? :to_hash
203
+ value.to_hash
204
+ else
205
+ value
206
+ end
207
+ end
208
+
209
+ end
210
+
211
+ end
@@ -0,0 +1,363 @@
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 Pdf stamps.
27
+ class ImageStamp
28
+ # Link to the document.
29
+ attr_accessor :links
30
+
31
+ # Sets or gets a bool value that indicates the content is stamped as background. If the value is true, the stamp content is layed at the bottom. By defalt, the value is false, the stamp content is layed at the top.
32
+ attr_accessor :background
33
+
34
+ # Gets or sets bottom margin of stamp.
35
+ attr_accessor :bottom_margin
36
+
37
+ # Gets or sets Horizontal alignment of stamp on the page.
38
+ attr_accessor :horizontal_alignment
39
+
40
+ # Gets or sets left margin of stamp.
41
+ attr_accessor :left_margin
42
+
43
+ # Gets or sets a value to indicate the stamp opacity. The value is from 0.0 to 1.0. By default the value is 1.0.
44
+ attr_accessor :opacity
45
+
46
+ # Gets or sets right margin of stamp.
47
+ attr_accessor :right_margin
48
+
49
+ # Sets or gets the rotation of stamp content according values. Note. This property is for set angles which are multiples of 90 degrees (0, 90, 180, 270 degrees). To set arbitrary angle use RotateAngle property. If angle set by ArbitraryAngle is not multiple of 90 then Rotate property returns Rotation.None.
50
+ attr_accessor :rotate
51
+
52
+ # Gets or sets rotate angle of stamp in degrees. This property allows to set arbitrary rotate angle.
53
+ attr_accessor :rotate_angle
54
+
55
+ # Gets or sets top margin of stamp.
56
+ attr_accessor :top_margin
57
+
58
+ # Gets or sets vertical alignment of stamp on page.
59
+ attr_accessor :vertical_alignment
60
+
61
+ # Horizontal stamp coordinate, starting from the left.
62
+ attr_accessor :x_indent
63
+
64
+ # Vertical stamp coordinate, starting from the bottom.
65
+ attr_accessor :y_indent
66
+
67
+ # Zooming factor of the stamp. Allows to scale stamp.
68
+ attr_accessor :zoom
69
+
70
+ # Gets or sets the file name.
71
+ attr_accessor :file_name
72
+
73
+ # Gets or sets image width. Setting this property allos to scal image horizontally.
74
+ attr_accessor :width
75
+
76
+ # Gets or sets image height. Setting this image allows to scale image vertically.
77
+ attr_accessor :height
78
+
79
+
80
+ # Attribute mapping from ruby-style variable name to JSON key.
81
+ def self.attribute_map
82
+ {
83
+ :'links' => :'Links',
84
+ :'background' => :'Background',
85
+ :'bottom_margin' => :'BottomMargin',
86
+ :'horizontal_alignment' => :'HorizontalAlignment',
87
+ :'left_margin' => :'LeftMargin',
88
+ :'opacity' => :'Opacity',
89
+ :'right_margin' => :'RightMargin',
90
+ :'rotate' => :'Rotate',
91
+ :'rotate_angle' => :'RotateAngle',
92
+ :'top_margin' => :'TopMargin',
93
+ :'vertical_alignment' => :'VerticalAlignment',
94
+ :'x_indent' => :'XIndent',
95
+ :'y_indent' => :'YIndent',
96
+ :'zoom' => :'Zoom',
97
+ :'file_name' => :'FileName',
98
+ :'width' => :'Width',
99
+ :'height' => :'Height'
100
+ }
101
+ end
102
+
103
+ # Attribute type mapping.
104
+ def self.swagger_types
105
+ {
106
+ :'links' => :'Array<Link>',
107
+ :'background' => :'BOOLEAN',
108
+ :'bottom_margin' => :'Float',
109
+ :'horizontal_alignment' => :'HorizontalAlignment',
110
+ :'left_margin' => :'Float',
111
+ :'opacity' => :'Float',
112
+ :'right_margin' => :'Float',
113
+ :'rotate' => :'Rotation',
114
+ :'rotate_angle' => :'Float',
115
+ :'top_margin' => :'Float',
116
+ :'vertical_alignment' => :'VerticalAlignment',
117
+ :'x_indent' => :'Float',
118
+ :'y_indent' => :'Float',
119
+ :'zoom' => :'Float',
120
+ :'file_name' => :'String',
121
+ :'width' => :'Float',
122
+ :'height' => :'Float'
123
+ }
124
+ end
125
+
126
+ # Initializes the object
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ def initialize(attributes = {})
129
+ return unless attributes.is_a?(Hash)
130
+
131
+ # convert string to symbol for hash key
132
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
133
+
134
+ if attributes.has_key?(:'Links')
135
+ if (value = attributes[:'Links']).is_a?(Array)
136
+ self.links = value
137
+ end
138
+ end
139
+
140
+ if attributes.has_key?(:'Background')
141
+ self.background = attributes[:'Background']
142
+ end
143
+
144
+ if attributes.has_key?(:'BottomMargin')
145
+ self.bottom_margin = attributes[:'BottomMargin']
146
+ end
147
+
148
+ if attributes.has_key?(:'HorizontalAlignment')
149
+ self.horizontal_alignment = attributes[:'HorizontalAlignment']
150
+ end
151
+
152
+ if attributes.has_key?(:'LeftMargin')
153
+ self.left_margin = attributes[:'LeftMargin']
154
+ end
155
+
156
+ if attributes.has_key?(:'Opacity')
157
+ self.opacity = attributes[:'Opacity']
158
+ end
159
+
160
+ if attributes.has_key?(:'RightMargin')
161
+ self.right_margin = attributes[:'RightMargin']
162
+ end
163
+
164
+ if attributes.has_key?(:'Rotate')
165
+ self.rotate = attributes[:'Rotate']
166
+ end
167
+
168
+ if attributes.has_key?(:'RotateAngle')
169
+ self.rotate_angle = attributes[:'RotateAngle']
170
+ end
171
+
172
+ if attributes.has_key?(:'TopMargin')
173
+ self.top_margin = attributes[:'TopMargin']
174
+ end
175
+
176
+ if attributes.has_key?(:'VerticalAlignment')
177
+ self.vertical_alignment = attributes[:'VerticalAlignment']
178
+ end
179
+
180
+ if attributes.has_key?(:'XIndent')
181
+ self.x_indent = attributes[:'XIndent']
182
+ end
183
+
184
+ if attributes.has_key?(:'YIndent')
185
+ self.y_indent = attributes[:'YIndent']
186
+ end
187
+
188
+ if attributes.has_key?(:'Zoom')
189
+ self.zoom = attributes[:'Zoom']
190
+ end
191
+
192
+ if attributes.has_key?(:'FileName')
193
+ self.file_name = attributes[:'FileName']
194
+ end
195
+
196
+ if attributes.has_key?(:'Width')
197
+ self.width = attributes[:'Width']
198
+ end
199
+
200
+ if attributes.has_key?(:'Height')
201
+ self.height = attributes[:'Height']
202
+ end
203
+
204
+ end
205
+
206
+ # Show invalid properties with the reasons. Usually used together with valid?
207
+ # @return Array for valid properies with the reasons
208
+ def list_invalid_properties
209
+ invalid_properties = Array.new
210
+ return invalid_properties
211
+ end
212
+
213
+ # Check to see if the all the properties in the model are valid
214
+ # @return true if the model is valid
215
+ def valid?
216
+ return true
217
+ end
218
+
219
+ # Checks equality by comparing each attribute.
220
+ # @param [Object] Object to be compared
221
+ def ==(o)
222
+ return true if self.equal?(o)
223
+ self.class == o.class &&
224
+ links == o.links &&
225
+ background == o.background &&
226
+ bottom_margin == o.bottom_margin &&
227
+ horizontal_alignment == o.horizontal_alignment &&
228
+ left_margin == o.left_margin &&
229
+ opacity == o.opacity &&
230
+ right_margin == o.right_margin &&
231
+ rotate == o.rotate &&
232
+ rotate_angle == o.rotate_angle &&
233
+ top_margin == o.top_margin &&
234
+ vertical_alignment == o.vertical_alignment &&
235
+ x_indent == o.x_indent &&
236
+ y_indent == o.y_indent &&
237
+ zoom == o.zoom &&
238
+ file_name == o.file_name &&
239
+ width == o.width &&
240
+ height == o.height
241
+ end
242
+
243
+ # @see the `==` method
244
+ # @param [Object] Object to be compared
245
+ def eql?(o)
246
+ self == o
247
+ end
248
+
249
+ # Calculates hash code according to all attributes.
250
+ # @return [Fixnum] Hash code
251
+ def hash
252
+ [links, background, bottom_margin, horizontal_alignment, left_margin, opacity, right_margin, rotate, rotate_angle, top_margin, vertical_alignment, x_indent, y_indent, zoom, file_name, width, height].hash
253
+ end
254
+
255
+ # Builds the object from hash
256
+ # @param [Hash] attributes Model attributes in the form of hash
257
+ # @return [Object] Returns the model itself
258
+ def build_from_hash(attributes)
259
+ return nil unless attributes.is_a?(Hash)
260
+ self.class.swagger_types.each_pair do |key, type|
261
+ if type =~ /\AArray<(.*)>/i
262
+ # check to ensure the input is an array given that the the attribute
263
+ # is documented as an array but the input is not
264
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
265
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
266
+ end
267
+ elsif !attributes[self.class.attribute_map[key]].nil?
268
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
269
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
270
+ end
271
+
272
+ self
273
+ end
274
+
275
+ # Deserializes the data based on type
276
+ # @param string type Data type
277
+ # @param string value Value to be deserialized
278
+ # @return [Object] Deserialized data
279
+ def _deserialize(type, value)
280
+ case type.to_sym
281
+ when :DateTime
282
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
283
+ Time.strptime(value, format).utc.to_datetime
284
+ when :Date
285
+ format = (value.include? '+') ? '/Date(%Q%z)/' : '/Date(%Q)/'
286
+ Time.strptime(value, format).utc.to_datetime.to_date
287
+ when :String
288
+ value.to_s
289
+ when :Integer
290
+ value.to_i
291
+ when :Float
292
+ value.to_f
293
+ when :BOOLEAN
294
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
295
+ true
296
+ else
297
+ false
298
+ end
299
+ when :Object
300
+ # generic object (usually a Hash), return directly
301
+ value
302
+ when /\AArray<(?<inner_type>.+)>\z/
303
+ inner_type = Regexp.last_match[:inner_type]
304
+ value.map { |v| _deserialize(inner_type, v) }
305
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
306
+ k_type = Regexp.last_match[:k_type]
307
+ v_type = Regexp.last_match[:v_type]
308
+ {}.tap do |hash|
309
+ value.each do |k, v|
310
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
311
+ end
312
+ end
313
+ else # model
314
+ temp_model = AsposePdfCloud.const_get(type).new
315
+ temp_model.build_from_hash(value)
316
+ end
317
+ end
318
+
319
+ # Returns the string representation of the object
320
+ # @return [String] String presentation of the object
321
+ def to_s
322
+ to_hash.to_s
323
+ end
324
+
325
+ # to_body is an alias to to_hash (backward compatibility)
326
+ # @return [Hash] Returns the object in the form of hash
327
+ def to_body
328
+ to_hash
329
+ end
330
+
331
+ # Returns the object in the form of hash
332
+ # @return [Hash] Returns the object in the form of hash
333
+ def to_hash
334
+ hash = {}
335
+ self.class.attribute_map.each_pair do |attr, param|
336
+ value = self.send(attr)
337
+ next if value.nil?
338
+ hash[param] = _to_hash(value)
339
+ end
340
+ hash
341
+ end
342
+
343
+ # Outputs non-array value in the form of hash
344
+ # For object, use to_hash. Otherwise, just return the value
345
+ # @param [Object] value Any valid value
346
+ # @return [Hash] Returns the value in the form of hash
347
+ def _to_hash(value)
348
+ if value.is_a?(Array)
349
+ value.compact.map{ |v| _to_hash(v) }
350
+ elsif value.is_a?(Hash)
351
+ {}.tap do |hash|
352
+ value.each { |k, v| hash[k] = _to_hash(v) }
353
+ end
354
+ elsif value.respond_to? :to_hash
355
+ value.to_hash
356
+ else
357
+ value
358
+ end
359
+ end
360
+
361
+ end
362
+
363
+ end