WebApi/Object/Pagination.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::Pagination;
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 #Instructs to limit the number of rows in transformed query resultset taking limitations of original query into account. In other words, if original query contains row limitation clause, it will be wrapped into a derived table and additional row limitation clause will be added ontop.
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 => 'Instructs to limit the number of rows in transformed query resultset taking limitations of original query into account. In other words, if original query contains row limitation clause, it will be wrapped into a derived table and additional row limitation clause will be added ontop.',
164 class => 'Pagination',
165 required => [], # TODO
166 } );
167  
168 __PACKAGE__->method_documentation({
169 'skip' => {
170 datatype => 'int',
171 base_name => 'skip',
172 description => 'Number of rows to skip from the top of original resultset.',
173 format => '',
174 read_only => '',
175 },
176 'take' => {
177 datatype => 'int',
178 base_name => 'take',
179 description => 'Number of rows to get from orignal to new resultset.',
180 format => '',
181 read_only => '',
182 },
183 });
184  
185 __PACKAGE__->swagger_types( {
186 'skip' => 'int',
187 'take' => 'int'
188 } );
189  
190 __PACKAGE__->attribute_map( {
191 'skip' => 'skip',
192 'take' => 'take'
193 } );
194  
195 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
196  
197  
198 1;