File Coverage

lib/Webservice/OVH/Me/Contact.pm
Criterion Covered Total %
statement 9 73 12.3
branch 0 10 0.0
condition n/a
subroutine 3 26 11.5
pod 22 22 100.0
total 34 131 25.9


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