aspose_diagram_cloud 18.10.1 → 18.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +7 -0
- data/README.md +126 -0
- data/Rakefile +8 -0
- data/aspose_diagram_cloud-18.10.1.gem +0 -0
- data/aspose_diagram_cloud-18.10.gem +0 -0
- data/aspose_diagram_cloud.gemspec +46 -0
- data/docs/AccessTokenResponse.md +15 -0
- data/docs/DiagramFileApi.md +228 -0
- data/docs/DiagramModel.md +9 -0
- data/docs/DiagramResponse.md +10 -0
- data/docs/FileFormatRequest.md +8 -0
- data/docs/Link.md +11 -0
- data/docs/OAuthApi.md +60 -0
- data/docs/PageModel.md +9 -0
- data/docs/SaaSposeResponse.md +9 -0
- data/docs/SaveResponse.md +10 -0
- data/docs/SaveResult.md +10 -0
- data/docs/SharpModel.md +8 -0
- data/git_push.sh +55 -0
- data/lib/aspose_diagram_cloud.rb +51 -0
- data/lib/aspose_diagram_cloud/api/diagram_file_api.rb +284 -0
- data/lib/aspose_diagram_cloud/api/o_auth_api.rb +93 -0
- data/lib/aspose_diagram_cloud/api_client.rb +389 -0
- data/lib/aspose_diagram_cloud/api_error.rb +38 -0
- data/lib/aspose_diagram_cloud/configuration.rb +223 -0
- data/lib/aspose_diagram_cloud/models/access_token_response.rb +251 -0
- data/lib/aspose_diagram_cloud/models/diagram_model.rb +199 -0
- data/lib/aspose_diagram_cloud/models/diagram_response.rb +211 -0
- data/lib/aspose_diagram_cloud/models/file_format_request.rb +188 -0
- data/lib/aspose_diagram_cloud/models/link.rb +215 -0
- data/lib/aspose_diagram_cloud/models/page_model.rb +199 -0
- data/lib/aspose_diagram_cloud/models/saa_spose_response.rb +202 -0
- data/lib/aspose_diagram_cloud/models/save_response.rb +211 -0
- data/lib/aspose_diagram_cloud/models/save_result.rb +208 -0
- data/lib/aspose_diagram_cloud/models/sharp_model.rb +188 -0
- data/lib/aspose_diagram_cloud/version.rb +15 -0
- data/spec/api/diagram_file_api_spec.rb +126 -0
- data/spec/api/o_auth_api_spec.rb +56 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/access_token_response_spec.rb +84 -0
- data/spec/models/diagram_model_spec.rb +48 -0
- data/spec/models/diagram_response_spec.rb +54 -0
- data/spec/models/file_format_request_spec.rb +42 -0
- data/spec/models/link_spec.rb +60 -0
- data/spec/models/page_model_spec.rb +48 -0
- data/spec/models/saa_spose_response_spec.rb +48 -0
- data/spec/models/save_response_spec.rb +54 -0
- data/spec/models/save_result_spec.rb +54 -0
- data/spec/models/sharp_model_spec.rb +42 -0
- data/spec/spec_helper.rb +116 -0
- metadata +108 -42
@@ -0,0 +1,38 @@
|
|
1
|
+
=begin
|
2
|
+
#Web API Swagger specification
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.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
|
+
module AsposeDiagramCloud
|
14
|
+
class ApiError < StandardError
|
15
|
+
attr_reader :code, :response_headers, :response_body
|
16
|
+
|
17
|
+
# Usage examples:
|
18
|
+
# ApiError.new
|
19
|
+
# ApiError.new("message")
|
20
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
21
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
22
|
+
def initialize(arg = nil)
|
23
|
+
if arg.is_a? Hash
|
24
|
+
if arg.key?(:message) || arg.key?('message')
|
25
|
+
super(arg[:message] || arg['message'])
|
26
|
+
else
|
27
|
+
super arg
|
28
|
+
end
|
29
|
+
|
30
|
+
arg.each do |k, v|
|
31
|
+
instance_variable_set "@#{k}", v
|
32
|
+
end
|
33
|
+
else
|
34
|
+
super arg
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
=begin
|
2
|
+
#Web API Swagger specification
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.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 'uri'
|
14
|
+
|
15
|
+
module AsposeDiagramCloud
|
16
|
+
class Configuration
|
17
|
+
# Defines url scheme
|
18
|
+
attr_accessor :scheme
|
19
|
+
|
20
|
+
# Defines url host
|
21
|
+
attr_accessor :host
|
22
|
+
|
23
|
+
# Defines url base path
|
24
|
+
attr_accessor :base_path
|
25
|
+
|
26
|
+
# Defines API keys used with API Key authentications.
|
27
|
+
#
|
28
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
29
|
+
#
|
30
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
31
|
+
# config.api_key['api_key'] = 'xxx'
|
32
|
+
attr_accessor :api_key
|
33
|
+
|
34
|
+
# Defines API key prefixes used with API Key authentications.
|
35
|
+
#
|
36
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
37
|
+
#
|
38
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
39
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
40
|
+
attr_accessor :api_key_prefix
|
41
|
+
|
42
|
+
# Defines the username used with HTTP basic authentication.
|
43
|
+
#
|
44
|
+
# @return [String]
|
45
|
+
attr_accessor :username
|
46
|
+
|
47
|
+
# Defines the password used with HTTP basic authentication.
|
48
|
+
#
|
49
|
+
# @return [String]
|
50
|
+
attr_accessor :password
|
51
|
+
|
52
|
+
# Defines the access token (Bearer) used with OAuth2.
|
53
|
+
attr_accessor :access_token
|
54
|
+
|
55
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
56
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
57
|
+
# Default to false.
|
58
|
+
#
|
59
|
+
# @return [true, false]
|
60
|
+
attr_accessor :debugging
|
61
|
+
|
62
|
+
# Defines the logger used for debugging.
|
63
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
64
|
+
#
|
65
|
+
# @return [#debug]
|
66
|
+
attr_accessor :logger
|
67
|
+
|
68
|
+
# Defines the temporary folder to store downloaded files
|
69
|
+
# (for API endpoints that have file response).
|
70
|
+
# Default to use `Tempfile`.
|
71
|
+
#
|
72
|
+
# @return [String]
|
73
|
+
attr_accessor :temp_folder_path
|
74
|
+
|
75
|
+
# The time limit for HTTP request in seconds.
|
76
|
+
# Default to 0 (never times out).
|
77
|
+
attr_accessor :timeout
|
78
|
+
|
79
|
+
# Set this to false to skip client side validation in the operation.
|
80
|
+
# Default to true.
|
81
|
+
# @return [true, false]
|
82
|
+
attr_accessor :client_side_validation
|
83
|
+
|
84
|
+
### TLS/SSL setting
|
85
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
86
|
+
# Default to true.
|
87
|
+
#
|
88
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
89
|
+
#
|
90
|
+
# @return [true, false]
|
91
|
+
attr_accessor :verify_ssl
|
92
|
+
|
93
|
+
### TLS/SSL setting
|
94
|
+
# Set this to false to skip verifying SSL host name
|
95
|
+
# Default to true.
|
96
|
+
#
|
97
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
98
|
+
#
|
99
|
+
# @return [true, false]
|
100
|
+
attr_accessor :verify_ssl_host
|
101
|
+
|
102
|
+
### TLS/SSL setting
|
103
|
+
# Set this to customize the certificate file to verify the peer.
|
104
|
+
#
|
105
|
+
# @return [String] the path to the certificate file
|
106
|
+
#
|
107
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
108
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
109
|
+
attr_accessor :ssl_ca_cert
|
110
|
+
|
111
|
+
### TLS/SSL setting
|
112
|
+
# Client certificate file (for client certificate)
|
113
|
+
attr_accessor :cert_file
|
114
|
+
|
115
|
+
### TLS/SSL setting
|
116
|
+
# Client private key file (for client certificate)
|
117
|
+
attr_accessor :key_file
|
118
|
+
|
119
|
+
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
120
|
+
# Default to nil.
|
121
|
+
#
|
122
|
+
# @see The params_encoding option of Ethon. Related source code:
|
123
|
+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
124
|
+
attr_accessor :params_encoding
|
125
|
+
|
126
|
+
attr_accessor :inject_format
|
127
|
+
|
128
|
+
attr_accessor :force_ending_format
|
129
|
+
|
130
|
+
def initialize
|
131
|
+
@scheme = 'https'
|
132
|
+
@host = 'api.aspose.cloud'
|
133
|
+
@base_path = '/v1.1/'
|
134
|
+
@api_key = {}
|
135
|
+
@api_key_prefix = {}
|
136
|
+
@timeout = 0
|
137
|
+
@client_side_validation = true
|
138
|
+
@verify_ssl = true
|
139
|
+
@verify_ssl_host = true
|
140
|
+
@params_encoding = nil
|
141
|
+
@cert_file = nil
|
142
|
+
@key_file = nil
|
143
|
+
@debugging = false
|
144
|
+
@inject_format = false
|
145
|
+
@force_ending_format = false
|
146
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
147
|
+
|
148
|
+
yield(self) if block_given?
|
149
|
+
end
|
150
|
+
|
151
|
+
# The default Configuration object.
|
152
|
+
def self.default
|
153
|
+
@@default ||= Configuration.new
|
154
|
+
end
|
155
|
+
|
156
|
+
def configure
|
157
|
+
yield(self) if block_given?
|
158
|
+
end
|
159
|
+
|
160
|
+
def scheme=(scheme)
|
161
|
+
# remove :// from scheme
|
162
|
+
@scheme = scheme.sub(/:\/\//, '')
|
163
|
+
end
|
164
|
+
|
165
|
+
def host=(host)
|
166
|
+
# remove http(s):// and anything after a slash
|
167
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
168
|
+
end
|
169
|
+
|
170
|
+
def base_path=(base_path)
|
171
|
+
# Add leading and trailing slashes to base_path
|
172
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
173
|
+
@base_path = "" if @base_path == "/"
|
174
|
+
end
|
175
|
+
|
176
|
+
def base_url
|
177
|
+
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
178
|
+
URI.encode(url)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Gets API key (with prefix if set).
|
182
|
+
# @param [String] param_name the parameter name of API key auth
|
183
|
+
def api_key_with_prefix(param_name)
|
184
|
+
if @api_key_prefix[param_name]
|
185
|
+
"#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
|
186
|
+
else
|
187
|
+
@api_key[param_name]
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Gets Basic Auth token string
|
192
|
+
def basic_auth_token
|
193
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns Auth Settings hash for api client.
|
197
|
+
def auth_settings
|
198
|
+
{
|
199
|
+
'appsid' =>
|
200
|
+
{
|
201
|
+
type: 'api_key',
|
202
|
+
in: 'query',
|
203
|
+
key: 'appsid',
|
204
|
+
value: api_key_with_prefix('appsid')
|
205
|
+
},
|
206
|
+
'oauth' =>
|
207
|
+
{
|
208
|
+
type: 'oauth2',
|
209
|
+
in: 'header',
|
210
|
+
key: 'Authorization',
|
211
|
+
value: "Bearer #{access_token}"
|
212
|
+
},
|
213
|
+
'signature' =>
|
214
|
+
{
|
215
|
+
type: 'api_key',
|
216
|
+
in: 'query',
|
217
|
+
key: 'signature',
|
218
|
+
value: api_key_with_prefix('signature')
|
219
|
+
},
|
220
|
+
}
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
@@ -0,0 +1,251 @@
|
|
1
|
+
=begin
|
2
|
+
#Web API Swagger specification
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.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 AccessTokenResponse
|
18
|
+
attr_accessor :_expires
|
19
|
+
|
20
|
+
attr_accessor :access_token
|
21
|
+
|
22
|
+
attr_accessor :_issued
|
23
|
+
|
24
|
+
attr_accessor :client_refresh_token_life_time_in_minutes
|
25
|
+
|
26
|
+
attr_accessor :expires_in
|
27
|
+
|
28
|
+
attr_accessor :token_type
|
29
|
+
|
30
|
+
attr_accessor :client_id
|
31
|
+
|
32
|
+
attr_accessor :refresh_token
|
33
|
+
|
34
|
+
|
35
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
36
|
+
def self.attribute_map
|
37
|
+
{
|
38
|
+
:'_expires' => :'.expires',
|
39
|
+
:'access_token' => :'access_token',
|
40
|
+
:'_issued' => :'.issued',
|
41
|
+
:'client_refresh_token_life_time_in_minutes' => :'clientRefreshTokenLifeTimeInMinutes',
|
42
|
+
:'expires_in' => :'expires_in',
|
43
|
+
:'token_type' => :'token_type',
|
44
|
+
:'client_id' => :'client_id',
|
45
|
+
:'refresh_token' => :'refresh_token'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Attribute type mapping.
|
50
|
+
def self.swagger_types
|
51
|
+
{
|
52
|
+
:'_expires' => :'String',
|
53
|
+
:'access_token' => :'String',
|
54
|
+
:'_issued' => :'String',
|
55
|
+
:'client_refresh_token_life_time_in_minutes' => :'String',
|
56
|
+
:'expires_in' => :'Integer',
|
57
|
+
:'token_type' => :'String',
|
58
|
+
:'client_id' => :'String',
|
59
|
+
:'refresh_token' => :'String'
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
# Initializes the object
|
64
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
65
|
+
def initialize(attributes = {})
|
66
|
+
return unless attributes.is_a?(Hash)
|
67
|
+
|
68
|
+
# convert string to symbol for hash key
|
69
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
70
|
+
|
71
|
+
if attributes.has_key?(:'.expires')
|
72
|
+
self._expires = attributes[:'.expires']
|
73
|
+
end
|
74
|
+
|
75
|
+
if attributes.has_key?(:'access_token')
|
76
|
+
self.access_token = attributes[:'access_token']
|
77
|
+
end
|
78
|
+
|
79
|
+
if attributes.has_key?(:'.issued')
|
80
|
+
self._issued = attributes[:'.issued']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.has_key?(:'clientRefreshTokenLifeTimeInMinutes')
|
84
|
+
self.client_refresh_token_life_time_in_minutes = attributes[:'clientRefreshTokenLifeTimeInMinutes']
|
85
|
+
end
|
86
|
+
|
87
|
+
if attributes.has_key?(:'expires_in')
|
88
|
+
self.expires_in = attributes[:'expires_in']
|
89
|
+
end
|
90
|
+
|
91
|
+
if attributes.has_key?(:'token_type')
|
92
|
+
self.token_type = attributes[:'token_type']
|
93
|
+
end
|
94
|
+
|
95
|
+
if attributes.has_key?(:'client_id')
|
96
|
+
self.client_id = attributes[:'client_id']
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.has_key?(:'refresh_token')
|
100
|
+
self.refresh_token = attributes[:'refresh_token']
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
106
|
+
# @return Array for valid properies with the reasons
|
107
|
+
def list_invalid_properties
|
108
|
+
invalid_properties = Array.new
|
109
|
+
return invalid_properties
|
110
|
+
end
|
111
|
+
|
112
|
+
# Check to see if the all the properties in the model are valid
|
113
|
+
# @return true if the model is valid
|
114
|
+
def valid?
|
115
|
+
return true
|
116
|
+
end
|
117
|
+
|
118
|
+
# Checks equality by comparing each attribute.
|
119
|
+
# @param [Object] Object to be compared
|
120
|
+
def ==(o)
|
121
|
+
return true if self.equal?(o)
|
122
|
+
self.class == o.class &&
|
123
|
+
_expires == o._expires &&
|
124
|
+
access_token == o.access_token &&
|
125
|
+
_issued == o._issued &&
|
126
|
+
client_refresh_token_life_time_in_minutes == o.client_refresh_token_life_time_in_minutes &&
|
127
|
+
expires_in == o.expires_in &&
|
128
|
+
token_type == o.token_type &&
|
129
|
+
client_id == o.client_id &&
|
130
|
+
refresh_token == o.refresh_token
|
131
|
+
end
|
132
|
+
|
133
|
+
# @see the `==` method
|
134
|
+
# @param [Object] Object to be compared
|
135
|
+
def eql?(o)
|
136
|
+
self == o
|
137
|
+
end
|
138
|
+
|
139
|
+
# Calculates hash code according to all attributes.
|
140
|
+
# @return [Fixnum] Hash code
|
141
|
+
def hash
|
142
|
+
[_expires, access_token, _issued, client_refresh_token_life_time_in_minutes, expires_in, token_type, client_id, refresh_token].hash
|
143
|
+
end
|
144
|
+
|
145
|
+
# Builds the object from hash
|
146
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
147
|
+
# @return [Object] Returns the model itself
|
148
|
+
def build_from_hash(attributes)
|
149
|
+
return nil unless attributes.is_a?(Hash)
|
150
|
+
self.class.swagger_types.each_pair do |key, type|
|
151
|
+
if type =~ /\AArray<(.*)>/i
|
152
|
+
# check to ensure the input is an array given that the the attribute
|
153
|
+
# is documented as an array but the input is not
|
154
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
155
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
156
|
+
end
|
157
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
158
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
159
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
160
|
+
end
|
161
|
+
|
162
|
+
self
|
163
|
+
end
|
164
|
+
|
165
|
+
# Deserializes the data based on type
|
166
|
+
# @param string type Data type
|
167
|
+
# @param string value Value to be deserialized
|
168
|
+
# @return [Object] Deserialized data
|
169
|
+
def _deserialize(type, value)
|
170
|
+
case type.to_sym
|
171
|
+
when :DateTime
|
172
|
+
DateTime.parse(value)
|
173
|
+
when :Date
|
174
|
+
Date.parse(value)
|
175
|
+
when :String
|
176
|
+
value.to_s
|
177
|
+
when :Integer
|
178
|
+
value.to_i
|
179
|
+
when :Float
|
180
|
+
value.to_f
|
181
|
+
when :BOOLEAN
|
182
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
183
|
+
true
|
184
|
+
else
|
185
|
+
false
|
186
|
+
end
|
187
|
+
when :Object
|
188
|
+
# generic object (usually a Hash), return directly
|
189
|
+
value
|
190
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
191
|
+
inner_type = Regexp.last_match[:inner_type]
|
192
|
+
value.map { |v| _deserialize(inner_type, v) }
|
193
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
194
|
+
k_type = Regexp.last_match[:k_type]
|
195
|
+
v_type = Regexp.last_match[:v_type]
|
196
|
+
{}.tap do |hash|
|
197
|
+
value.each do |k, v|
|
198
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
else # model
|
202
|
+
temp_model = AsposeDiagramCloud.const_get(type).new
|
203
|
+
temp_model.build_from_hash(value)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# Returns the string representation of the object
|
208
|
+
# @return [String] String presentation of the object
|
209
|
+
def to_s
|
210
|
+
to_hash.to_s
|
211
|
+
end
|
212
|
+
|
213
|
+
# to_body is an alias to to_hash (backward compatibility)
|
214
|
+
# @return [Hash] Returns the object in the form of hash
|
215
|
+
def to_body
|
216
|
+
to_hash
|
217
|
+
end
|
218
|
+
|
219
|
+
# Returns the object in the form of hash
|
220
|
+
# @return [Hash] Returns the object in the form of hash
|
221
|
+
def to_hash
|
222
|
+
hash = {}
|
223
|
+
self.class.attribute_map.each_pair do |attr, param|
|
224
|
+
value = self.send(attr)
|
225
|
+
next if value.nil?
|
226
|
+
hash[param] = _to_hash(value)
|
227
|
+
end
|
228
|
+
hash
|
229
|
+
end
|
230
|
+
|
231
|
+
# Outputs non-array value in the form of hash
|
232
|
+
# For object, use to_hash. Otherwise, just return the value
|
233
|
+
# @param [Object] value Any valid value
|
234
|
+
# @return [Hash] Returns the value in the form of hash
|
235
|
+
def _to_hash(value)
|
236
|
+
if value.is_a?(Array)
|
237
|
+
value.compact.map{ |v| _to_hash(v) }
|
238
|
+
elsif value.is_a?(Hash)
|
239
|
+
{}.tap do |hash|
|
240
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
241
|
+
end
|
242
|
+
elsif value.respond_to? :to_hash
|
243
|
+
value.to_hash
|
244
|
+
else
|
245
|
+
value
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|