NAME

WWW::eNom::Contact - Representation of eNom Contact

SYNOPSIS

use strict;
use warnings;

use WWW::eNom;
use WWW::eNom::Contact;

my $api     = WWW::eNom->new( ... );
my $contact = WWW::eNom::Contact->new( ... );

# New Contact Object
my $contact = WWW::eNom::Contact->new(
    first_name        => 'Ada',
    last_name         => 'Byron',
    organization_name => 'Lovelace',                # Optional
    job_title         => 'Countess',                # Optional if no organization_name, otherwise required
    address1          => 'University of London',
    address2          => 'Analytical Engine Dept',  # Optional
    city              => 'London',
    #state            => 'Texas',                   # Optional, primarily used for US Contacts
    country           => 'GB',
    zipcode           => 'WC1E 7HU',
    email             => 'ada.byron@lovelace.com',
    phone_number      => '18005551212',
    fax_number        => '18005551212',             # Optional if no organization_name, otherwise required
);

# Contact Creation
my $registrant_contact_creation_payload = $contact->construct_creation_request('Registrant');
my $admin_contact_creation_payload      = $contact->construct_creation_request('Admin');
my $technical_contact_creation_payload  = $contact->construct_creation_request('Tech');
my $billing_contact_creation_payload    = $contact->construct_creation_request('AuxBilling');

my $response = $api->submit({
    method => 'Purchase',
    params => {
        ...,
        %{ $registrant_contact_creation_payload },
        %{ $admin_contact_creation_payload },
        %{ $technical_contact_creation_payload },
        %{ $billing_contact_creation_payload },
    }
});

# Contact Retrieval
my $response = $self->submit({
    method => 'GetContacts',
    params => {
        Domain => $domain_name
    }
});

my $contacts;
for my $contact_type (qw( Registrant Admin Tech AuxBilling )) {
    my $raw_contact_response = $response->{GetContacts}{$contact_type};

    my $common_contact_response;
    for my $field ( keys %{ $raw_contact_response } ) {
        if( $field !~ m/$contact_type/ ) {
            next;
        }

        $common_contact_response->{ substr( $field, length( $contact_type ) ) } =
            $raw_contact_response->{ $field } // { };
    }

    $contacts->{ $contact_type } = WWW::eNom::Contact->construct_from_response( $common_contact_response );
}

DESCRIPTION

Representation of an eNom Contact.

ATTRIBUTES

first_name

last_name

organization_name

Predicate of has_organization_name and clearer of clear_organization_name.

NOTE If the organization_name is specified then the previously optional job_title and fax_number attributes become required.

job_title

Predicate of has_job_title and clearer of clear_job_title.

NOTE this field is required if an organization_name was provided.

address1

address2

Predicate of has_address2 and clearer of clear_address2

city

state

Required for Contacts with a US Address, the full name of the state so Texas rather than TX should be used.

Predicate of has_state and clearer of clear_state.

country

The ISO-3166-1 alpha-2 (two character country code) is preferred. You can use a full country name, just keep in mind your response from eNom will be the country code.

zipcode

email

phone_number

An instance of WWW::eNom::PhoneNumber, but this will coerce from a Number::Phone object or a string based representation of the phone number. This will also stringify to a human readable phone number.

fax_number

An instance of WWW::eNom::PhoneNumber, but this will coerce from a Number::Phone object or a string based representation of the phone number. This will also stringify to a human readable phone number.

Predicate of has_fax_number and clearer of clear_fax_number.

NOTE this field is required if an organization_name was provided.

METHODS

construct_creation_request

my $api     = WWW::eNom->new( ... );
my $contact = WWW::eNom::Contact->new( ... );

my $registrant_contact_creation_payload = $contact->construct_creation_request('Registrant');
my $admin_contact_creation_payload      = $contact->construct_creation_request('Admin');
my $technical_contact_creation_payload  = $contact->construct_creation_request('Tech');
my $billing_contact_creation_payload    = $contact->construct_creation_request('AuxBilling');

my $response = $api->submit({
    method => 'Purchase',
    params => {
        ...,
        %{ $registrant_contact_creation_payload },
        %{ $admin_contact_creation_payload },
        %{ $technical_contact_creation_payload },
        %{ $billing_contact_creation_payload },
    }
});

Converts $self into a HashRef suitable for creation of a contact with eNom. Accepts a string that must be one of the following:

Registrant
Admin
Tech
AuxBilling

AuxBilling is what eNom calls the "Billing" contact for WHOIS data since the Billing contact is actually the reseller.

construct_from_response

my $response = $api->submit({
    method => 'GetContacts',
    params => {
        Domain => $domain_name
    }
});

my $contacts;
for my $contact_type (qw( Registrant Admin Tech AuxBilling )) {
    my $raw_contact_response = $response->{GetContacts}{$contact_type};

    my $common_contact_response;
    for my $field ( keys %{ $raw_contact_response } ) {
        if( $field !~ m/$contact_type/ ) {
            next;
        }

        $common_contact_response->{ substr( $field, length( $contact_type ) ) } =
            $raw_contact_response->{ $field } // { };
    }

    $contacts->{ $contact_type } = WWW::eNom::Contact->construct_from_response( $common_contact_response );
}

Getting a contact from a response is a bit more involved then other data marshallers. This is because the fields are all prefixed with the contact type. Rather than having just FirstName the response will contain a field like TechFirstName. This must be processed off before feeding in the HashRef of the response into the construct_from_response method. Returned is an instance of self.