AsposeDiagramCloud 18.10 → 20.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/AsposeDiagramCloud.gemspec +46 -0
  3. data/Gemfile +7 -0
  4. data/README.md +74 -0
  5. data/Rakefile +8 -0
  6. data/git_push.sh +55 -0
  7. data/lib/AsposeDiagramCloud.rb +85 -0
  8. data/lib/AsposeDiagramCloud/api/diagram_api.rb +768 -0
  9. data/lib/AsposeDiagramCloud/api/o_auth_api.rb +93 -0
  10. data/lib/AsposeDiagramCloud/api/storage_api.rb +905 -0
  11. data/lib/AsposeDiagramCloud/api_client.rb +391 -0
  12. data/lib/AsposeDiagramCloud/api_error.rb +38 -0
  13. data/lib/AsposeDiagramCloud/configuration.rb +209 -0
  14. data/lib/AsposeDiagramCloud/models/access_token_response.rb +251 -0
  15. data/lib/AsposeDiagramCloud/models/api_response_of_list_of_page_data.rb +190 -0
  16. data/lib/AsposeDiagramCloud/models/create_new_response.rb +188 -0
  17. data/lib/AsposeDiagramCloud/models/diagram_save_options.rb +244 -0
  18. data/lib/AsposeDiagramCloud/models/disc_usage.rb +209 -0
  19. data/lib/AsposeDiagramCloud/models/draw_shape_data.rb +262 -0
  20. data/lib/AsposeDiagramCloud/models/ellipse_data.rb +262 -0
  21. data/lib/AsposeDiagramCloud/models/error.rb +219 -0
  22. data/lib/AsposeDiagramCloud/models/error_details.rb +204 -0
  23. data/lib/AsposeDiagramCloud/models/file_version.rb +264 -0
  24. data/lib/AsposeDiagramCloud/models/file_versions.rb +191 -0
  25. data/lib/AsposeDiagramCloud/models/files_list.rb +191 -0
  26. data/lib/AsposeDiagramCloud/models/files_upload_result.rb +203 -0
  27. data/lib/AsposeDiagramCloud/models/html_save_options.rb +330 -0
  28. data/lib/AsposeDiagramCloud/models/image_save_options.rb +492 -0
  29. data/lib/AsposeDiagramCloud/models/line_data.rb +273 -0
  30. data/lib/AsposeDiagramCloud/models/modify_response.rb +202 -0
  31. data/lib/AsposeDiagramCloud/models/object_exist.rb +209 -0
  32. data/lib/AsposeDiagramCloud/models/page_data.rb +216 -0
  33. data/lib/AsposeDiagramCloud/models/page_setting.rb +219 -0
  34. data/lib/AsposeDiagramCloud/models/page_size.rb +221 -0
  35. data/lib/AsposeDiagramCloud/models/pdf_digital_signature_details.rb +248 -0
  36. data/lib/AsposeDiagramCloud/models/pdf_encryption_details.rb +260 -0
  37. data/lib/AsposeDiagramCloud/models/pdf_save_options.rb +408 -0
  38. data/lib/AsposeDiagramCloud/models/point_f.rb +221 -0
  39. data/lib/AsposeDiagramCloud/models/polyline_data.rb +273 -0
  40. data/lib/AsposeDiagramCloud/models/rectangle_f.rb +333 -0
  41. data/lib/AsposeDiagramCloud/models/rendering_save_options.rb +276 -0
  42. data/lib/AsposeDiagramCloud/models/saa_spose_response.rb +179 -0
  43. data/lib/AsposeDiagramCloud/models/save_as_response.rb +208 -0
  44. data/lib/AsposeDiagramCloud/models/save_options_model.rb +235 -0
  45. data/lib/AsposeDiagramCloud/models/save_options_request.rb +206 -0
  46. data/lib/AsposeDiagramCloud/models/shape_data.rb +221 -0
  47. data/lib/AsposeDiagramCloud/models/shape_style_data.rb +189 -0
  48. data/lib/AsposeDiagramCloud/models/storage_exist.rb +194 -0
  49. data/lib/AsposeDiagramCloud/models/storage_file.rb +239 -0
  50. data/lib/AsposeDiagramCloud/models/svg_save_options.rb +321 -0
  51. data/lib/AsposeDiagramCloud/models/swf_save_options.rb +271 -0
  52. data/lib/AsposeDiagramCloud/models/text_style_data.rb +253 -0
  53. data/lib/AsposeDiagramCloud/models/upload_response.rb +188 -0
  54. data/lib/AsposeDiagramCloud/models/xaml_save_options.rb +262 -0
  55. data/lib/AsposeDiagramCloud/models/xps_save_options.rb +271 -0
  56. data/lib/AsposeDiagramCloud/version.rb +15 -0
  57. data/spec/_spec.rb +308 -0
  58. data/spec/api/test_convert_spec.rb +308 -0
  59. data/spec/api/test_drawing_spec.rb +136 -0
  60. data/spec/api/test_page_spec.rb +92 -0
  61. data/spec/api_client_spec.rb +226 -0
  62. data/spec/configuration_spec.rb +42 -0
  63. data/spec/spec_helper.rb +120 -0
  64. data/testData/FileUpload.vdx +437 -0
  65. metadata +118 -49
