webapi-active-query-builder 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +201 -0
- data/README.md +55 -0
- data/docs/ActiveQueryBuilderApi.md +102 -0
- data/docs/Condition.md +10 -0
- data/docs/ConditionGroup.md +10 -0
- data/docs/HiddenColumn.md +8 -0
- data/docs/Pagination.md +9 -0
- data/docs/QueryColumn.md +9 -0
- data/docs/Sorting.md +9 -0
- data/docs/SqlQuery.md +9 -0
- data/docs/Totals.md +9 -0
- data/docs/Transform.md +14 -0
- data/docs/TransformResult.md +10 -0
- data/git_push.sh +67 -0
- data/lib/webapi-active-query-builder.rb +61 -0
- data/lib/webapi-active-query-builder/api/active_query_builder_api.rb +148 -0
- data/lib/webapi-active-query-builder/api_client.rb +378 -0
- data/lib/webapi-active-query-builder/api_error.rb +47 -0
- data/lib/webapi-active-query-builder/configuration.rb +207 -0
- data/lib/webapi-active-query-builder/models/condition.rb +255 -0
- data/lib/webapi-active-query-builder/models/condition_group.rb +257 -0
- data/lib/webapi-active-query-builder/models/hidden_column.rb +200 -0
- data/lib/webapi-active-query-builder/models/pagination.rb +210 -0
- data/lib/webapi-active-query-builder/models/query_column.rb +210 -0
- data/lib/webapi-active-query-builder/models/sorting.rb +243 -0
- data/lib/webapi-active-query-builder/models/sql_query.rb +210 -0
- data/lib/webapi-active-query-builder/models/totals.rb +243 -0
- data/lib/webapi-active-query-builder/models/transform.rb +261 -0
- data/lib/webapi-active-query-builder/models/transform_result.rb +220 -0
- data/lib/webapi-active-query-builder/version.rb +26 -0
- data/spec/api/active_query_builder_api_spec.rb +70 -0
- data/spec/api_client_spec.rb +237 -0
- data/spec/configuration_spec.rb +53 -0
- data/spec/models/condition_group_spec.rb +69 -0
- data/spec/models/condition_spec.rb +69 -0
- data/spec/models/hidden_column_spec.rb +53 -0
- data/spec/models/pagination_spec.rb +59 -0
- data/spec/models/query_column_spec.rb +59 -0
- data/spec/models/sorting_spec.rb +63 -0
- data/spec/models/sql_query_spec.rb +59 -0
- data/spec/models/totals_spec.rb +63 -0
- data/spec/models/transform_result_spec.rb +65 -0
- data/spec/models/transform_spec.rb +89 -0
- data/spec/spec_helper.rb +122 -0
- data/webapi-active-query-builder.gemspec +55 -0
- metadata +307 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
=begin
|
2
|
+
#QueryBuilderApi
|
3
|
+
|
4
|
+
#Active Query Builder Web API lets create, analyze and modify SQL queries for different database servers using RESTful HTTP requests to a cloud-based service. It requires SQL execution context (information about database schema and used database server) to be stored under the registered account at https://webapi.activequerybuilder.com/.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.1.3
|
7
|
+
Contact: support@activedbsoft.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
you may not use this file except in compliance with the License.
|
12
|
+
You may obtain a copy of the License at
|
13
|
+
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
See the License for the specific language governing permissions and
|
20
|
+
limitations under the License.
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
24
|
+
module WebApiActivequerybuilder
|
25
|
+
class ApiError < StandardError
|
26
|
+
attr_reader :code, :response_headers, :response_body
|
27
|
+
|
28
|
+
# Usage examples:
|
29
|
+
# ApiError.new
|
30
|
+
# ApiError.new("message")
|
31
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
32
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
33
|
+
def initialize(arg = nil)
|
34
|
+
if arg.is_a? Hash
|
35
|
+
arg.each do |k, v|
|
36
|
+
if k.to_s == 'message'
|
37
|
+
super v
|
38
|
+
else
|
39
|
+
instance_variable_set "@#{k}", v
|
40
|
+
end
|
41
|
+
end
|
42
|
+
else
|
43
|
+
super arg
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
=begin
|
2
|
+
#QueryBuilderApi
|
3
|
+
|
4
|
+
#Active Query Builder Web API lets create, analyze and modify SQL queries for different database servers using RESTful HTTP requests to a cloud-based service. It requires SQL execution context (information about database schema and used database server) to be stored under the registered account at https://webapi.activequerybuilder.com/.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.1.3
|
7
|
+
Contact: support@activedbsoft.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
you may not use this file except in compliance with the License.
|
12
|
+
You may obtain a copy of the License at
|
13
|
+
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
See the License for the specific language governing permissions and
|
20
|
+
limitations under the License.
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'uri'
|
25
|
+
|
26
|
+
module WebApiActivequerybuilder
|
27
|
+
class Configuration
|
28
|
+
# Defines url scheme
|
29
|
+
attr_accessor :scheme
|
30
|
+
|
31
|
+
# Defines url host
|
32
|
+
attr_accessor :host
|
33
|
+
|
34
|
+
# Defines url base path
|
35
|
+
attr_accessor :base_path
|
36
|
+
|
37
|
+
# Defines API keys used with API Key authentications.
|
38
|
+
#
|
39
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
40
|
+
#
|
41
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
42
|
+
# config.api_key['api_key'] = 'xxx'
|
43
|
+
attr_accessor :api_key
|
44
|
+
|
45
|
+
# Defines API key prefixes used with API Key authentications.
|
46
|
+
#
|
47
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
48
|
+
#
|
49
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
50
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
51
|
+
attr_accessor :api_key_prefix
|
52
|
+
|
53
|
+
# Defines the username used with HTTP basic authentication.
|
54
|
+
#
|
55
|
+
# @return [String]
|
56
|
+
attr_accessor :username
|
57
|
+
|
58
|
+
# Defines the password used with HTTP basic authentication.
|
59
|
+
#
|
60
|
+
# @return [String]
|
61
|
+
attr_accessor :password
|
62
|
+
|
63
|
+
# Defines the access token (Bearer) used with OAuth2.
|
64
|
+
attr_accessor :access_token
|
65
|
+
|
66
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
67
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
68
|
+
# Default to false.
|
69
|
+
#
|
70
|
+
# @return [true, false]
|
71
|
+
attr_accessor :debugging
|
72
|
+
|
73
|
+
# Defines the logger used for debugging.
|
74
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
75
|
+
#
|
76
|
+
# @return [#debug]
|
77
|
+
attr_accessor :logger
|
78
|
+
|
79
|
+
# Defines the temporary folder to store downloaded files
|
80
|
+
# (for API endpoints that have file response).
|
81
|
+
# Default to use `Tempfile`.
|
82
|
+
#
|
83
|
+
# @return [String]
|
84
|
+
attr_accessor :temp_folder_path
|
85
|
+
|
86
|
+
# The time limit for HTTP request in seconds.
|
87
|
+
# Default to 0 (never times out).
|
88
|
+
attr_accessor :timeout
|
89
|
+
|
90
|
+
### TLS/SSL setting
|
91
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
92
|
+
# Default to true.
|
93
|
+
#
|
94
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
95
|
+
#
|
96
|
+
# @return [true, false]
|
97
|
+
attr_accessor :verify_ssl
|
98
|
+
|
99
|
+
### TLS/SSL setting
|
100
|
+
# Set this to false to skip verifying SSL host name
|
101
|
+
# Default to true.
|
102
|
+
#
|
103
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
104
|
+
#
|
105
|
+
# @return [true, false]
|
106
|
+
attr_accessor :verify_ssl_host
|
107
|
+
|
108
|
+
### TLS/SSL setting
|
109
|
+
# Set this to customize the certificate file to verify the peer.
|
110
|
+
#
|
111
|
+
# @return [String] the path to the certificate file
|
112
|
+
#
|
113
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
114
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
115
|
+
attr_accessor :ssl_ca_cert
|
116
|
+
|
117
|
+
### TLS/SSL setting
|
118
|
+
# Client certificate file (for client certificate)
|
119
|
+
attr_accessor :cert_file
|
120
|
+
|
121
|
+
### TLS/SSL setting
|
122
|
+
# Client private key file (for client certificate)
|
123
|
+
attr_accessor :key_file
|
124
|
+
|
125
|
+
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
126
|
+
# Default to nil.
|
127
|
+
#
|
128
|
+
# @see The params_encoding option of Ethon. Related source code:
|
129
|
+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
130
|
+
attr_accessor :params_encoding
|
131
|
+
|
132
|
+
attr_accessor :inject_format
|
133
|
+
|
134
|
+
attr_accessor :force_ending_format
|
135
|
+
|
136
|
+
def initialize
|
137
|
+
@scheme = 'https'
|
138
|
+
@host = 'webapi.activequerybuilder.com'
|
139
|
+
@base_path = ''
|
140
|
+
@api_key = {}
|
141
|
+
@api_key_prefix = {}
|
142
|
+
@timeout = 0
|
143
|
+
@verify_ssl = true
|
144
|
+
@verify_ssl_host = true
|
145
|
+
@params_encoding = nil
|
146
|
+
@cert_file = nil
|
147
|
+
@key_file = nil
|
148
|
+
@debugging = false
|
149
|
+
@inject_format = false
|
150
|
+
@force_ending_format = false
|
151
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
152
|
+
|
153
|
+
yield(self) if block_given?
|
154
|
+
end
|
155
|
+
|
156
|
+
# The default Configuration object.
|
157
|
+
def self.default
|
158
|
+
@@default ||= Configuration.new
|
159
|
+
end
|
160
|
+
|
161
|
+
def configure
|
162
|
+
yield(self) if block_given?
|
163
|
+
end
|
164
|
+
|
165
|
+
def scheme=(scheme)
|
166
|
+
# remove :// from scheme
|
167
|
+
@scheme = scheme.sub(/:\/\//, '')
|
168
|
+
end
|
169
|
+
|
170
|
+
def host=(host)
|
171
|
+
# remove http(s):// and anything after a slash
|
172
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
173
|
+
end
|
174
|
+
|
175
|
+
def base_path=(base_path)
|
176
|
+
# Add leading and trailing slashes to base_path
|
177
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
178
|
+
@base_path = "" if @base_path == "/"
|
179
|
+
end
|
180
|
+
|
181
|
+
def base_url
|
182
|
+
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
183
|
+
URI.encode(url)
|
184
|
+
end
|
185
|
+
|
186
|
+
# Gets API key (with prefix if set).
|
187
|
+
# @param [String] param_name the parameter name of API key auth
|
188
|
+
def api_key_with_prefix(param_name)
|
189
|
+
if @api_key_prefix[param_name]
|
190
|
+
"#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
|
191
|
+
else
|
192
|
+
@api_key[param_name]
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# Gets Basic Auth token string
|
197
|
+
def basic_auth_token
|
198
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns Auth Settings hash for api client.
|
202
|
+
def auth_settings
|
203
|
+
{
|
204
|
+
}
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
=begin
|
2
|
+
#QueryBuilderApi
|
3
|
+
|
4
|
+
#Active Query Builder Web API lets create, analyze and modify SQL queries for different database servers using RESTful HTTP requests to a cloud-based service. It requires SQL execution context (information about database schema and used database server) to be stored under the registered account at https://webapi.activequerybuilder.com/.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.1.3
|
7
|
+
Contact: support@activedbsoft.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
you may not use this file except in compliance with the License.
|
12
|
+
You may obtain a copy of the License at
|
13
|
+
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
|
16
|
+
Unless required by applicable law or agreed to in writing, software
|
17
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
See the License for the specific language governing permissions and
|
20
|
+
limitations under the License.
|
21
|
+
|
22
|
+
=end
|
23
|
+
|
24
|
+
require 'date'
|
25
|
+
|
26
|
+
module WebApiActivequerybuilder
|
27
|
+
# Defines a constraint for original query resultset values.
|
28
|
+
class Condition
|
29
|
+
# Column of original query to which a constraint will applied.
|
30
|
+
attr_accessor :field
|
31
|
+
|
32
|
+
# Condition operator.
|
33
|
+
attr_accessor :condition_operator
|
34
|
+
|
35
|
+
# List of values for a constraint. \"IsNull\", \"IsNotNull\" need no values; \"Between\", \"NotBetween\" require 2 values; \"In\" accepts one or more values; other conditions accept single value only.
|
36
|
+
attr_accessor :values
|
37
|
+
|
38
|
+
class EnumAttributeValidator
|
39
|
+
attr_reader :datatype
|
40
|
+
attr_reader :allowable_values
|
41
|
+
|
42
|
+
def initialize(datatype, allowable_values)
|
43
|
+
@allowable_values = allowable_values.map do |value|
|
44
|
+
case datatype.to_s
|
45
|
+
when /Integer/i
|
46
|
+
value.to_i
|
47
|
+
when /Float/i
|
48
|
+
value.to_f
|
49
|
+
else
|
50
|
+
value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def valid?(value)
|
56
|
+
!value || allowable_values.include?(value)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
61
|
+
def self.attribute_map
|
62
|
+
{
|
63
|
+
:'field' => :'field',
|
64
|
+
:'condition_operator' => :'conditionOperator',
|
65
|
+
:'values' => :'values'
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
# Attribute type mapping.
|
70
|
+
def self.swagger_types
|
71
|
+
{
|
72
|
+
:'field' => :'String',
|
73
|
+
:'condition_operator' => :'String',
|
74
|
+
:'values' => :'Array<String>'
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
# Initializes the object
|
79
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
80
|
+
def initialize(attributes = {})
|
81
|
+
return unless attributes.is_a?(Hash)
|
82
|
+
|
83
|
+
# convert string to symbol for hash key
|
84
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
85
|
+
|
86
|
+
if attributes.has_key?(:'field')
|
87
|
+
self.field = attributes[:'field']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.has_key?(:'conditionOperator')
|
91
|
+
self.condition_operator = attributes[:'conditionOperator']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.has_key?(:'values')
|
95
|
+
if (value = attributes[:'values']).is_a?(Array)
|
96
|
+
self.values = value
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
103
|
+
# @return Array for valid properies with the reasons
|
104
|
+
def list_invalid_properties
|
105
|
+
invalid_properties = Array.new
|
106
|
+
return invalid_properties
|
107
|
+
end
|
108
|
+
|
109
|
+
# Check to see if the all the properties in the model are valid
|
110
|
+
# @return true if the model is valid
|
111
|
+
def valid?
|
112
|
+
condition_operator_validator = EnumAttributeValidator.new('String', ["IsNull", "IsNotNull", "Equal", "NotEqual", "Less", "NotLess", "LessEqual", "NotLessEqual", "Greater", "NotGreater", "GreaterEqual", "NotGreaterEqual", "Between", "NotBetween", "In", "NotIn", "Like", "NotLike"])
|
113
|
+
return false unless condition_operator_validator.valid?(@condition_operator)
|
114
|
+
return true
|
115
|
+
end
|
116
|
+
|
117
|
+
# Custom attribute writer method checking allowed values (enum).
|
118
|
+
# @param [Object] condition_operator Object to be assigned
|
119
|
+
def condition_operator=(condition_operator)
|
120
|
+
validator = EnumAttributeValidator.new('String', ["IsNull", "IsNotNull", "Equal", "NotEqual", "Less", "NotLess", "LessEqual", "NotLessEqual", "Greater", "NotGreater", "GreaterEqual", "NotGreaterEqual", "Between", "NotBetween", "In", "NotIn", "Like", "NotLike"])
|
121
|
+
unless validator.valid?(condition_operator)
|
122
|
+
fail ArgumentError, "invalid value for 'condition_operator', must be one of #{validator.allowable_values}."
|
123
|
+
end
|
124
|
+
@condition_operator = condition_operator
|
125
|
+
end
|
126
|
+
|
127
|
+
# Checks equality by comparing each attribute.
|
128
|
+
# @param [Object] Object to be compared
|
129
|
+
def ==(o)
|
130
|
+
return true if self.equal?(o)
|
131
|
+
self.class == o.class &&
|
132
|
+
field == o.field &&
|
133
|
+
condition_operator == o.condition_operator &&
|
134
|
+
values == o.values
|
135
|
+
end
|
136
|
+
|
137
|
+
# @see the `==` method
|
138
|
+
# @param [Object] Object to be compared
|
139
|
+
def eql?(o)
|
140
|
+
self == o
|
141
|
+
end
|
142
|
+
|
143
|
+
# Calculates hash code according to all attributes.
|
144
|
+
# @return [Fixnum] Hash code
|
145
|
+
def hash
|
146
|
+
[field, condition_operator, values].hash
|
147
|
+
end
|
148
|
+
|
149
|
+
# Builds the object from hash
|
150
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
151
|
+
# @return [Object] Returns the model itself
|
152
|
+
def build_from_hash(attributes)
|
153
|
+
return nil unless attributes.is_a?(Hash)
|
154
|
+
self.class.swagger_types.each_pair do |key, type|
|
155
|
+
if type =~ /^Array<(.*)>/i
|
156
|
+
# check to ensure the input is an array given that the the attribute
|
157
|
+
# is documented as an array but the input is not
|
158
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
159
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
160
|
+
end
|
161
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
162
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
163
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
164
|
+
end
|
165
|
+
|
166
|
+
self
|
167
|
+
end
|
168
|
+
|
169
|
+
# Deserializes the data based on type
|
170
|
+
# @param string type Data type
|
171
|
+
# @param string value Value to be deserialized
|
172
|
+
# @return [Object] Deserialized data
|
173
|
+
def _deserialize(type, value)
|
174
|
+
case type.to_sym
|
175
|
+
when :DateTime
|
176
|
+
DateTime.parse(value)
|
177
|
+
when :Date
|
178
|
+
Date.parse(value)
|
179
|
+
when :String
|
180
|
+
value.to_s
|
181
|
+
when :Integer
|
182
|
+
value.to_i
|
183
|
+
when :Float
|
184
|
+
value.to_f
|
185
|
+
when :BOOLEAN
|
186
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
187
|
+
true
|
188
|
+
else
|
189
|
+
false
|
190
|
+
end
|
191
|
+
when :Object
|
192
|
+
# generic object (usually a Hash), return directly
|
193
|
+
value
|
194
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
195
|
+
inner_type = Regexp.last_match[:inner_type]
|
196
|
+
value.map { |v| _deserialize(inner_type, v) }
|
197
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
198
|
+
k_type = Regexp.last_match[:k_type]
|
199
|
+
v_type = Regexp.last_match[:v_type]
|
200
|
+
{}.tap do |hash|
|
201
|
+
value.each do |k, v|
|
202
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
else # model
|
206
|
+
temp_model = WebApiActivequerybuilder.const_get(type).new
|
207
|
+
temp_model.build_from_hash(value)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns the string representation of the object
|
212
|
+
# @return [String] String presentation of the object
|
213
|
+
def to_s
|
214
|
+
to_hash.to_s
|
215
|
+
end
|
216
|
+
|
217
|
+
# to_body is an alias to to_hash (backward compatibility)
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
219
|
+
def to_body
|
220
|
+
to_hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the object in the form of hash
|
224
|
+
# @return [Hash] Returns the object in the form of hash
|
225
|
+
def to_hash
|
226
|
+
hash = {}
|
227
|
+
self.class.attribute_map.each_pair do |attr, param|
|
228
|
+
value = self.send(attr)
|
229
|
+
next if value.nil?
|
230
|
+
hash[param] = _to_hash(value)
|
231
|
+
end
|
232
|
+
hash
|
233
|
+
end
|
234
|
+
|
235
|
+
# Outputs non-array value in the form of hash
|
236
|
+
# For object, use to_hash. Otherwise, just return the value
|
237
|
+
# @param [Object] value Any valid value
|
238
|
+
# @return [Hash] Returns the value in the form of hash
|
239
|
+
def _to_hash(value)
|
240
|
+
if value.is_a?(Array)
|
241
|
+
value.compact.map{ |v| _to_hash(v) }
|
242
|
+
elsif value.is_a?(Hash)
|
243
|
+
{}.tap do |hash|
|
244
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
245
|
+
end
|
246
|
+
elsif value.respond_to? :to_hash
|
247
|
+
value.to_hash
|
248
|
+
else
|
249
|
+
value
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|