Fastly/Object/BrotliCompressionResponseBodyGetAllServices.pm untested

filter: Statementstmt 0.0% 0 / 124 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 24 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 174 CC 7 SCAR 19.2
CC
7
Cov
0%
from_hash
20.0
_deserialize
20.0
new
2.0
CRAP 6.8
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::BrotliCompressionResponseBodyGetAllServices;
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::BotManagementResponseCustomerCustomer;
32 use WebService::Fastly::Object::BrotliCompressionResponseCustomer;
33 use WebService::Fastly::Object::BrotliCompressionResponseEnabledServices;
34 use WebService::Fastly::Object::BrotliCompressionResponseLinksGetAllServices;
35 use WebService::Fastly::Object::BrotliCompressionResponseLinksGetAllServicesLinks;
36 use WebService::Fastly::Object::BrotliCompressionResponseProduct;
37 use WebService::Fastly::Object::BrotliCompressionResponseProductProduct;
38  
39 use base ("Class::Accessor", "Class::Data::Inheritable");
40  
41 #
42 #
43 #
44 # NOTE: This class is auto generated. Do not edit the class manually.
45 #
46  
47 =begin comment
48  
49 Fastly API
50  
51 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/)
52  
53 The version of the API Spec document: 1.0.0
54 Contact: oss@fastly.com
55  
56 =end comment
57  
58 =cut
59  
60 #
61 # NOTE: This class is auto generated.
62 # Do not edit the class manually.
63 #
64 __PACKAGE__->mk_classdata('attribute_map' => {});
65 __PACKAGE__->mk_classdata('openapi_types' => {});
66 __PACKAGE__->mk_classdata('method_documentation' => {});
67 __PACKAGE__->mk_classdata('class_documentation' => {});
68 __PACKAGE__->mk_classdata('openapi_nullable' => {});
69  
70 # new plain object
71 sub new {
72 my ($class, %args) = @_;
73  
74 my $self = bless {}, $class;
75  
76 $self->init(%args);
77  
78 return $self;
79 }
80  
81 # initialize the object
82 sub init
83 {
84 my ($self, %args) = @_;
85  
86 foreach my $attribute (keys %{$self->attribute_map}) {
87 my $args_key = $self->attribute_map->{$attribute};
88 $self->$attribute( $args{ $args_key } );
89 }
90 }
91  
92 # return perl hash
93 sub to_hash {
94 my $self = shift;
95 my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
96  
97 return $_hash;
98 }
99  
100 # used by JSON for serialization
101 sub TO_JSON {
102 my $self = shift;
103 my $_data = {};
104 foreach my $_key (keys %{$self->attribute_map}) {
105 $_data->{$self->attribute_map->{$_key}} = $self->{$_key};
106 }
107  
108 return $_data;
109 }
110  
111 # from Perl hashref
112 sub from_hash {
113 my ($self, $hash) = @_;
114  
115 # loop through attributes and use openapi_types to deserialize the data
116 while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
117 my $_json_attribute = $self->attribute_map->{$_key};
118 my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true';
119 if ($_type =~ /^array\[(.+)\]$/i) { # array
120 my $_subclass = $1;
121 my @_array = ();
122 foreach my $_element (@{$hash->{$_json_attribute}}) {
123 push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable);
124 }
125 $self->{$_key} = \@_array;
126 } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
127 my $_subclass = $1;
128 my %_hash = ();
129 while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
130 $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable);
131 }
132 $self->{$_key} = \%_hash;
133 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
134 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable);
135 } else {
136 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
137 }
138 }
139  
140 return $self;
141 }
142  
143 # deserialize non-array data
144 sub _deserialize {
145 my ($self, $type, $data, $is_nullable) = @_;
146 $log->debugf("deserializing %s with %s",Dumper($data), $type);
147  
148 if (!(defined $data) && $is_nullable) {
149 return undef;
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 "WebService::Fastly::Object::$type->new()";
157 return $_instance->from_hash($data);
158 }
159 }
160  
161  
162 __PACKAGE__->class_documentation({description => '',
163 class => 'BrotliCompressionResponseBodyGetAllServices',
164 required => [], # TODO
165 } );
166  
167 __PACKAGE__->method_documentation({
168 'product' => {
169 datatype => 'BrotliCompressionResponseProductProduct',
170 base_name => 'product',
171 description => '',
172 format => '',
173 read_only => 'false',
174 },
175 'customer' => {
176 datatype => 'BotManagementResponseCustomerCustomer',
177 base_name => 'customer',
178 description => '',
179 format => '',
180 read_only => 'false',
181 },
182 'services' => {
183 datatype => 'ARRAY[string]',
184 base_name => 'services',
185 description => 'A list of services with Brotli Compression enabled.',
186 format => '',
187 read_only => 'false',
188 },
189 '_links' => {
190 datatype => 'BrotliCompressionResponseLinksGetAllServicesLinks',
191 base_name => '_links',
192 description => '',
193 format => '',
194 read_only => 'false',
195 },
196 });
197  
198 __PACKAGE__->openapi_types( {
199 'product' => 'BrotliCompressionResponseProductProduct',
200 'customer' => 'BotManagementResponseCustomerCustomer',
201 'services' => 'ARRAY[string]',
202 '_links' => 'BrotliCompressionResponseLinksGetAllServicesLinks'
203 } );
204  
205 __PACKAGE__->attribute_map( {
206 'product' => 'product',
207 'customer' => 'customer',
208 'services' => 'services',
209 '_links' => '_links'
210 } );
211  
212 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
213  
214 __PACKAGE__->openapi_nullable( {
215 } );
216  
217  
218 1;