Object/Entity.pm untested

filter: Statementstmt 0.0% 0 / 102 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 21 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 138 CC 6 SCAR 15.3
CC
6
Cov
0%
from_hash
12.0
_deserialize
12.0
TO_JSON
6.0
CRAP 4.6
1 =begin comment
2
3 Aspose.3D Cloud API Reference
4
5 No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
6
7 OpenAPI spec version: 3.0
8
9 Generated by: https://github.com/swagger-api/swagger-codegen.git
10
11 =end comment
12
13 =cut
14
15 #
16 # NOTE: This class is auto generated by the swagger code generator program.
17 # Do not edit the class manually.
18 # Ref: https://github.com/swagger-api/swagger-codegen
19 #
20 package AsposeThreeDCloud::Object::Entity;
21
22 require 5.6.0;
23 use strict;
24 use warnings;
25 use utf8;
26 use JSON qw(decode_json);
27 use Data::Dumper;
28 use Module::Runtime qw(use_module);
29 use Log::Any qw($log);
30 use Date::Parse;
31 use DateTime;
32
33 use AsposeThreeDCloud::Object::Box;
34 use AsposeThreeDCloud::Object::Cylinder;
35 use AsposeThreeDCloud::Object::Plane;
36 use AsposeThreeDCloud::Object::Sphere;
37 use AsposeThreeDCloud::Object::Torus;
38
39 use base ("Class::Accessor", "Class::Data::Inheritable");
40
41
42 #
43 #Entity class
44 #
45 # NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
46 # REF: https://github.com/swagger-api/swagger-codegen
47 #
48
49 =begin comment
50
51 Aspose.3D Cloud API Reference
52
53 No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
54
55 OpenAPI spec version: 3.0
56
57 Generated by: https://github.com/swagger-api/swagger-codegen.git
58
59 =end comment
60
61 =cut
62
63 #
64 # NOTE: This class is auto generated by the swagger code generator program.
65 # Do not edit the class manually.
66 # Ref: https://github.com/swagger-api/swagger-codegen
67 #
68 __PACKAGE__->mk_classdata('attribute_map' => {});
69 __PACKAGE__->mk_classdata('swagger_types' => {});
70 __PACKAGE__->mk_classdata('method_documentation' => {});
71 __PACKAGE__->mk_classdata('class_documentation' => {});
72
73 # new object
74 sub new {
75 my ($class, %args) = @_;
76
77 my $self = bless {}, $class;
78
79 foreach my $attribute (keys %{$class->attribute_map}) {
80 my $args_key = $class->attribute_map->{$attribute};
81 $self->$attribute( $args{ $args_key } );
82 }
83
84 return $self;
85 }
86
87 # return perl hash
88 sub to_hash {
89 return decode_json(JSON->new->convert_blessed->encode( shift ));
90 }
91
92 # used by JSON for serialization
93 sub TO_JSON {
94 my $self = shift;
95 my $_data = {};
96 foreach my $_key (keys %{$self->attribute_map}) {
97 if (defined $self->{$_key}) {
98 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
99 }
100 }
101 return $_data;
102 }
103
104 # from Perl hashref
105 sub from_hash {
106 my ($self, $hash) = @_;
107
108 # loop through attributes and use swagger_types to deserialize the data
109 while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
110 my $_json_attribute = $self->attribute_map->{$_key};
111 if ($_type =~ /^array\[/i) { # array
112 my $_subclass = substr($_type, 6, -1);
113 my @_array = ();
114 foreach my $_element (@{$hash->{$_json_attribute}}) {
115 push @_array, $self->_deserialize($_subclass, $_element);
116 }
117 $self->{$_key} = \@_array;
118 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
119 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
120 } else {
121 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
122 }
123 }
124
125 return $self;
126 }
127
128 # deserialize non-array data
129 sub _deserialize {
130 my ($self, $type, $data) = @_;
131 $log->debugf("deserializing %s with %s",Dumper($data), $type);
132
133 if ($type eq 'DateTime') {
134 return DateTime->from_epoch(epoch => str2time($data));
135 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
136 return $data;
137 } else { # hash(model)
138 my $_instance = eval "AsposeThreeDCloud::Object::$type->new()";
139 return $_instance->from_hash($data);
140 }
141 }
142
143
144
145 __PACKAGE__->class_documentation({description => 'Entity class ',
146 class => 'Entity',
147 required => [], # TODO
148 } );
149
150 __PACKAGE__->method_documentation({
151 'type' => {
152 datatype => 'string',
153 base_name => 'Type',
154 description => 'Box/Cylinder/Sphere/Torus/Plane',
155 format => '',
156 read_only => '',
157 },
158 'box' => {
159 datatype => 'Box',
160 base_name => 'Box',
161 description => 'Gets or sets Box entity',
162 format => '',
163 read_only => '',
164 },
165 'cylinder' => {
166 datatype => 'Cylinder',
167 base_name => 'Cylinder',
168 description => 'Gets or sets Cylinder entity',
169 format => '',
170 read_only => '',
171 },
172 'sphere' => {
173 datatype => 'Sphere',
174 base_name => 'Sphere',
175 description => 'Gets or sets Sphere entity',
176 format => '',
177 read_only => '',
178 },
179 'torus' => {
180 datatype => 'Torus',
181 base_name => 'Torus',
182 description => 'Gets or sets Torus entity',
183 format => '',
184 read_only => '',
185 },
186 'plane' => {
187 datatype => 'Plane',
188 base_name => 'Plane',
189 description => 'Gets or sets Plane entity',
190 format => '',
191 read_only => '',
192 },
193 });
194
195 __PACKAGE__->swagger_types( {
196 'type' => 'string',
197 'box' => 'Box',
198 'cylinder' => 'Cylinder',
199 'sphere' => 'Sphere',
200 'torus' => 'Torus',
201 'plane' => 'Plane'
202 } );
203
204 __PACKAGE__->attribute_map( {
205 'type' => 'Type',
206 'box' => 'Box',
207 'cylinder' => 'Cylinder',
208 'sphere' => 'Sphere',
209 'torus' => 'Torus',
210 'plane' => 'Plane'
211 } );
212
213 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
214
215
216 1;