@@ -0,0 +1,333 @@
1
+ =begin
2
+ #Aspose.Diagram Cloud API Reference
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 3.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module AsposeDiagramCloud
16
+
17
+ class RectangleF
18
+ attr_accessor :location
19
+
20
+ attr_accessor :size
21
+
22
+ attr_accessor :x
23
+
24
+ attr_accessor :y
25
+
26
+ attr_accessor :width
27
+
28
+ attr_accessor :height
29
+
30
+ attr_accessor :left
31
+
32
+ attr_accessor :top
33
+
34
+ attr_accessor :right
35
+
36
+ attr_accessor :bottom
37
+
38
+ attr_accessor :is_empty
39
+
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'location' => :'Location',
45
+ :'size' => :'Size',
46
+ :'x' => :'X',
47
+ :'y' => :'Y',
48
+ :'width' => :'Width',
49
+ :'height' => :'Height',
50
+ :'left' => :'Left',
51
+ :'top' => :'Top',
52
+ :'right' => :'Right',
53
+ :'bottom' => :'Bottom',
54
+ :'is_empty' => :'IsEmpty'
55
+ }
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.swagger_types
60
+ {
61
+ :'location' => :'PointF',
62
+ :'size' => :'String',
63
+ :'x' => :'Float',
64
+ :'y' => :'Float',
65
+ :'width' => :'Float',
66
+ :'height' => :'Float',
67
+ :'left' => :'Float',
68
+ :'top' => :'Float',
69
+ :'right' => :'Float',
70
+ :'bottom' => :'Float',
71
+ :'is_empty' => :'BOOLEAN'
72
+ }
73
+ end
74
+
75
+ # Initializes the object
76
+ # @param [Hash] attributes Model attributes in the form of hash
77
+ def initialize(attributes = {})
78
+ return unless attributes.is_a?(Hash)
79
+
80
+ # convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
82
+
83
+ if attributes.has_key?(:'Location')
84
+ self.location = attributes[:'Location']
85
+ end
86
+
87
+ if attributes.has_key?(:'Size')
88
+ self.size = attributes[:'Size']
89
+ end
90
+
91
+ if attributes.has_key?(:'X')
92
+ self.x = attributes[:'X']
93
+ end
94
+
95
+ if attributes.has_key?(:'Y')
96
+ self.y = attributes[:'Y']
97
+ end
98
+
99
+ if attributes.has_key?(:'Width')
100
+ self.width = attributes[:'Width']
101
+ end
102
+
103
+ if attributes.has_key?(:'Height')
104
+ self.height = attributes[:'Height']
105
+ end
106
+
107
+ if attributes.has_key?(:'Left')
108
+ self.left = attributes[:'Left']
109
+ end
110
+
111
+ if attributes.has_key?(:'Top')
112
+ self.top = attributes[:'Top']
113
+ end
114
+
115
+ if attributes.has_key?(:'Right')
116
+ self.right = attributes[:'Right']
117
+ end
118
+
119
+ if attributes.has_key?(:'Bottom')
120
+ self.bottom = attributes[:'Bottom']
121
+ end
122
+
123
+ if attributes.has_key?(:'IsEmpty')
124
+ self.is_empty = attributes[:'IsEmpty']
125
+ end
126
+
127
+ end
128
+
129
+ # Show invalid properties with the reasons. Usually used together with valid?
130
+ # @return Array for valid properies with the reasons
131
+ def list_invalid_properties
132
+ invalid_properties = Array.new
133
+ if @location.nil?
134
+ invalid_properties.push("invalid value for 'location', location cannot be nil.")
135
+ end
136
+
137
+ if @size.nil?
138
+ invalid_properties.push("invalid value for 'size', size cannot be nil.")
139
+ end
140
+
141
+ if @x.nil?
142
+ invalid_properties.push("invalid value for 'x', x cannot be nil.")
143
+ end
144
+
145
+ if @y.nil?
146
+ invalid_properties.push("invalid value for 'y', y cannot be nil.")
147
+ end
148
+
149
+ if @width.nil?
150
+ invalid_properties.push("invalid value for 'width', width cannot be nil.")
151
+ end
152
+
153
+ if @height.nil?
154
+ invalid_properties.push("invalid value for 'height', height cannot be nil.")
155
+ end
156
+
157
+ if @left.nil?
158
+ invalid_properties.push("invalid value for 'left', left cannot be nil.")
159
+ end
160
+
161
+ if @top.nil?
162
+ invalid_properties.push("invalid value for 'top', top cannot be nil.")
163
+ end
164
+
165
+ if @right.nil?
166
+ invalid_properties.push("invalid value for 'right', right cannot be nil.")
167
+ end
168
+
169
+ if @bottom.nil?
170
+ invalid_properties.push("invalid value for 'bottom', bottom cannot be nil.")
171
+ end
172
+
173
+ if @is_empty.nil?
174
+ invalid_properties.push("invalid value for 'is_empty', is_empty cannot be nil.")
175
+ end
176
+
177
+ return invalid_properties
178
+ end
179
+
180
+ # Check to see if the all the properties in the model are valid
181
+ # @return true if the model is valid
182
+ def valid?
183
+ return false if @location.nil?
184
+ return false if @size.nil?
185
+ return false if @x.nil?
186
+ return false if @y.nil?
187
+ return false if @width.nil?
188
+ return false if @height.nil?
189
+ return false if @left.nil?
190
+ return false if @top.nil?
191
+ return false if @right.nil?
192
+ return false if @bottom.nil?
193
+ return false if @is_empty.nil?
194
+ return true
195
+ end
196
+
197
+ # Checks equality by comparing each attribute.
198
+ # @param [Object] Object to be compared
199
+ def ==(o)
200
+ return true if self.equal?(o)
201
+ self.class == o.class &&
202
+ location == o.location &&
203
+ size == o.size &&
204
+ x == o.x &&
205
+ y == o.y &&
206
+ width == o.width &&
207
+ height == o.height &&
208
+ left == o.left &&
209
+ top == o.top &&
210
+ right == o.right &&
211
+ bottom == o.bottom &&
212
+ is_empty == o.is_empty
213
+ end
214
+
215
+ # @see the `==` method
216
+ # @param [Object] Object to be compared
217
+ def eql?(o)
218
+ self == o
219
+ end
220
+
221
+ # Calculates hash code according to all attributes.
222
+ # @return [Fixnum] Hash code
223
+ def hash
224
+ [location, size, x, y, width, height, left, top, right, bottom, is_empty].hash
225
+ end
226
+
227
+ # Builds the object from hash
228
+ # @param [Hash] attributes Model attributes in the form of hash
229
+ # @return [Object] Returns the model itself
230
+ def build_from_hash(attributes)
231
+ return nil unless attributes.is_a?(Hash)
232
+ self.class.swagger_types.each_pair do |key, type|
233
+ if type =~ /\AArray<(.*)>/i
234
+ # check to ensure the input is an array given that the the attribute
235
+ # is documented as an array but the input is not
236
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
237
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
238
+ end
239
+ elsif !attributes[self.class.attribute_map[key]].nil?
240
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
241
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
242
+ end
243
+
244
+ self
245
+ end
246
+
247
+ # Deserializes the data based on type
248
+ # @param string type Data type
249
+ # @param string value Value to be deserialized
250
+ # @return [Object] Deserialized data
251
+ def _deserialize(type, value)
252
+ case type.to_sym
253
+ when :DateTime
254
+ DateTime.parse(value)
255
+ when :Date
256
+ Date.parse(value)
257
+ when :String
258
+ value.to_s
259
+ when :Integer
260
+ value.to_i
261
+ when :Float
262
+ value.to_f
263
+ when :BOOLEAN
264
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
265
+ true
266
+ else
267
+ false
268
+ end
269
+ when :Object
270
+ # generic object (usually a Hash), return directly
271
+ value
272
+ when /\AArray<(?<inner_type>.+)>\z/
273
+ inner_type = Regexp.last_match[:inner_type]
274
+ value.map { |v| _deserialize(inner_type, v) }
275
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
276
+ k_type = Regexp.last_match[:k_type]
277
+ v_type = Regexp.last_match[:v_type]
278
+ {}.tap do |hash|
279
+ value.each do |k, v|
280
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
281
+ end
282
+ end
283
+ else # model
284
+ temp_model = AsposeDiagramCloud.const_get(type).new
285
+ temp_model.build_from_hash(value)
286
+ end
287
+ end
288
+
289
+ # Returns the string representation of the object
290
+ # @return [String] String presentation of the object
291
+ def to_s
292
+ to_hash.to_s
293
+ end
294
+
295
+ # to_body is an alias to to_hash (backward compatibility)
296
+ # @return [Hash] Returns the object in the form of hash
297
+ def to_body
298
+ to_hash
299
+ end
300
+
301
+ # Returns the object in the form of hash
302
+ # @return [Hash] Returns the object in the form of hash
303
+ def to_hash
304
+ hash = {}
305
+ self.class.attribute_map.each_pair do |attr, param|
306
+ value = self.send(attr)
307
+ next if value.nil?
308
+ hash[param] = _to_hash(value)
309
+ end
310
+ hash
311
+ end
312
+
313
+ # Outputs non-array value in the form of hash
314
+ # For object, use to_hash. Otherwise, just return the value
315
+ # @param [Object] value Any valid value
316
+ # @return [Hash] Returns the value in the form of hash
317
+ def _to_hash(value)
318
+ if value.is_a?(Array)
319
+ value.compact.map{ |v| _to_hash(v) }
320
+ elsif value.is_a?(Hash)
321
+ {}.tap do |hash|
322
+ value.each { |k, v| hash[k] = _to_hash(v) }
323
+ end
324
+ elsif value.respond_to? :to_hash
325
+ value.to_hash
326
+ else
327
+ value
328
+ end
329
+ end
330
+
331
+ end
332
+
333
+ end
@@ -0,0 +1,276 @@
1
+ =begin
2
+ #Aspose.Diagram Cloud API Reference
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 3.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module AsposeDiagramCloud
16
+
17
+ class RenderingSaveOptions
18
+ attr_accessor :save_format
19
+
20
+ attr_accessor :default_font
21
+
22
+ attr_accessor :area
23
+
24
+ attr_accessor :export_guide_shapes
25
+
26
+ attr_accessor :page_size
27
+
28
+ attr_accessor :is_export_comments
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'save_format' => :'SaveFormat',
56
+ :'default_font' => :'DefaultFont',
57
+ :'area' => :'Area',
58
+ :'export_guide_shapes' => :'ExportGuideShapes',
59
+ :'page_size' => :'PageSize',
60
+ :'is_export_comments' => :'IsExportComments'
61
+ }
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.swagger_types
66
+ {
67
+ :'save_format' => :'String',
68
+ :'default_font' => :'String',
69
+ :'area' => :'RectangleF',
70
+ :'export_guide_shapes' => :'BOOLEAN',
71
+ :'page_size' => :'PageSize',
72
+ :'is_export_comments' => :'BOOLEAN'
73
+ }
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ return unless attributes.is_a?(Hash)
80
+
81
+ # convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
83
+
84
+ if attributes.has_key?(:'SaveFormat')
85
+ self.save_format = attributes[:'SaveFormat']
86
+ end
87
+
88
+ if attributes.has_key?(:'DefaultFont')
89
+ self.default_font = attributes[:'DefaultFont']
90
+ end
91
+
92
+ if attributes.has_key?(:'Area')
93
+ self.area = attributes[:'Area']
94
+ end
95
+
96
+ if attributes.has_key?(:'ExportGuideShapes')
97
+ self.export_guide_shapes = attributes[:'ExportGuideShapes']
98
+ end
99
+
100
+ if attributes.has_key?(:'PageSize')
101
+ self.page_size = attributes[:'PageSize']
102
+ end
103
+
104
+ if attributes.has_key?(:'IsExportComments')
105
+ self.is_export_comments = attributes[:'IsExportComments']
106
+ end
107
+
108
+ end
109
+
110
+ # Show invalid properties with the reasons. Usually used together with valid?
111
+ # @return Array for valid properies with the reasons
112
+ def list_invalid_properties
113
+ invalid_properties = Array.new
114
+ if @save_format.nil?
115
+ invalid_properties.push("invalid value for 'save_format', save_format cannot be nil.")
116
+ end
117
+
118
+ if @area.nil?
119
+ invalid_properties.push("invalid value for 'area', area cannot be nil.")
120
+ end
121
+
122
+ return invalid_properties
123
+ end
124
+
125
+ # Check to see if the all the properties in the model are valid
126
+ # @return true if the model is valid
127
+ def valid?
128
+ return false if @save_format.nil?
129
+ save_format_validator = EnumAttributeValidator.new('String', ["VDX", "VSX", "VTX", "TIFF", "PNG", "BMP", "EMF", "JPEG", "PDF", "XPS", "GIF", "HTML", "SVG", "SWF", "XAML", "VSDX", "VSTX", "VSSX", "VSDM", "VSSM", "VSTM"])
130
+ return false unless save_format_validator.valid?(@save_format)
131
+ return false if @area.nil?
132
+ return true
133
+ end
134
+
135
+ # Custom attribute writer method checking allowed values (enum).
136
+ # @param [Object] save_format Object to be assigned
137
+ def save_format=(save_format)
138
+ validator = EnumAttributeValidator.new('String', ["VDX", "VSX", "VTX", "TIFF", "PNG", "BMP", "EMF", "JPEG", "PDF", "XPS", "GIF", "HTML", "SVG", "SWF", "XAML", "VSDX", "VSTX", "VSSX", "VSDM", "VSSM", "VSTM"])
139
+ unless validator.valid?(save_format)
140
+ fail ArgumentError, "invalid value for 'save_format', must be one of #{validator.allowable_values}."
141
+ end
142
+ @save_format = save_format
143
+ end
144
+
145
+ # Checks equality by comparing each attribute.
146
+ # @param [Object] Object to be compared
147
+ def ==(o)
148
+ return true if self.equal?(o)
149
+ self.class == o.class &&
150
+ save_format == o.save_format &&
151
+ default_font == o.default_font &&
152
+ area == o.area &&
153
+ export_guide_shapes == o.export_guide_shapes &&
154
+ page_size == o.page_size &&
155
+ is_export_comments == o.is_export_comments
156
+ end
157
+
158
+ # @see the `==` method
159
+ # @param [Object] Object to be compared
160
+ def eql?(o)
161
+ self == o
162
+ end
163
+
164
+ # Calculates hash code according to all attributes.
165
+ # @return [Fixnum] Hash code
166
+ def hash
167
+ [save_format, default_font, area, export_guide_shapes, page_size, is_export_comments].hash
168
+ end
169
+
170
+ # Builds the object from hash
171
+ # @param [Hash] attributes Model attributes in the form of hash
172
+ # @return [Object] Returns the model itself
173
+ def build_from_hash(attributes)
174
+ return nil unless attributes.is_a?(Hash)
175
+ self.class.swagger_types.each_pair do |key, type|
176
+ if type =~ /\AArray<(.*)>/i
177
+ # check to ensure the input is an array given that the the attribute
178
+ # is documented as an array but the input is not
179
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
180
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
181
+ end
182
+ elsif !attributes[self.class.attribute_map[key]].nil?
183
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
184
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
185
+ end
186
+
187
+ self
188
+ end
189
+
190
+ # Deserializes the data based on type
191
+ # @param string type Data type
192
+ # @param string value Value to be deserialized
193
+ # @return [Object] Deserialized data
194
+ def _deserialize(type, value)
195
+ case type.to_sym
196
+ when :DateTime
197
+ DateTime.parse(value)
198
+ when :Date
199
+ Date.parse(value)
200
+ when :String
201
+ value.to_s
202
+ when :Integer
203
+ value.to_i
204
+ when :Float
205
+ value.to_f
206
+ when :BOOLEAN
207
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
208
+ true
209
+ else
210
+ false
211
+ end
212
+ when :Object
213
+ # generic object (usually a Hash), return directly
214
+ value
215
+ when /\AArray<(?<inner_type>.+)>\z/
216
+ inner_type = Regexp.last_match[:inner_type]
217
+ value.map { |v| _deserialize(inner_type, v) }
218
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
219
+ k_type = Regexp.last_match[:k_type]
220
+ v_type = Regexp.last_match[:v_type]
221
+ {}.tap do |hash|
222
+ value.each do |k, v|
223
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
224
+ end
225
+ end
226
+ else # model
227
+ temp_model = AsposeDiagramCloud.const_get(type).new
228
+ temp_model.build_from_hash(value)
229
+ end
230
+ end
231
+
232
+ # Returns the string representation of the object
233
+ # @return [String] String presentation of the object
234
+ def to_s
235
+ to_hash.to_s
236
+ end
237
+
238
+ # to_body is an alias to to_hash (backward compatibility)
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_body
241
+ to_hash
242
+ end
243
+
244
+ # Returns the object in the form of hash
245
+ # @return [Hash] Returns the object in the form of hash
246
+ def to_hash
247
+ hash = {}
248
+ self.class.attribute_map.each_pair do |attr, param|
249
+ value = self.send(attr)
250
+ next if value.nil?
251
+ hash[param] = _to_hash(value)
252
+ end
253
+ hash
254
+ end
255
+
256
+ # Outputs non-array value in the form of hash
257
+ # For object, use to_hash. Otherwise, just return the value
258
+ # @param [Object] value Any valid value
259
+ # @return [Hash] Returns the value in the form of hash
260
+ def _to_hash(value)
261
+ if value.is_a?(Array)
262
+ value.compact.map{ |v| _to_hash(v) }
263
+ elsif value.is_a?(Hash)
264
+ {}.tap do |hash|
265
+ value.each { |k, v| hash[k] = _to_hash(v) }
266
+ end
267
+ elsif value.respond_to? :to_hash
268
+ value.to_hash
269
+ else
270
+ value
271
+ end
272
+ end
273
+
274
+ end
275
+
276
+ end