Webservice/OVH/Me/Contact.pm

filter: Statementstmt 14.6% 11 / 75 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 11.5% 3 / 26 Podpod 100% 22 / 22 totaltotal 27.0% 36 / 133 CC 6 SCAR 19.0
CC
6
Cov
13%
_new_existing
30.0
properties
6.0
id
2.0
CRAP 6.7
« Webservice/OVH/Order/Domain/Zone.pm ↑ Summary Webservice/OVH/Hosting.pm »
1 package Webservice::OVH::Me::Contact;
2  
3 =encoding utf-8
4  
5 =head1 NAME
6  
7 Webservice::OVH::Me::Contact
8  
9 =head1 SYNOPSIS
10  
11 use Webservice::OVH;
12
13 my $ovh = Webservice::OVH->new_from_json("credentials.json");
14
15 my $contacts = $ovh->me->contacts;
16
17 foreach my $contact (@$contact) {
18
19 print $contact->birth_city;
20 }
21  
22 =head1 DESCRIPTION
23  
24 Propvides access to contact properties.
25 No managing methods are available at the moment.
26  
27 =head1 METHODS
28  
29 =cut
30  
31 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 36 ▶use Carp qw{ carp croak };
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 36 our $VERSION = 0.48;
36  
37 =head2 _new_existing
38  
39 Internal Method to create the Contact object.
40 This method is not ment to be called directly.
41  
42 =over
43  
44 =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object, $contact_id - api id
45  
46 =item * Return: L<Webservice::OVH::Me::Contact>
47  
48 =item * Synopsis: Webservice::OVH::Me::Contact->_new($ovh_api_wrapper, $contact_id, $module);
49  
50 =back
51  
52 =cut
53  
54 0 ▶sub _new_existing {
Subroutine _new_existing: not called CC=5 SCAR=34.0
55  
56 0 my ( $class, %params ) = @_;
57
58 0 ▶ die "Missing module" unless $params{module};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"module"} 0 0 0
59 0 ▶ die "Missing wrapper" unless $params{wrapper};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"wrapper"} 0 0 0
60 0 ▶ die "Missing id" unless $params{id};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"id"} 0 0 0
61  
62 0 my $module = $params{module};
63 0 my $api_wrapper = $params{wrapper};
64 0 my $contact_id = $params{id};
65  
66 0 my $response = $api_wrapper->rawCall( method => 'get', path => "/me/contact/$contact_id", noSignature => 0 );
67 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
68  
69 0 my $id = $response->content->{id};
70 0 my $porperties = $response->content;
71  
72 0 my $self = bless { _module => $module, _api_wrapper => $api_wrapper, _id => $id, _properties => $porperties }, $class;
73  
74 0 return $self;
75 }
76  
77 =head2 id
78  
79 Returns the api id.
80  
81 =over
82  
83 =item * Return: VALUE
84  
85 =item * Synopsis: my $id = $contact->id;
86  
87 =back
88  
89 =cut
90  
91 0 ▶sub id {
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
92  
93 0 my ($self) = @_;
94  
95 0 return $self->{_id};
96 }
97  
98 =head2 properties
99  
100 Retrieves properties.
101 This method updates the intern property variable.
102  
103 =over
104  
105 =item * Return: HASH
106  
107 =item * Synopsis: my $properties = $contact->properties;
108  
109 =back
110  
111 =cut
112  
113 0 ▶sub properties {
Subroutine properties: not called CC=2 SCAR=17.9
Pod documented
114  
115 0 my ($self) = @_;
116  
117 0 my $api = $self->{_api_wrapper};
118 0 my $contact_id = $self->{_id};
119 0 my $response = $api->rawCall( method => 'get', path => "/me/contact/$contact_id", noSignature => 0 );
120 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
121 0 $self->{_properties} = $response->content;
122  
123 0 return $self->{_properties};
124 }
125  
126 =head2 address
127  
128 Exposed property value.
129  
130 =over
131  
132 =item * Return: HASH
133  
134 =item * Synopsis: my $address = $contact->address;
135  
136 =back
137  
138 =cut
139  
140 0 ▶sub address {
Subroutine address: not called CC=1 SCAR=6.9
Pod documented
141  
142 0 my ($self) = @_;
143  
144 0 return $self->{_properties}->{address};
145 }
146  
147 =head2 birth_city
148  
149 Exposed property value.
150  
151 =over
152  
153 =item * Return: VALUE
154  
155 =item * Synopsis: my $birth_city = $contact->birth_city;
156  
157 =back
158  
159 =cut
160  
161 0 ▶sub birth_city {
Subroutine birth_city: not called CC=1 SCAR=6.9
Pod documented
162  
163 0 my ($self) = @_;
164  
165 0 return $self->{_properties}->{birthCity};
166 }
167  
168 =head2 birth_country
169  
170 Exposed property value.
171  
172 =over
173  
174 =item * Return: VALUE
175  
176 =item * Synopsis: my $birth_country = $contact->birth_country;
177  
178 =back
179  
180 =cut
181  
182 0 ▶sub birth_country {
Subroutine birth_country: not called CC=1 SCAR=6.9
Pod documented
183  
184 0 my ($self) = @_;
185  
186 0 return $self->{_properties}->{birthCountry};
187 }
188  
189 =head2 birth_day
190  
191 Exposed property value.
192  
193 =over
194  
195 =item * Return: DateTime
196  
197 =item * Synopsis: my $birth_day = $contact->birth_day;
198  
199 =back
200  
201 =cut
202  
203 0 ▶sub birth_day {
Subroutine birth_day: not called CC=1 SCAR=6.9
Pod documented
204  
205 0 my ($self) = @_;
206  
207 0 my $str_datetime = $self->{_properties}->{birthDay} . "T00:00:00+0000";
208 0 my $datetime = Webservice::OVH::Helper->parse_datetime($str_datetime);
209 0 return $datetime;
210 }
211  
212 =head2 birth_zip
213  
214 Exposed property value.
215  
216 =over
217  
218 =item * Return: VALUE
219  
220 =item * Synopsis: my $birth_zip = $contact->birth_zip;
221  
222 =back
223  
224 =cut
225  
226 0 ▶sub birth_zip {
Subroutine birth_zip: not called CC=1 SCAR=6.9
Pod documented
227  
228 0 my ($self) = @_;
229  
230 0 return $self->{_properties}->{birthZip};
231 }
232  
233 =head2 cell_phone
234  
235 Exposed property value.
236  
237 =over
238  
239 =item * Return: VALUE
240  
241 =item * Synopsis: my $cell_phone = $contact->cell_phone;
242  
243 =back
244  
245 =cut
246  
247 0 ▶sub cell_phone {
Subroutine cell_phone: not called CC=1 SCAR=6.9
Pod documented
248  
249 0 my ($self) = @_;
250  
251 0 return $self->{_properties}->{cellPhone};
252 }
253  
254 =head2 company_national_identification_number
255  
256 Exposed property value.
257  
258 =over
259  
260 =item * Return: VALUE
261  
262 =item * Synopsis: my $company_national_identification_number = $contact->company_national_identification_number;
263  
264 =back
265  
266 =cut
267  
268 0 ▶sub company_national_identification_number {
Subroutine company_national_identification_number: not called CC=1 SCAR=6.9
Pod documented
269  
270 0 my ($self) = @_;
271  
272 0 return $self->{_properties}->{companyNationalIdentificationNumber};
273 }
274  
275 =head2 email
276  
277 Exposed property value.
278  
279 =over
280  
281 =item * Return: VALUE
282  
283 =item * Synopsis: my $email = $contact->email;
284  
285 =back
286  
287 =cut
288  
289 0 ▶sub email {
Subroutine email: not called CC=1 SCAR=6.9
Pod documented
290  
291 0 my ($self) = @_;
292  
293 0 return $self->{_properties}->{email};
294 }
295  
296 =head2 fax
297  
298 Exposed property value.
299  
300 =over
301  
302 =item * Return: VALUE
303  
304 =item * Synopsis: my $fax = $contact->fax;
305  
306 =back
307  
308 =cut
309  
310 0 ▶sub fax {
Subroutine fax: not called CC=1 SCAR=6.9
Pod documented
311  
312 0 my ($self) = @_;
313  
314 0 return $self->{_properties}->{fax};
315 }
316  
317 =head2 first_name
318  
319 Exposed property value.
320  
321 =over
322  
323 =item * Return: VALUE
324  
325 =item * Synopsis: my $first_name = $contact->first_name;
326  
327 =back
328  
329 =cut
330  
331 0 ▶sub first_name {
Subroutine first_name: not called CC=1 SCAR=6.9
Pod documented
332  
333 0 my ($self) = @_;
334  
335 0 return $self->{_properties}->{firstName};
336 }
337  
338 =head2 gender
339  
340 Exposed property value.
341  
342 =over
343  
344 =item * Return: VALUE
345  
346 =item * Synopsis: my $gender = $contact->gender;
347  
348 =back
349  
350 =cut
351  
352 0 ▶sub gender {
Subroutine gender: not called CC=1 SCAR=6.9
Pod documented
353  
354 0 my ($self) = @_;
355  
356 0 return $self->{_properties}->{gender};
357 }
358  
359 =head2 language
360  
361 Exposed property value.
362  
363 =over
364  
365 =item * Return: VALUE
366  
367 =item * Synopsis: my $language = $contact->language;
368  
369 =back
370  
371 =cut
372  
373 0 ▶sub language {
Subroutine language: not called CC=1 SCAR=6.9
Pod documented
374  
375 0 my ($self) = @_;
376  
377 0 return $self->{_properties}->{language};
378 }
379  
380 =head2 last_name
381  
382 Exposed property value.
383  
384 =over
385  
386 =item * Return: VALUE
387  
388 =item * Synopsis: my $last_name = $contact->last_name;
389  
390 =back
391  
392 =cut
393  
394 0 ▶sub last_name {
Subroutine last_name: not called CC=1 SCAR=6.9
Pod documented
395  
396 0 my ($self) = @_;
397  
398 0 return $self->{_properties}->{lastName};
399 }
400  
401 =head2 legal_form
402  
403 Exposed property value.
404  
405 =over
406  
407 =item * Return: VALUE
408  
409 =item * Synopsis: my $legal_form = $contact->legal_form;
410  
411 =back
412  
413 =cut
414  
415 0 ▶sub legal_form {
Subroutine legal_form: not called CC=1 SCAR=6.9
Pod documented
416  
417 0 my ($self) = @_;
418  
419 0 return $self->{_properties}->{legalForm};
420 }
421  
422 =head2 national_identification_number
423  
424 Exposed property value.
425  
426 =over
427  
428 =item * Return: VALUE
429  
430 =item * Synopsis: my $national_identification_number = $contact->national_identification_number;
431  
432 =back
433  
434 =cut
435  
436 0 ▶sub national_identification_number {
Subroutine national_identification_number: not called CC=1 SCAR=6.9
Pod documented
437  
438 0 my ($self) = @_;
439  
440 0 return $self->{_properties}->{nationalIdentificationNumber};
441 }
442  
443 =head2 nationality
444  
445 Exposed property value.
446  
447 =over
448  
449 =item * Return: VALUE
450  
451 =item * Synopsis: my $nationality = $contact->nationality;
452  
453 =back
454  
455 =cut
456  
457 0 ▶sub nationality {
Subroutine nationality: not called CC=1 SCAR=6.9
Pod documented
458  
459 0 my ($self) = @_;
460  
461 0 return $self->{_properties}->{nationality};
462 }
463  
464 =head2 organisation_name
465  
466 Exposed property value.
467  
468 =over
469  
470 =item * Return: VALUE
471  
472 =item * Synopsis: my $organisation_name = $contact->organisation_name;
473  
474 =back
475  
476 =cut
477  
478 0 ▶sub organisation_name {
Subroutine organisation_name: not called CC=1 SCAR=6.9
Pod documented
479  
480 0 my ($self) = @_;
481  
482 0 return $self->{_properties}->{organisationName};
483 }
484  
485 =head2 organisation_type
486  
487 Exposed property value.
488  
489 =over
490  
491 =item * Return: VALUE
492  
493 =item * Synopsis: my $organisation_type = $contact->organisation_type;
494  
495 =back
496  
497 =cut
498  
499 0 ▶sub organisation_type {
Subroutine organisation_type: not called CC=1 SCAR=6.9
Pod documented
500  
501 0 my ($self) = @_;
502  
503 0 return $self->{_properties}->{organisationType};
504 }
505  
506 =head2 phone
507  
508 Exposed property value.
509  
510 =over
511  
512 =item * Return: VALUE
513  
514 =item * Synopsis: my $phone = $contact->phone;
515  
516 =back
517  
518 =cut
519  
520 0 ▶sub phone {
Subroutine phone: not called CC=1 SCAR=6.9
Pod documented
521  
522 0 my ($self) = @_;
523  
524 0 return $self->{_properties}->{phone};
525 }
526  
527 =head2 vat
528  
529 Exposed property value.
530  
531 =over
532  
533 =item * Return: VALUE
534  
535 =item * Synopsis: my $vat = $contact->vat;
536  
537 =back
538  
539 =cut
540  
541 0 ▶sub vat {
Subroutine vat: not called CC=1 SCAR=6.9
Pod documented
542  
543 0 my ($self) = @_;
544  
545 0 return $self->{_properties}->{vat};
546 }
547  
548 36 1;
« Webservice/OVH/Order/Domain/Zone.pm ↑ Summary Webservice/OVH/Hosting.pm »