Fastly/Object/HistoricalRegionsResponse.pm untested

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