| 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 | use strict; | ||
| 32 | use warnings; | ||
| 33 | use Carp qw{ carp croak }; | ||
| 34 | |||
| 35 | our $VERSION = 0.47; | ||
| 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 | sub _new_existing { | ||
| 55 | |||
| 56 | my ( $class, %params ) = @_; | ||
| 57 | |||
| 58 | die "Missing module" unless $params{module}; | ||
| 59 | die "Missing wrapper" unless $params{wrapper}; | ||
| 60 | die "Missing id" unless $params{id}; | ||
| 61 | |||
| 62 | my $module = $params{module}; | ||
| 63 | my $api_wrapper = $params{wrapper}; | ||
| 64 | my $contact_id = $params{id}; | ||
| 65 | |||
| 66 | my $response = $api_wrapper->rawCall( method => 'get', path => "/me/contact/$contact_id", noSignature => 0 ); | ||
| 67 | croak $response->error if $response->error; | ||
| 68 | |||
| 69 | my $id = $response->content->{id}; | ||
| 70 | my $porperties = $response->content; | ||
| 71 | |||
| 72 | my $self = bless { _module => $module, _api_wrapper => $api_wrapper, _id => $id, _properties => $porperties }, $class; | ||
| 73 | |||
| 74 | 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 | sub id { | ||
| 92 | |||
| 93 | my ($self) = @_; | ||
| 94 | |||
| 95 | 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 | sub properties { | ||
| 114 | |||
| 115 | my ($self) = @_; | ||
| 116 | |||
| 117 | my $api = $self->{_api_wrapper}; | ||
| 118 | my $contact_id = $self->{_id}; | ||
| 119 | my $response = $api->rawCall( method => 'get', path => "/me/contact/$contact_id", noSignature => 0 ); | ||
| 120 | croak $response->error if $response->error; | ||
| 121 | $self->{_properties} = $response->content; | ||
| 122 | |||
| 123 | 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 | sub address { | ||
| 141 | |||
| 142 | my ($self) = @_; | ||
| 143 | |||
| 144 | 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 | sub birth_city { | ||
| 162 | |||
| 163 | my ($self) = @_; | ||
| 164 | |||
| 165 | 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 | sub birth_country { | ||
| 183 | |||
| 184 | my ($self) = @_; | ||
| 185 | |||
| 186 | 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 | sub birth_day { | ||
| 204 | |||
| 205 | my ($self) = @_; | ||
| 206 | |||
| 207 | my $str_datetime = $self->{_properties}->{birthDay} . "T00:00:00+0000"; | ||
| 208 | my $datetime = Webservice::OVH::Helper->parse_datetime($str_datetime); | ||
| 209 | 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 | sub birth_zip { | ||
| 227 | |||
| 228 | my ($self) = @_; | ||
| 229 | |||
| 230 | 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 | sub cell_phone { | ||
| 248 | |||
| 249 | my ($self) = @_; | ||
| 250 | |||
| 251 | 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 | sub company_national_identification_number { | ||
| 269 | |||
| 270 | my ($self) = @_; | ||
| 271 | |||
| 272 | 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 | sub email { | ||
| 290 | |||
| 291 | my ($self) = @_; | ||
| 292 | |||
| 293 | 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 | sub fax { | ||
| 311 | |||
| 312 | my ($self) = @_; | ||
| 313 | |||
| 314 | 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 | sub first_name { | ||
| 332 | |||
| 333 | my ($self) = @_; | ||
| 334 | |||
| 335 | 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 | sub gender { | ||
| 353 | |||
| 354 | my ($self) = @_; | ||
| 355 | |||
| 356 | 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 | sub language { | ||
| 374 | |||
| 375 | my ($self) = @_; | ||
| 376 | |||
| 377 | 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 | sub last_name { | ||
| 395 | |||
| 396 | my ($self) = @_; | ||
| 397 | |||
| 398 | 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 | sub legal_form { | ||
| 416 | |||
| 417 | my ($self) = @_; | ||
| 418 | |||
| 419 | 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 | sub national_identification_number { | ||
| 437 | |||
| 438 | my ($self) = @_; | ||
| 439 | |||
| 440 | 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 | sub nationality { | ||
| 458 | |||
| 459 | my ($self) = @_; | ||
| 460 | |||
| 461 | 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 | sub organisation_name { | ||
| 479 | |||
| 480 | my ($self) = @_; | ||
| 481 | |||
| 482 | 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 | sub organisation_type { | ||
| 500 | |||
| 501 | my ($self) = @_; | ||
| 502 | |||
| 503 | 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 | sub phone { | ||
| 521 | |||
| 522 | my ($self) = @_; | ||
| 523 | |||
| 524 | 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 | sub vat { | ||
| 542 | |||
| 543 | my ($self) = @_; | ||
| 544 | |||
| 545 | return $self->{_properties}->{vat}; | ||
| 546 | } | ||
| 547 | |||
| 548 | 1; |