WebApi/Object/Transform.pm untested

filter: Statementstmt 0.0% 0 / 87 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 118 CC 6 SCAR 16.6
CC
6
Cov
0%
from_hash
12.0
_deserialize
12.0
TO_JSON
6.0
CRAP 5.2
1 =begin comment
2  
3 QueryBuilderApi
4  
5 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/.
6  
7 OpenAPI spec version: 1.1.8
8 Contact: support@activedbsoft.com
9 Generated by: https://github.com/swagger-api/swagger-codegen.git
10  
11 Licensed under the Apache License, Version 2.0 (the "License");
12 you may not use this file except in compliance with the License.
13 You may obtain a copy of the License at
14  
15 http://www.apache.org/licenses/LICENSE-2.0
16  
17 Unless required by applicable law or agreed to in writing, software
18 distributed under the License is distributed on an "AS IS" BASIS,
19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 See the License for the specific language governing permissions and
21 limitations under the License.
22  
23 =end comment
24  
25 =cut
26  
27 #
28 # NOTE: This class is auto generated by the swagger code generator program.
29 # Do not edit the class manually.
30 # Ref: https://github.com/swagger-api/swagger-codegen
31 #
32 package SQL::QueryBuilder::WebApi::Object::Transform;
33  
34 require 5.6.0;
35 use strict;
36 use warnings;
37 use utf8;
38 use JSON qw(decode_json);
39 use Data::Dumper;
40 use Module::Runtime qw(use_module);
41 use Log::Any qw($log);
42 use Date::Parse;
43 use DateTime;
44  
45 use base ("Class::Accessor", "Class::Data::Inheritable");
46  
47  
48 #
49 #SQL transformation parameters and commands.
50 #
51 # NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
52 # REF: https://github.com/swagger-api/swagger-codegen
53 #
54  
55 =begin comment
56  
57 QueryBuilderApi
58  
59 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/.
60  
61 OpenAPI spec version: 1.1.8
62 Contact: support@activedbsoft.com
63 Generated by: https://github.com/swagger-api/swagger-codegen.git
64  
65 Licensed under the Apache License, Version 2.0 (the "License");
66 you may not use this file except in compliance with the License.
67 You may obtain a copy of the License at
68  
69 http://www.apache.org/licenses/LICENSE-2.0
70  
71 Unless required by applicable law or agreed to in writing, software
72 distributed under the License is distributed on an "AS IS" BASIS,
73 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74 See the License for the specific language governing permissions and
75 limitations under the License.
76  
77 =end comment
78  
79 =cut
80  
81 #
82 # NOTE: This class is auto generated by the swagger code generator program.
83 # Do not edit the class manually.
84 # Ref: https://github.com/swagger-api/swagger-codegen
85 #
86 __PACKAGE__->mk_classdata('attribute_map' => {});
87 __PACKAGE__->mk_classdata('swagger_types' => {});
88 __PACKAGE__->mk_classdata('method_documentation' => {});
89 __PACKAGE__->mk_classdata('class_documentation' => {});
90  
91 # new object
92 sub new {
93 my ($class, %args) = @_;
94  
95 my $self = bless {}, $class;
96
97 foreach my $attribute (keys %{$class->attribute_map}) {
98 my $args_key = $class->attribute_map->{$attribute};
99 $self->$attribute( $args{ $args_key } );
100 }
101
102 return $self;
103 }
104  
105 # return perl hash
106 sub to_hash {
107 return decode_json(JSON->new->convert_blessed->encode( shift ));
108 }
109  
110 # used by JSON for serialization
111 sub TO_JSON {
112 my $self = shift;
113 my $_data = {};
114 foreach my $_key (keys %{$self->attribute_map}) {
115 if (defined $self->{$_key}) {
116 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
117 }
118 }
119 return $_data;
120 }
121  
122 # from Perl hashref
123 sub from_hash {
124 my ($self, $hash) = @_;
125  
126 # loop through attributes and use swagger_types to deserialize the data
127 while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
128 my $_json_attribute = $self->attribute_map->{$_key};
129 if ($_type =~ /^array\[/i) { # array
130 my $_subclass = substr($_type, 6, -1);
131 my @_array = ();
132 foreach my $_element (@{$hash->{$_json_attribute}}) {
133 push @_array, $self->_deserialize($_subclass, $_element);
134 }
135 $self->{$_key} = \@_array;
136 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
137 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
138 } else {
139 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
140 }
141 }
142
143 return $self;
144 }
145  
146 # deserialize non-array data
147 sub _deserialize {
148 my ($self, $type, $data) = @_;
149 $log->debugf("deserializing %s with %s",Dumper($data), $type);
150
151 if ($type eq 'DateTime') {
152 return DateTime->from_epoch(epoch => str2time($data));
153 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
154 return $data;
155 } else { # hash(model)
156 my $_instance = eval "SQL::QueryBuilder::WebApi::Object::$type->new()";
157 return $_instance->from_hash($data);
158 }
159 }
160  
161  
162  
163 __PACKAGE__->class_documentation({description => 'SQL transformation parameters and commands.',
164 class => 'Transform',
165 required => [], # TODO
166 } );
167  
168 __PACKAGE__->method_documentation({
169 'guid' => {
170 datatype => 'string',
171 base_name => 'Guid',
172 description => 'Unique identifier that defines SQL execution context for the given query, i.e. database server (SQL syntax rules), database schema. The context itself must be saved in the user account on https://webapi.activequerybuilder.com/.',
173 format => '',
174 read_only => '',
175 },
176 'sql' => {
177 datatype => 'string',
178 base_name => 'Sql',
179 description => 'Text of original SQL query to be transformed.',
180 format => '',
181 read_only => '',
182 },
183 'pagination' => {
184 datatype => 'Pagination',
185 base_name => 'Pagination',
186 description => '',
187 format => '',
188 read_only => '',
189 },
190 'totals' => {
191 datatype => 'ARRAY[Totals]',
192 base_name => 'Totals',
193 description => '',
194 format => '',
195 read_only => '',
196 },
197 'sortings' => {
198 datatype => 'ARRAY[Sorting]',
199 base_name => 'Sortings',
200 description => '',
201 format => '',
202 read_only => '',
203 },
204 'filter' => {
205 datatype => 'ConditionGroup',
206 base_name => 'Filter',
207 description => '',
208 format => '',
209 read_only => '',
210 },
211 'hidden_columns' => {
212 datatype => 'ARRAY[HiddenColumn]',
213 base_name => 'HiddenColumns',
214 description => '',
215 format => '',
216 read_only => '',
217 },
218 });
219  
220 __PACKAGE__->swagger_types( {
221 'guid' => 'string',
222 'sql' => 'string',
223 'pagination' => 'Pagination',
224 'totals' => 'ARRAY[Totals]',
225 'sortings' => 'ARRAY[Sorting]',
226 'filter' => 'ConditionGroup',
227 'hidden_columns' => 'ARRAY[HiddenColumn]'
228 } );
229  
230 __PACKAGE__->attribute_map( {
231 'guid' => 'Guid',
232 'sql' => 'Sql',
233 'pagination' => 'Pagination',
234 'totals' => 'Totals',
235 'sortings' => 'Sortings',
236 'filter' => 'Filter',
237 'hidden_columns' => 'HiddenColumns'
238 } );
239  
240 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
241  
242  
243 1;