Fastly/Object/ImageOptimizerResponseBodyEnable.pm untested

filter: Statementstmt 0.0% 0 / 121 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 23 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 170 CC 7 SCAR 19.4
CC
7
Cov
0%
from_hash
20.0
_deserialize
20.0
new
2.0
CRAP 7.0
1 =begin comment
2  
3 Fastly API
4  
5 Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
6  
7 The version of the API Spec document: 1.0.0
8 Contact: oss@fastly.com
9  
10 =end comment
11  
12 =cut
13  
14 #
15 # NOTE: This class is auto generated.
16 # Do not edit the class manually.
17 #
18 package WebService::Fastly::Object::ImageOptimizerResponseBodyEnable;
19  
20 require 5.6.0;
21 use strict;
22 use warnings;
23 use utf8;
24 use JSON::MaybeXS qw(decode_json);
25 use Data::Dumper;
26 use Module::Runtime qw(use_module);
27 use Log::Any qw($log);
28 use Date::Parse;
29 use DateTime;
30  
31 use WebService::Fastly::Object::ApiDiscoveryResponseServiceService;
32 use WebService::Fastly::Object::ImageOptimizerResponseLinks;
33 use WebService::Fastly::Object::ImageOptimizerResponseLinksLinks;
34 use WebService::Fastly::Object::ImageOptimizerResponseProduct;
35 use WebService::Fastly::Object::ImageOptimizerResponseProductProduct;
36 use WebService::Fastly::Object::ImageOptimizerResponseService;
37  
38 use base ("Class::Accessor", "Class::Data::Inheritable");
39  
40 #
41 #
42 #
43 # NOTE: This class is auto generated. Do not edit the class manually.
44 #
45  
46 =begin comment
47  
48 Fastly API
49  
50 Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/)
51  
52 The version of the API Spec document: 1.0.0
53 Contact: oss@fastly.com
54  
55 =end comment
56  
57 =cut
58  
59 #
60 # NOTE: This class is auto generated.
61 # Do not edit the class manually.
62 #
63 __PACKAGE__->mk_classdata('attribute_map' => {});
64 __PACKAGE__->mk_classdata('openapi_types' => {});
65 __PACKAGE__->mk_classdata('method_documentation' => {});
66 __PACKAGE__->mk_classdata('class_documentation' => {});
67 __PACKAGE__->mk_classdata('openapi_nullable' => {});
68  
69 # new plain object
70 sub new {
71 my ($class, %args) = @_;
72  
73 my $self = bless {}, $class;
74  
75 $self->init(%args);
76  
77 return $self;
78 }
79  
80 # initialize the object
81 sub init
82 {
83 my ($self, %args) = @_;
84  
85 foreach my $attribute (keys %{$self->attribute_map}) {
86 my $args_key = $self->attribute_map->{$attribute};
87 $self->$attribute( $args{ $args_key } );
88 }
89 }
90  
91 # return perl hash
92 sub to_hash {
93 my $self = shift;
94 my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
95  
96 return $_hash;
97 }
98  
99 # used by JSON for serialization
100 sub TO_JSON {
101 my $self = shift;
102 my $_data = {};
103 foreach my $_key (keys %{$self->attribute_map}) {
104 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
105 }
106  
107 return $_data;
108 }
109  
110 # from Perl hashref
111 sub from_hash {
112 my ($self, $hash) = @_;
113  
114 # loop through attributes and use openapi_types to deserialize the data
115 while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
116 my $_json_attribute = $self->attribute_map->{$_key};
117 my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true';
118 if ($_type =~ /^array\[(.+)\]$/i) { # array
119 my $_subclass = $1;
120 my @_array = ();
121 foreach my $_element (@{$hash->{$_json_attribute}}) {
122 push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable);
123 }
124 $self->{$_key} = \@_array;
125 } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
126 my $_subclass = $1;
127 my %_hash = ();
128 while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
129 $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable);
130 }
131 $self->{$_key} = \%_hash;
132 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
133 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable);
134 } else {
135 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
136 }
137 }
138  
139 return $self;
140 }
141  
142 # deserialize non-array data
143 sub _deserialize {
144 my ($self, $type, $data, $is_nullable) = @_;
145 $log->debugf("deserializing %s with %s",Dumper($data), $type);
146  
147 if (!(defined $data) && $is_nullable) {
148 return undef;
149 }
150 if ($type eq 'DateTime') {
151 return DateTime->from_epoch(epoch => str2time($data));
152 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
153 return $data;
154 } else { # hash(model)
155 my $_instance = eval "WebService::Fastly::Object::$type->new()";
156 return $_instance->from_hash($data);
157 }
158 }
159  
160  
161 __PACKAGE__->class_documentation({description => '',
162 class => 'ImageOptimizerResponseBodyEnable',
163 required => [], # TODO
164 } );
165  
166 __PACKAGE__->method_documentation({
167 'product' => {
168 datatype => 'ImageOptimizerResponseProductProduct',
169 base_name => 'product',
170 description => '',
171 format => '',
172 read_only => 'false',
173 },
174 'service' => {
175 datatype => 'ApiDiscoveryResponseServiceService',
176 base_name => 'service',
177 description => '',
178 format => '',
179 read_only => 'false',
180 },
181 '_links' => {
182 datatype => 'ImageOptimizerResponseLinksLinks',
183 base_name => '_links',
184 description => '',
185 format => '',
186 read_only => 'false',
187 },
188 });
189  
190 __PACKAGE__->openapi_types( {
191 'product' => 'ImageOptimizerResponseProductProduct',
192 'service' => 'ApiDiscoveryResponseServiceService',
193 '_links' => 'ImageOptimizerResponseLinksLinks'
194 } );
195  
196 __PACKAGE__->attribute_map( {
197 'product' => 'product',
198 'service' => 'service',
199 '_links' => '_links'
200 } );
201  
202 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
203  
204 __PACKAGE__->openapi_nullable( {
205 } );
206  
207  
208 1;