Fastly/Object/InvitationsResponse.pm untested

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