webapi-active-query-builder 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/LICENSE +201 -0
  2. data/README.md +55 -0
  3. data/docs/ActiveQueryBuilderApi.md +102 -0
  4. data/docs/Condition.md +10 -0
  5. data/docs/ConditionGroup.md +10 -0
  6. data/docs/HiddenColumn.md +8 -0
  7. data/docs/Pagination.md +9 -0
  8. data/docs/QueryColumn.md +9 -0
  9. data/docs/Sorting.md +9 -0
  10. data/docs/SqlQuery.md +9 -0
  11. data/docs/Totals.md +9 -0
  12. data/docs/Transform.md +14 -0
  13. data/docs/TransformResult.md +10 -0
  14. data/git_push.sh +67 -0
  15. data/lib/webapi-active-query-builder.rb +61 -0
  16. data/lib/webapi-active-query-builder/api/active_query_builder_api.rb +148 -0
  17. data/lib/webapi-active-query-builder/api_client.rb +378 -0
  18. data/lib/webapi-active-query-builder/api_error.rb +47 -0
  19. data/lib/webapi-active-query-builder/configuration.rb +207 -0
  20. data/lib/webapi-active-query-builder/models/condition.rb +255 -0
  21. data/lib/webapi-active-query-builder/models/condition_group.rb +257 -0
  22. data/lib/webapi-active-query-builder/models/hidden_column.rb +200 -0
  23. data/lib/webapi-active-query-builder/models/pagination.rb +210 -0
  24. data/lib/webapi-active-query-builder/models/query_column.rb +210 -0
  25. data/lib/webapi-active-query-builder/models/sorting.rb +243 -0
  26. data/lib/webapi-active-query-builder/models/sql_query.rb +210 -0
  27. data/lib/webapi-active-query-builder/models/totals.rb +243 -0
  28. data/lib/webapi-active-query-builder/models/transform.rb +261 -0
  29. data/lib/webapi-active-query-builder/models/transform_result.rb +220 -0
  30. data/lib/webapi-active-query-builder/version.rb +26 -0
  31. data/spec/api/active_query_builder_api_spec.rb +70 -0
  32. data/spec/api_client_spec.rb +237 -0
  33. data/spec/configuration_spec.rb +53 -0
  34. data/spec/models/condition_group_spec.rb +69 -0
  35. data/spec/models/condition_spec.rb +69 -0
  36. data/spec/models/hidden_column_spec.rb +53 -0
  37. data/spec/models/pagination_spec.rb +59 -0
  38. data/spec/models/query_column_spec.rb +59 -0
  39. data/spec/models/sorting_spec.rb +63 -0
  40. data/spec/models/sql_query_spec.rb +59 -0
  41. data/spec/models/totals_spec.rb +63 -0
  42. data/spec/models/transform_result_spec.rb +65 -0
  43. data/spec/models/transform_spec.rb +89 -0
  44. data/spec/spec_helper.rb +122 -0
  45. data/webapi-active-query-builder.gemspec +55 -0
  46. metadata +307 -0
