Fastly/Object/Customer.pm untested

filter: Statementstmt 0.0% 0 / 104 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 147 CC 7 SCAR 21.1
CC
7
Cov
0%
from_hash
20.0
_deserialize
20.0
new
2.0
CRAP 8.3
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::Customer;
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  
32 use base ("Class::Accessor", "Class::Data::Inheritable");
33  
34 #
35 #
36 #
37 # NOTE: This class is auto generated. Do not edit the class manually.
38 #
39  
40 =begin comment
41  
42 Fastly API
43  
44 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/)
45  
46 The version of the API Spec document: 1.0.0
47 Contact: oss@fastly.com
48  
49 =end comment
50  
51 =cut
52  
53 #
54 # NOTE: This class is auto generated.
55 # Do not edit the class manually.
56 #
57 __PACKAGE__->mk_classdata('attribute_map' => {});
58 __PACKAGE__->mk_classdata('openapi_types' => {});
59 __PACKAGE__->mk_classdata('method_documentation' => {});
60 __PACKAGE__->mk_classdata('class_documentation' => {});
61 __PACKAGE__->mk_classdata('openapi_nullable' => {});
62  
63 # new plain object
64 sub new {
65 my ($class, %args) = @_;
66  
67 my $self = bless {}, $class;
68  
69 $self->init(%args);
70  
71 return $self;
72 }
73  
74 # initialize the object
75 sub init
76 {
77 my ($self, %args) = @_;
78  
79 foreach my $attribute (keys %{$self->attribute_map}) {
80 my $args_key = $self->attribute_map->{$attribute};
81 $self->$attribute( $args{ $args_key } );
82 }
83 }
84  
85 # return perl hash
86 sub to_hash {
87 my $self = shift;
88 my $_hash = decode_json(JSON()->new->allow_blessed->convert_blessed->encode($self));
89  
90 return $_hash;
91 }
92  
93 # used by JSON for serialization
94 sub TO_JSON {
95 my $self = shift;
96 my $_data = {};
97 foreach my $_key (keys %{$self->attribute_map}) {
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 openapi_types to deserialize the data
109 while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
110 my $_json_attribute = $self->attribute_map->{$_key};
111 my $_is_nullable = ($self->openapi_nullable->{$_key} || 'false') eq 'true';
112 if ($_type =~ /^array\[(.+)\]$/i) { # array
113 my $_subclass = $1;
114 my @_array = ();
115 foreach my $_element (@{$hash->{$_json_attribute}}) {
116 push @_array, $self->_deserialize($_subclass, $_element, $_is_nullable);
117 }
118 $self->{$_key} = \@_array;
119 } elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
120 my $_subclass = $1;
121 my %_hash = ();
122 while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
123 $_hash{$_key} = $self->_deserialize($_subclass, $_element, $_is_nullable);
124 }
125 $self->{$_key} = \%_hash;
126 } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
127 $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}, $_is_nullable);
128 } else {
129 $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
130 }
131 }
132  
133 return $self;
134 }
135  
136 # deserialize non-array data
137 sub _deserialize {
138 my ($self, $type, $data, $is_nullable) = @_;
139 $log->debugf("deserializing %s with %s",Dumper($data), $type);
140  
141 if (!(defined $data) && $is_nullable) {
142 return undef;
143 }
144 if ($type eq 'DateTime') {
145 return DateTime->from_epoch(epoch => str2time($data));
146 } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
147 return $data;
148 } else { # hash(model)
149 my $_instance = eval "WebService::Fastly::Object::$type->new()";
150 return $_instance->from_hash($data);
151 }
152 }
153  
154  
155 __PACKAGE__->class_documentation({description => '',
156 class => 'Customer',
157 required => [], # TODO
158 } );
159  
160 __PACKAGE__->method_documentation({
161 'billing_contact_id' => {
162 datatype => 'string',
163 base_name => 'billing_contact_id',
164 description => 'The alphanumeric string representing the primary billing contact.',
165 format => '',
166 read_only => 'false',
167 },
168 'billing_network_type' => {
169 datatype => 'string',
170 base_name => 'billing_network_type',
171 description => 'Customer's current network revenue type.',
172 format => '',
173 read_only => 'false',
174 },
175 'billing_ref' => {
176 datatype => 'string',
177 base_name => 'billing_ref',
178 description => 'Used for adding purchased orders to customer's account.',
179 format => '',
180 read_only => 'false',
181 },
182 'can_configure_wordpress' => {
183 datatype => 'boolean',
184 base_name => 'can_configure_wordpress',
185 description => 'Whether this customer can view or edit wordpress.',
186 format => '',
187 read_only => 'true',
188 },
189 'can_reset_passwords' => {
190 datatype => 'boolean',
191 base_name => 'can_reset_passwords',
192 description => 'Whether this customer can reset passwords.',
193 format => '',
194 read_only => 'true',
195 },
196 'can_upload_vcl' => {
197 datatype => 'boolean',
198 base_name => 'can_upload_vcl',
199 description => 'Whether this customer can upload VCL.',
200 format => '',
201 read_only => 'true',
202 },
203 'force_2fa' => {
204 datatype => 'boolean',
205 base_name => 'force_2fa',
206 description => 'Specifies whether 2FA is forced or not forced on the customer account. Logs out non-2FA users once 2FA is force enabled.',
207 format => '',
208 read_only => 'false',
209 },
210 'force_sso' => {
211 datatype => 'boolean',
212 base_name => 'force_sso',
213 description => 'Specifies whether SSO is forced or not forced on the customer account.',
214 format => '',
215 read_only => 'false',
216 },
217 'has_account_panel' => {
218 datatype => 'boolean',
219 base_name => 'has_account_panel',
220 description => 'Specifies whether the account has access or does not have access to the account panel.',
221 format => '',
222 read_only => 'false',
223 },
224 'has_improved_events' => {
225 datatype => 'boolean',
226 base_name => 'has_improved_events',
227 description => 'Specifies whether the account has access or does not have access to the improved events.',
228 format => '',
229 read_only => 'false',
230 },
231 'has_improved_ssl_config' => {
232 datatype => 'boolean',
233 base_name => 'has_improved_ssl_config',
234 description => 'Whether this customer can view or edit the SSL config.',
235 format => '',
236 read_only => 'true',
237 },
238 'has_openstack_logging' => {
239 datatype => 'boolean',
240 base_name => 'has_openstack_logging',
241 description => 'Specifies whether the account has enabled or not enabled openstack logging.',
242 format => '',
243 read_only => 'false',
244 },
245 'has_pci' => {
246 datatype => 'boolean',
247 base_name => 'has_pci',
248 description => 'Specifies whether the account can edit PCI for a service.',
249 format => '',
250 read_only => 'false',
251 },
252 'has_pci_passwords' => {
253 datatype => 'boolean',
254 base_name => 'has_pci_passwords',
255 description => 'Specifies whether PCI passwords are required for the account.',
256 format => '',
257 read_only => 'true',
258 },
259 'ip_whitelist' => {
260 datatype => 'string',
261 base_name => 'ip_whitelist',
262 description => 'The range of IP addresses authorized to access the customer account.',
263 format => '',
264 read_only => 'false',
265 },
266 'legal_contact_id' => {
267 datatype => 'string',
268 base_name => 'legal_contact_id',
269 description => 'The alphanumeric string identifying the account's legal contact.',
270 format => '',
271 read_only => 'false',
272 },
273 'name' => {
274 datatype => 'string',
275 base_name => 'name',
276 description => 'The name of the customer, generally the company name.',
277 format => '',
278 read_only => 'false',
279 },
280 'owner_id' => {
281 datatype => 'string',
282 base_name => 'owner_id',
283 description => 'The alphanumeric string identifying the account owner.',
284 format => '',
285 read_only => 'false',
286 },
287 'phone_number' => {
288 datatype => 'string',
289 base_name => 'phone_number',
290 description => 'The phone number associated with the account.',
291 format => '',
292 read_only => 'false',
293 },
294 'postal_address' => {
295 datatype => 'string',
296 base_name => 'postal_address',
297 description => 'The postal address associated with the account.',
298 format => '',
299 read_only => 'false',
300 },
301 'pricing_plan' => {
302 datatype => 'string',
303 base_name => 'pricing_plan',
304 description => 'The pricing plan this customer is under.',
305 format => '',
306 read_only => 'false',
307 },
308 'pricing_plan_id' => {
309 datatype => 'string',
310 base_name => 'pricing_plan_id',
311 description => 'The alphanumeric string identifying the pricing plan.',
312 format => '',
313 read_only => 'false',
314 },
315 'security_contact_id' => {
316 datatype => 'string',
317 base_name => 'security_contact_id',
318 description => 'The alphanumeric string identifying the account's security contact.',
319 format => '',
320 read_only => 'false',
321 },
322 'technical_contact_id' => {
323 datatype => 'string',
324 base_name => 'technical_contact_id',
325 description => 'The alphanumeric string identifying the account's technical contact.',
326 format => '',
327 read_only => 'false',
328 },
329 });
330  
331 __PACKAGE__->openapi_types( {
332 'billing_contact_id' => 'string',
333 'billing_network_type' => 'string',
334 'billing_ref' => 'string',
335 'can_configure_wordpress' => 'boolean',
336 'can_reset_passwords' => 'boolean',
337 'can_upload_vcl' => 'boolean',
338 'force_2fa' => 'boolean',
339 'force_sso' => 'boolean',
340 'has_account_panel' => 'boolean',
341 'has_improved_events' => 'boolean',
342 'has_improved_ssl_config' => 'boolean',
343 'has_openstack_logging' => 'boolean',
344 'has_pci' => 'boolean',
345 'has_pci_passwords' => 'boolean',
346 'ip_whitelist' => 'string',
347 'legal_contact_id' => 'string',
348 'name' => 'string',
349 'owner_id' => 'string',
350 'phone_number' => 'string',
351 'postal_address' => 'string',
352 'pricing_plan' => 'string',
353 'pricing_plan_id' => 'string',
354 'security_contact_id' => 'string',
355 'technical_contact_id' => 'string'
356 } );
357  
358 __PACKAGE__->attribute_map( {
359 'billing_contact_id' => 'billing_contact_id',
360 'billing_network_type' => 'billing_network_type',
361 'billing_ref' => 'billing_ref',
362 'can_configure_wordpress' => 'can_configure_wordpress',
363 'can_reset_passwords' => 'can_reset_passwords',
364 'can_upload_vcl' => 'can_upload_vcl',
365 'force_2fa' => 'force_2fa',
366 'force_sso' => 'force_sso',
367 'has_account_panel' => 'has_account_panel',
368 'has_improved_events' => 'has_improved_events',
369 'has_improved_ssl_config' => 'has_improved_ssl_config',
370 'has_openstack_logging' => 'has_openstack_logging',
371 'has_pci' => 'has_pci',
372 'has_pci_passwords' => 'has_pci_passwords',
373 'ip_whitelist' => 'ip_whitelist',
374 'legal_contact_id' => 'legal_contact_id',
375 'name' => 'name',
376 'owner_id' => 'owner_id',
377 'phone_number' => 'phone_number',
378 'postal_address' => 'postal_address',
379 'pricing_plan' => 'pricing_plan',
380 'pricing_plan_id' => 'pricing_plan_id',
381 'security_contact_id' => 'security_contact_id',
382 'technical_contact_id' => 'technical_contact_id'
383 } );
384  
385 __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
386  
387 __PACKAGE__->openapi_nullable( {
388 'billing_contact_id' => 'true',
389 'billing_ref' => 'true',
390 'can_configure_wordpress' => 'true',
391 'legal_contact_id' => 'true',
392 'postal_address' => 'true',
393 'security_contact_id' => 'true',
394 'technical_contact_id' => 'true',
395 } );
396  
397  
398 1;