AsposeDiagramCloud 18.10 → 20.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/AsposeDiagramCloud.gemspec +46 -0
- data/Gemfile +7 -0
- data/README.md +74 -0
- data/Rakefile +8 -0
- data/git_push.sh +55 -0
- data/lib/AsposeDiagramCloud.rb +85 -0
- data/lib/AsposeDiagramCloud/api/diagram_api.rb +768 -0
- data/lib/AsposeDiagramCloud/api/o_auth_api.rb +93 -0
- data/lib/AsposeDiagramCloud/api/storage_api.rb +905 -0
- data/lib/AsposeDiagramCloud/api_client.rb +391 -0
- data/lib/AsposeDiagramCloud/api_error.rb +38 -0
- data/lib/AsposeDiagramCloud/configuration.rb +209 -0
- data/lib/AsposeDiagramCloud/models/access_token_response.rb +251 -0
- data/lib/AsposeDiagramCloud/models/api_response_of_list_of_page_data.rb +190 -0
- data/lib/AsposeDiagramCloud/models/create_new_response.rb +188 -0
- data/lib/AsposeDiagramCloud/models/diagram_save_options.rb +244 -0
- data/lib/AsposeDiagramCloud/models/disc_usage.rb +209 -0
- data/lib/AsposeDiagramCloud/models/draw_shape_data.rb +262 -0
- data/lib/AsposeDiagramCloud/models/ellipse_data.rb +262 -0
- data/lib/AsposeDiagramCloud/models/error.rb +219 -0
- data/lib/AsposeDiagramCloud/models/error_details.rb +204 -0
- data/lib/AsposeDiagramCloud/models/file_version.rb +264 -0
- data/lib/AsposeDiagramCloud/models/file_versions.rb +191 -0
- data/lib/AsposeDiagramCloud/models/files_list.rb +191 -0
- data/lib/AsposeDiagramCloud/models/files_upload_result.rb +203 -0
- data/lib/AsposeDiagramCloud/models/html_save_options.rb +330 -0
- data/lib/AsposeDiagramCloud/models/image_save_options.rb +492 -0
- data/lib/AsposeDiagramCloud/models/line_data.rb +273 -0
- data/lib/AsposeDiagramCloud/models/modify_response.rb +202 -0
- data/lib/AsposeDiagramCloud/models/object_exist.rb +209 -0
- data/lib/AsposeDiagramCloud/models/page_data.rb +216 -0
- data/lib/AsposeDiagramCloud/models/page_setting.rb +219 -0
- data/lib/AsposeDiagramCloud/models/page_size.rb +221 -0
- data/lib/AsposeDiagramCloud/models/pdf_digital_signature_details.rb +248 -0
- data/lib/AsposeDiagramCloud/models/pdf_encryption_details.rb +260 -0
- data/lib/AsposeDiagramCloud/models/pdf_save_options.rb +408 -0
- data/lib/AsposeDiagramCloud/models/point_f.rb +221 -0
- data/lib/AsposeDiagramCloud/models/polyline_data.rb +273 -0
- data/lib/AsposeDiagramCloud/models/rectangle_f.rb +333 -0
- data/lib/AsposeDiagramCloud/models/rendering_save_options.rb +276 -0
- data/lib/AsposeDiagramCloud/models/saa_spose_response.rb +179 -0
- data/lib/AsposeDiagramCloud/models/save_as_response.rb +208 -0
- data/lib/AsposeDiagramCloud/models/save_options_model.rb +235 -0
- data/lib/AsposeDiagramCloud/models/save_options_request.rb +206 -0
- data/lib/AsposeDiagramCloud/models/shape_data.rb +221 -0
- data/lib/AsposeDiagramCloud/models/shape_style_data.rb +189 -0
- data/lib/AsposeDiagramCloud/models/storage_exist.rb +194 -0
- data/lib/AsposeDiagramCloud/models/storage_file.rb +239 -0
- data/lib/AsposeDiagramCloud/models/svg_save_options.rb +321 -0
- data/lib/AsposeDiagramCloud/models/swf_save_options.rb +271 -0
- data/lib/AsposeDiagramCloud/models/text_style_data.rb +253 -0
- data/lib/AsposeDiagramCloud/models/upload_response.rb +188 -0
- data/lib/AsposeDiagramCloud/models/xaml_save_options.rb +262 -0
- data/lib/AsposeDiagramCloud/models/xps_save_options.rb +271 -0
- data/lib/AsposeDiagramCloud/version.rb +15 -0
- data/spec/_spec.rb +308 -0
- data/spec/api/test_convert_spec.rb +308 -0
- data/spec/api/test_drawing_spec.rb +136 -0
- data/spec/api/test_page_spec.rb +92 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/spec_helper.rb +120 -0
- data/testData/FileUpload.vdx +437 -0
- metadata +118 -49
@@ -0,0 +1,271 @@
|
|
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 SWFSaveOptions
|
18
|
+
attr_accessor :save_format
|
19
|
+
|
20
|
+
attr_accessor :default_font
|
21
|
+
|
22
|
+
attr_accessor :page_count
|
23
|
+
|
24
|
+
attr_accessor :viewer_included
|
25
|
+
|
26
|
+
attr_accessor :page_index
|
27
|
+
|
28
|
+
attr_accessor :save_foreground_pages_only
|
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
|
+
:'page_count' => :'PageCount',
|
58
|
+
:'viewer_included' => :'ViewerIncluded',
|
59
|
+
:'page_index' => :'PageIndex',
|
60
|
+
:'save_foreground_pages_only' => :'SaveForegroundPagesOnly'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# Attribute type mapping.
|
65
|
+
def self.swagger_types
|
66
|
+
{
|
67
|
+
:'save_format' => :'String',
|
68
|
+
:'default_font' => :'String',
|
69
|
+
:'page_count' => :'Integer',
|
70
|
+
:'viewer_included' => :'BOOLEAN',
|
71
|
+
:'page_index' => :'Integer',
|
72
|
+
:'save_foreground_pages_only' => :'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?(:'PageCount')
|
93
|
+
self.page_count = attributes[:'PageCount']
|
94
|
+
end
|
95
|
+
|
96
|
+
if attributes.has_key?(:'ViewerIncluded')
|
97
|
+
self.viewer_included = attributes[:'ViewerIncluded']
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.has_key?(:'PageIndex')
|
101
|
+
self.page_index = attributes[:'PageIndex']
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.has_key?(:'SaveForegroundPagesOnly')
|
105
|
+
self.save_foreground_pages_only = attributes[:'SaveForegroundPagesOnly']
|
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
|
+
return invalid_properties
|
119
|
+
end
|
120
|
+
|
121
|
+
# Check to see if the all the properties in the model are valid
|
122
|
+
# @return true if the model is valid
|
123
|
+
def valid?
|
124
|
+
return false if @save_format.nil?
|
125
|
+
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"])
|
126
|
+
return false unless save_format_validator.valid?(@save_format)
|
127
|
+
return true
|
128
|
+
end
|
129
|
+
|
130
|
+
# Custom attribute writer method checking allowed values (enum).
|
131
|
+
# @param [Object] save_format Object to be assigned
|
132
|
+
def save_format=(save_format)
|
133
|
+
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"])
|
134
|
+
unless validator.valid?(save_format)
|
135
|
+
fail ArgumentError, "invalid value for 'save_format', must be one of #{validator.allowable_values}."
|
136
|
+
end
|
137
|
+
@save_format = save_format
|
138
|
+
end
|
139
|
+
|
140
|
+
# Checks equality by comparing each attribute.
|
141
|
+
# @param [Object] Object to be compared
|
142
|
+
def ==(o)
|
143
|
+
return true if self.equal?(o)
|
144
|
+
self.class == o.class &&
|
145
|
+
save_format == o.save_format &&
|
146
|
+
default_font == o.default_font &&
|
147
|
+
page_count == o.page_count &&
|
148
|
+
viewer_included == o.viewer_included &&
|
149
|
+
page_index == o.page_index &&
|
150
|
+
save_foreground_pages_only == o.save_foreground_pages_only
|
151
|
+
end
|
152
|
+
|
153
|
+
# @see the `==` method
|
154
|
+
# @param [Object] Object to be compared
|
155
|
+
def eql?(o)
|
156
|
+
self == o
|
157
|
+
end
|
158
|
+
|
159
|
+
# Calculates hash code according to all attributes.
|
160
|
+
# @return [Fixnum] Hash code
|
161
|
+
def hash
|
162
|
+
[save_format, default_font, page_count, viewer_included, page_index, save_foreground_pages_only].hash
|
163
|
+
end
|
164
|
+
|
165
|
+
# Builds the object from hash
|
166
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
167
|
+
# @return [Object] Returns the model itself
|
168
|
+
def build_from_hash(attributes)
|
169
|
+
return nil unless attributes.is_a?(Hash)
|
170
|
+
self.class.swagger_types.each_pair do |key, type|
|
171
|
+
if type =~ /\AArray<(.*)>/i
|
172
|
+
# check to ensure the input is an array given that the the attribute
|
173
|
+
# is documented as an array but the input is not
|
174
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
175
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
176
|
+
end
|
177
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
178
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
179
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
180
|
+
end
|
181
|
+
|
182
|
+
self
|
183
|
+
end
|
184
|
+
|
185
|
+
# Deserializes the data based on type
|
186
|
+
# @param string type Data type
|
187
|
+
# @param string value Value to be deserialized
|
188
|
+
# @return [Object] Deserialized data
|
189
|
+
def _deserialize(type, value)
|
190
|
+
case type.to_sym
|
191
|
+
when :DateTime
|
192
|
+
DateTime.parse(value)
|
193
|
+
when :Date
|
194
|
+
Date.parse(value)
|
195
|
+
when :String
|
196
|
+
value.to_s
|
197
|
+
when :Integer
|
198
|
+
value.to_i
|
199
|
+
when :Float
|
200
|
+
value.to_f
|
201
|
+
when :BOOLEAN
|
202
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
203
|
+
true
|
204
|
+
else
|
205
|
+
false
|
206
|
+
end
|
207
|
+
when :Object
|
208
|
+
# generic object (usually a Hash), return directly
|
209
|
+
value
|
210
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
211
|
+
inner_type = Regexp.last_match[:inner_type]
|
212
|
+
value.map { |v| _deserialize(inner_type, v) }
|
213
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
214
|
+
k_type = Regexp.last_match[:k_type]
|
215
|
+
v_type = Regexp.last_match[:v_type]
|
216
|
+
{}.tap do |hash|
|
217
|
+
value.each do |k, v|
|
218
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
else # model
|
222
|
+
temp_model = AsposeDiagramCloud.const_get(type).new
|
223
|
+
temp_model.build_from_hash(value)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# Returns the string representation of the object
|
228
|
+
# @return [String] String presentation of the object
|
229
|
+
def to_s
|
230
|
+
to_hash.to_s
|
231
|
+
end
|
232
|
+
|
233
|
+
# to_body is an alias to to_hash (backward compatibility)
|
234
|
+
# @return [Hash] Returns the object in the form of hash
|
235
|
+
def to_body
|
236
|
+
to_hash
|
237
|
+
end
|
238
|
+
|
239
|
+
# Returns the object in the form of hash
|
240
|
+
# @return [Hash] Returns the object in the form of hash
|
241
|
+
def to_hash
|
242
|
+
hash = {}
|
243
|
+
self.class.attribute_map.each_pair do |attr, param|
|
244
|
+
value = self.send(attr)
|
245
|
+
next if value.nil?
|
246
|
+
hash[param] = _to_hash(value)
|
247
|
+
end
|
248
|
+
hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Outputs non-array value in the form of hash
|
252
|
+
# For object, use to_hash. Otherwise, just return the value
|
253
|
+
# @param [Object] value Any valid value
|
254
|
+
# @return [Hash] Returns the value in the form of hash
|
255
|
+
def _to_hash(value)
|
256
|
+
if value.is_a?(Array)
|
257
|
+
value.compact.map{ |v| _to_hash(v) }
|
258
|
+
elsif value.is_a?(Hash)
|
259
|
+
{}.tap do |hash|
|
260
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
261
|
+
end
|
262
|
+
elsif value.respond_to? :to_hash
|
263
|
+
value.to_hash
|
264
|
+
else
|
265
|
+
value
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
@@ -0,0 +1,253 @@
|
|
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
|
+
# Text style
|
17
|
+
class TextStyleData
|
18
|
+
attr_accessor :color
|
19
|
+
|
20
|
+
attr_accessor :style
|
21
|
+
|
22
|
+
attr_accessor :font_name
|
23
|
+
|
24
|
+
attr_accessor :font_size
|
25
|
+
|
26
|
+
class EnumAttributeValidator
|
27
|
+
attr_reader :datatype
|
28
|
+
attr_reader :allowable_values
|
29
|
+
|
30
|
+
def initialize(datatype, allowable_values)
|
31
|
+
@allowable_values = allowable_values.map do |value|
|
32
|
+
case datatype.to_s
|
33
|
+
when /Integer/i
|
34
|
+
value.to_i
|
35
|
+
when /Float/i
|
36
|
+
value.to_f
|
37
|
+
else
|
38
|
+
value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def valid?(value)
|
44
|
+
!value || allowable_values.include?(value)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
49
|
+
def self.attribute_map
|
50
|
+
{
|
51
|
+
:'color' => :'Color',
|
52
|
+
:'style' => :'Style',
|
53
|
+
:'font_name' => :'FontName',
|
54
|
+
:'font_size' => :'FontSize'
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# Attribute type mapping.
|
59
|
+
def self.swagger_types
|
60
|
+
{
|
61
|
+
:'color' => :'String',
|
62
|
+
:'style' => :'String',
|
63
|
+
:'font_name' => :'String',
|
64
|
+
:'font_size' => :'Float'
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
# Initializes the object
|
69
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
70
|
+
def initialize(attributes = {})
|
71
|
+
return unless attributes.is_a?(Hash)
|
72
|
+
|
73
|
+
# convert string to symbol for hash key
|
74
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
75
|
+
|
76
|
+
if attributes.has_key?(:'Color')
|
77
|
+
self.color = attributes[:'Color']
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.has_key?(:'Style')
|
81
|
+
self.style = attributes[:'Style']
|
82
|
+
end
|
83
|
+
|
84
|
+
if attributes.has_key?(:'FontName')
|
85
|
+
self.font_name = attributes[:'FontName']
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.has_key?(:'FontSize')
|
89
|
+
self.font_size = attributes[:'FontSize']
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
95
|
+
# @return Array for valid properies with the reasons
|
96
|
+
def list_invalid_properties
|
97
|
+
invalid_properties = Array.new
|
98
|
+
if @style.nil?
|
99
|
+
invalid_properties.push("invalid value for 'style', style cannot be nil.")
|
100
|
+
end
|
101
|
+
|
102
|
+
return invalid_properties
|
103
|
+
end
|
104
|
+
|
105
|
+
# Check to see if the all the properties in the model are valid
|
106
|
+
# @return true if the model is valid
|
107
|
+
def valid?
|
108
|
+
return false if @style.nil?
|
109
|
+
style_validator = EnumAttributeValidator.new('String', ["Bold", "Italic", "Underline", "SmallCaps", "Undefined"])
|
110
|
+
return false unless style_validator.valid?(@style)
|
111
|
+
return true
|
112
|
+
end
|
113
|
+
|
114
|
+
# Custom attribute writer method checking allowed values (enum).
|
115
|
+
# @param [Object] style Object to be assigned
|
116
|
+
def style=(style)
|
117
|
+
validator = EnumAttributeValidator.new('String', ["Bold", "Italic", "Underline", "SmallCaps", "Undefined"])
|
118
|
+
unless validator.valid?(style)
|
119
|
+
fail ArgumentError, "invalid value for 'style', must be one of #{validator.allowable_values}."
|
120
|
+
end
|
121
|
+
@style = style
|
122
|
+
end
|
123
|
+
|
124
|
+
# Checks equality by comparing each attribute.
|
125
|
+
# @param [Object] Object to be compared
|
126
|
+
def ==(o)
|
127
|
+
return true if self.equal?(o)
|
128
|
+
self.class == o.class &&
|
129
|
+
color == o.color &&
|
130
|
+
style == o.style &&
|
131
|
+
font_name == o.font_name &&
|
132
|
+
font_size == o.font_size
|
133
|
+
end
|
134
|
+
|
135
|
+
# @see the `==` method
|
136
|
+
# @param [Object] Object to be compared
|
137
|
+
def eql?(o)
|
138
|
+
self == o
|
139
|
+
end
|
140
|
+
|
141
|
+
# Calculates hash code according to all attributes.
|
142
|
+
# @return [Fixnum] Hash code
|
143
|
+
def hash
|
144
|
+
[color, style, font_name, font_size].hash
|
145
|
+
end
|
146
|
+
|
147
|
+
# Builds the object from hash
|
148
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
149
|
+
# @return [Object] Returns the model itself
|
150
|
+
def build_from_hash(attributes)
|
151
|
+
return nil unless attributes.is_a?(Hash)
|
152
|
+
self.class.swagger_types.each_pair do |key, type|
|
153
|
+
if type =~ /\AArray<(.*)>/i
|
154
|
+
# check to ensure the input is an array given that the the attribute
|
155
|
+
# is documented as an array but the input is not
|
156
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
157
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
158
|
+
end
|
159
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
160
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
161
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
162
|
+
end
|
163
|
+
|
164
|
+
self
|
165
|
+
end
|
166
|
+
|
167
|
+
# Deserializes the data based on type
|
168
|
+
# @param string type Data type
|
169
|
+
# @param string value Value to be deserialized
|
170
|
+
# @return [Object] Deserialized data
|
171
|
+
def _deserialize(type, value)
|
172
|
+
case type.to_sym
|
173
|
+
when :DateTime
|
174
|
+
DateTime.parse(value)
|
175
|
+
when :Date
|
176
|
+
Date.parse(value)
|
177
|
+
when :String
|
178
|
+
value.to_s
|
179
|
+
when :Integer
|
180
|
+
value.to_i
|
181
|
+
when :Float
|
182
|
+
value.to_f
|
183
|
+
when :BOOLEAN
|
184
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
185
|
+
true
|
186
|
+
else
|
187
|
+
false
|
188
|
+
end
|
189
|
+
when :Object
|
190
|
+
# generic object (usually a Hash), return directly
|
191
|
+
value
|
192
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
193
|
+
inner_type = Regexp.last_match[:inner_type]
|
194
|
+
value.map { |v| _deserialize(inner_type, v) }
|
195
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
196
|
+
k_type = Regexp.last_match[:k_type]
|
197
|
+
v_type = Regexp.last_match[:v_type]
|
198
|
+
{}.tap do |hash|
|
199
|
+
value.each do |k, v|
|
200
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
else # model
|
204
|
+
temp_model = AsposeDiagramCloud.const_get(type).new
|
205
|
+
temp_model.build_from_hash(value)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Returns the string representation of the object
|
210
|
+
# @return [String] String presentation of the object
|
211
|
+
def to_s
|
212
|
+
to_hash.to_s
|
213
|
+
end
|
214
|
+
|
215
|
+
# to_body is an alias to to_hash (backward compatibility)
|
216
|
+
# @return [Hash] Returns the object in the form of hash
|
217
|
+
def to_body
|
218
|
+
to_hash
|
219
|
+
end
|
220
|
+
|
221
|
+
# Returns the object in the form of hash
|
222
|
+
# @return [Hash] Returns the object in the form of hash
|
223
|
+
def to_hash
|
224
|
+
hash = {}
|
225
|
+
self.class.attribute_map.each_pair do |attr, param|
|
226
|
+
value = self.send(attr)
|
227
|
+
next if value.nil?
|
228
|
+
hash[param] = _to_hash(value)
|
229
|
+
end
|
230
|
+
hash
|
231
|
+
end
|
232
|
+
|
233
|
+
# Outputs non-array value in the form of hash
|
234
|
+
# For object, use to_hash. Otherwise, just return the value
|
235
|
+
# @param [Object] value Any valid value
|
236
|
+
# @return [Hash] Returns the value in the form of hash
|
237
|
+
def _to_hash(value)
|
238
|
+
if value.is_a?(Array)
|
239
|
+
value.compact.map{ |v| _to_hash(v) }
|
240
|
+
elsif value.is_a?(Hash)
|
241
|
+
{}.tap do |hash|
|
242
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
243
|
+
end
|
244
|
+
elsif value.respond_to? :to_hash
|
245
|
+
value.to_hash
|
246
|
+
else
|
247
|
+
value
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
252
|
+
|
253
|
+
end
|