@@ -0,0 +1,257 @@
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
+ # Group of conditions joined with the same boolean operator.
28
+ class ConditionGroup
29
+ # Type of junction. All = AND; Any = OR.
30
+ attr_accessor :junction_type
31
+
32
+ # List of conditions to join.
33
+ attr_accessor :conditions
34
+
35
+ # List of nested condition groups to join them with a different boolean operator.
36
+ attr_accessor :condition_groups
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
+ :'junction_type' => :'junctionType',
64
+ :'conditions' => :'conditions',
65
+ :'condition_groups' => :'conditionGroups'
66
+ }
67
+ end
68
+
69
+ # Attribute type mapping.
70
+ def self.swagger_types
71
+ {
72
+ :'junction_type' => :'String',
73
+ :'conditions' => :'Array<Condition>',
74
+ :'condition_groups' => :'Array<ConditionGroup>'
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?(:'junctionType')
87
+ self.junction_type = attributes[:'junctionType']
88
+ end
89
+
90
+ if attributes.has_key?(:'conditions')
91
+ if (value = attributes[:'conditions']).is_a?(Array)
92
+ self.conditions = value
93
+ end
94
+ end
95
+
96
+ if attributes.has_key?(:'conditionGroups')
97
+ if (value = attributes[:'conditionGroups']).is_a?(Array)
98
+ self.condition_groups = value
99
+ end
100
+ end
101
+
102
+ end
103
+
104
+ # Show invalid properties with the reasons. Usually used together with valid?
105
+ # @return Array for valid properies with the reasons
106
+ def list_invalid_properties
107
+ invalid_properties = Array.new
108
+ return invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ junction_type_validator = EnumAttributeValidator.new('String', ["And", "Or", "Any", "All"])
115
+ return false unless junction_type_validator.valid?(@junction_type)
116
+ return true
117
+ end
118
+
119
+ # Custom attribute writer method checking allowed values (enum).
120
+ # @param [Object] junction_type Object to be assigned
121
+ def junction_type=(junction_type)
122
+ validator = EnumAttributeValidator.new('String', ["And", "Or", "Any", "All"])
123
+ unless validator.valid?(junction_type)
124
+ fail ArgumentError, "invalid value for 'junction_type', must be one of #{validator.allowable_values}."
125
+ end
126
+ @junction_type = junction_type
127
+ end
128
+
129
+ # Checks equality by comparing each attribute.
130
+ # @param [Object] Object to be compared
131
+ def ==(o)
132
+ return true if self.equal?(o)
133
+ self.class == o.class &&
134
+ junction_type == o.junction_type &&
135
+ conditions == o.conditions &&
136
+ condition_groups == o.condition_groups
137
+ end
138
+
139
+ # @see the `==` method
140
+ # @param [Object] Object to be compared
141
+ def eql?(o)
142
+ self == o
143
+ end
144
+
145
+ # Calculates hash code according to all attributes.
146
+ # @return [Fixnum] Hash code
147
+ def hash
148
+ [junction_type, conditions, condition_groups].hash
149
+ end
150
+
151
+ # Builds the object from hash
152
+ # @param [Hash] attributes Model attributes in the form of hash
153
+ # @return [Object] Returns the model itself
154
+ def build_from_hash(attributes)
155
+ return nil unless attributes.is_a?(Hash)
156
+ self.class.swagger_types.each_pair do |key, type|
157
+ if type =~ /^Array<(.*)>/i
158
+ # check to ensure the input is an array given that the the attribute
159
+ # is documented as an array but the input is not
160
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
161
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
162
+ end
163
+ elsif !attributes[self.class.attribute_map[key]].nil?
164
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
165
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
166
+ end
167
+
168
+ self
169
+ end
170
+
171
+ # Deserializes the data based on type
172
+ # @param string type Data type
173
+ # @param string value Value to be deserialized
174
+ # @return [Object] Deserialized data
175
+ def _deserialize(type, value)
176
+ case type.to_sym
177
+ when :DateTime
178
+ DateTime.parse(value)
179
+ when :Date
180
+ Date.parse(value)
181
+ when :String
182
+ value.to_s
183
+ when :Integer
184
+ value.to_i
185
+ when :Float
186
+ value.to_f
187
+ when :BOOLEAN
188
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
189
+ true
190
+ else
191
+ false
192
+ end
193
+ when :Object
194
+ # generic object (usually a Hash), return directly
195
+ value
196
+ when /\AArray<(?<inner_type>.+)>\z/
197
+ inner_type = Regexp.last_match[:inner_type]
198
+ value.map { |v| _deserialize(inner_type, v) }
199
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
200
+ k_type = Regexp.last_match[:k_type]
201
+ v_type = Regexp.last_match[:v_type]
202
+ {}.tap do |hash|
203
+ value.each do |k, v|
204
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
205
+ end
206
+ end
207
+ else # model
208
+ temp_model = WebApiActivequerybuilder.const_get(type).new
209
+ temp_model.build_from_hash(value)
210
+ end
211
+ end
212
+
213
+ # Returns the string representation of the object
214
+ # @return [String] String presentation of the object
215
+ def to_s
216
+ to_hash.to_s
217
+ end
218
+
219
+ # to_body is an alias to to_hash (backward compatibility)
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_body
222
+ to_hash
223
+ end
224
+
225
+ # Returns the object in the form of hash
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_hash
228
+ hash = {}
229
+ self.class.attribute_map.each_pair do |attr, param|
230
+ value = self.send(attr)
231
+ next if value.nil?
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map{ |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end
@@ -0,0 +1,200 @@
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
+ # Instructs to exclude some columns of original query from the SELECT list of transformed query.
28
+ class HiddenColumn
29
+ # Column of original query which will be removed from transformed query.
30
+ attr_accessor :field
31
+
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'field' => :'field'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'field' => :'String'
44
+ }
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ return unless attributes.is_a?(Hash)
51
+
52
+ # convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
54
+
55
+ if attributes.has_key?(:'field')
56
+ self.field = attributes[:'field']
57
+ end
58
+
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properies with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ return invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ return true
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(o)
77
+ return true if self.equal?(o)
78
+ self.class == o.class &&
79
+ field == o.field
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(o)
85
+ self == o
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Fixnum] Hash code
90
+ def hash
91
+ [field].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def build_from_hash(attributes)
98
+ return nil unless attributes.is_a?(Hash)
99
+ self.class.swagger_types.each_pair do |key, type|
100
+ if type =~ /^Array<(.*)>/i
101
+ # check to ensure the input is an array given that the the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
104
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
105
+ end
106
+ elsif !attributes[self.class.attribute_map[key]].nil?
107
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
108
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
109
+ end
110
+
111
+ self
112
+ end
113
+
114
+ # Deserializes the data based on type
115
+ # @param string type Data type
116
+ # @param string value Value to be deserialized
117
+ # @return [Object] Deserialized data
118
+ def _deserialize(type, value)
119
+ case type.to_sym
120
+ when :DateTime
121
+ DateTime.parse(value)
122
+ when :Date
123
+ Date.parse(value)
124
+ when :String
125
+ value.to_s
126
+ when :Integer
127
+ value.to_i
128
+ when :Float
129
+ value.to_f
130
+ when :BOOLEAN
131
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
132
+ true
133
+ else
134
+ false
135
+ end
136
+ when :Object
137
+ # generic object (usually a Hash), return directly
138
+ value
139
+ when /\AArray<(?<inner_type>.+)>\z/
140
+ inner_type = Regexp.last_match[:inner_type]
141
+ value.map { |v| _deserialize(inner_type, v) }
142
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
143
+ k_type = Regexp.last_match[:k_type]
144
+ v_type = Regexp.last_match[:v_type]
145
+ {}.tap do |hash|
146
+ value.each do |k, v|
147
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
+ end
149
+ end
150
+ else # model
151
+ temp_model = WebApiActivequerybuilder.const_get(type).new
152
+ temp_model.build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ # Returns the object in the form of hash
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_hash
171
+ hash = {}
172
+ self.class.attribute_map.each_pair do |attr, param|
173
+ value = self.send(attr)
174
+ next if value.nil?
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param [Object] value Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map{ |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ end
199
+
200
+ end