| 1 | package WWW::eNom::Contact; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 54 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 54 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 54 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 54 | ▶ | use MooseX::StrictConstructor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 54 | ▶ | use MooseX::Params::Validate; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 54 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 54 | ▶ | use WWW::eNom::Types qw( ContactType EmailAddress HashRef PhoneNumber Str ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 54 | ▶ | use WWW::eNom::PhoneNumber; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 54 | ▶ | use Data::Util qw( is_string ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 54 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 54 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 54 | our $VERSION = 'v2.6.0'; # VERSION | |||||||||||||||||||||||||||
| 20 | # ABSTRACT: Representation of eNom Contact | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 54 | has 'first_name' => ( | |||||||||||||||||||||||||||
| 23 | is => 'rw', | ||||||||||||||||||||||||||||
| 24 | isa => Str, | ||||||||||||||||||||||||||||
| 25 | required => 1, | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 54 | has 'last_name' => ( | |||||||||||||||||||||||||||
| 29 | is => 'rw', | ||||||||||||||||||||||||||||
| 30 | isa => Str, | ||||||||||||||||||||||||||||
| 31 | required => 1, | ||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 54 | has 'organization_name' => ( | |||||||||||||||||||||||||||
| 35 | is => 'rw', | ||||||||||||||||||||||||||||
| 36 | isa => Str, | ||||||||||||||||||||||||||||
| 37 | predicate => 'has_organization_name', | ||||||||||||||||||||||||||||
| 38 | clearer => 'clear_organization_name', | ||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 54 | has 'job_title' => ( | |||||||||||||||||||||||||||
| 42 | is => 'rw', | ||||||||||||||||||||||||||||
| 43 | isa => Str, | ||||||||||||||||||||||||||||
| 44 | predicate => 'has_job_title', | ||||||||||||||||||||||||||||
| 45 | clearer => 'clear_job_title', | ||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 54 | has 'address1' => ( | |||||||||||||||||||||||||||
| 49 | is => 'rw', | ||||||||||||||||||||||||||||
| 50 | isa => Str, | ||||||||||||||||||||||||||||
| 51 | required => 1, | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 54 | has 'address2' => ( | |||||||||||||||||||||||||||
| 55 | is => 'rw', | ||||||||||||||||||||||||||||
| 56 | isa => Str, | ||||||||||||||||||||||||||||
| 57 | predicate => 'has_address2', | ||||||||||||||||||||||||||||
| 58 | clearer => 'clear_address2', | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 54 | has 'city' => ( | |||||||||||||||||||||||||||
| 62 | is => 'rw', | ||||||||||||||||||||||||||||
| 63 | isa => Str, | ||||||||||||||||||||||||||||
| 64 | required => 1, | ||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 54 | has 'state' => ( | |||||||||||||||||||||||||||
| 68 | is => 'rw', | ||||||||||||||||||||||||||||
| 69 | isa => Str, | ||||||||||||||||||||||||||||
| 70 | predicate => 'has_state', | ||||||||||||||||||||||||||||
| 71 | clearer => 'clear_state', | ||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 54 | has 'country' => ( | |||||||||||||||||||||||||||
| 75 | is => 'rw', | ||||||||||||||||||||||||||||
| 76 | isa => Str, | ||||||||||||||||||||||||||||
| 77 | required => 1, | ||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 54 | has 'zipcode' => ( | |||||||||||||||||||||||||||
| 81 | is => 'rw', | ||||||||||||||||||||||||||||
| 82 | isa => Str, | ||||||||||||||||||||||||||||
| 83 | required => 1, | ||||||||||||||||||||||||||||
| 84 | ); | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 54 | has 'email' => ( | |||||||||||||||||||||||||||
| 87 | is => 'rw', | ||||||||||||||||||||||||||||
| 88 | isa => EmailAddress, | ||||||||||||||||||||||||||||
| 89 | required => 1, | ||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 54 | has 'phone_number' => ( | |||||||||||||||||||||||||||
| 93 | is => 'rw', | ||||||||||||||||||||||||||||
| 94 | isa => PhoneNumber, | ||||||||||||||||||||||||||||
| 95 | required => 1, | ||||||||||||||||||||||||||||
| 96 | coerce => 1, | ||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 54 | has 'fax_number' => ( | |||||||||||||||||||||||||||
| 100 | is => 'rw', | ||||||||||||||||||||||||||||
| 101 | isa => PhoneNumber, | ||||||||||||||||||||||||||||
| 102 | predicate => 'has_fax_number', | ||||||||||||||||||||||||||||
| 103 | clearer => 'clear_fax_number', | ||||||||||||||||||||||||||||
| 104 | coerce => 1, | ||||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | sub BUILD { | ||||||||||||||||||||||||||||
| 108 | 47 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 47 | ▶ | if( $self->has_organization_name ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 3 | ▶ | if( !$self->has_job_title || !$self->has_fax_number ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_job_title && $self->has_fax_number
MC/DC100%2/2
$self->has_job_title && $self->has_fax_number
$self->has_job_title
$self->has_fax_number
Truth table100%3/3
A && B
A= $self->has_job_titleB= $self->has_fax_number
| |||||||||||||||||||||||||||||
| 112 | 2 | croak 'Contacts with an organization_name require a job_title and fax_number'; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | sub construct_creation_request { | ||||||||||||||||||||||||||||
| 118 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
construct_creation_request: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 119 | 0 | my ( $contact_type ) = pos_validated_list( \@_, { isa => ContactType, optional => 1 } ); | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $creation_request = { | ||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 122 | FirstName => $self->first_name, | ||||||||||||||||||||||||||||
| 123 | LastName => $self->last_name, | ||||||||||||||||||||||||||||
| 124 | $self->has_organization_name ? ( OrganizationName => $self->organization_name ) : ( ), | ||||||||||||||||||||||||||||
| 125 | $self->has_job_title ? ( JobTitle => $self->job_title ) : ( ), | ||||||||||||||||||||||||||||
| 126 | Address1 => $self->address1, | ||||||||||||||||||||||||||||
| 127 | $self->has_address2 ? ( Address2 => $self->address2 ) : ( ), | ||||||||||||||||||||||||||||
| 128 | City => $self->city, | ||||||||||||||||||||||||||||
| 129 | $self->has_state ? ( StateProvince => $self->state ) : ( ), | ||||||||||||||||||||||||||||
| 130 | Country => $self->country, | ||||||||||||||||||||||||||||
| 131 | PostalCode => $self->zipcode, | ||||||||||||||||||||||||||||
| 132 | EmailAddress => $self->email, | ||||||||||||||||||||||||||||
| 133 | Phone => sprintf('+%s.%s', $self->phone_number->country_code, $self->phone_number->number ), | ||||||||||||||||||||||||||||
| 134 | $self->has_fax_number ? ( Fax => sprintf('+%s.%s', $self->fax_number->country_code, $self->fax_number->number ) ) : ( ), | ||||||||||||||||||||||||||||
| 135 | }; | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if( $contact_type ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | for my $key ( keys %{ $creation_request } ) { | |||||||||||||||||||||||||||
| 139 | 0 | $creation_request->{ $contact_type . $key } = delete $creation_request->{ $key }; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | return $creation_request; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | sub construct_from_response { | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
construct_from_response: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | 0 | my ( $response ) = pos_validated_list( \@_, { isa => HashRef } ); | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | return try { | ||||||||||||||||||||||||||||
| 151 | return $self->new({ | ||||||||||||||||||||||||||||
| 152 | first_name => $response->{'FirstName'}, | ||||||||||||||||||||||||||||
| 153 | last_name => $response->{'LastName'}, | ||||||||||||||||||||||||||||
| 154 | is_string( $response->{'OrganizationName'} ) ? ( organization_name => $response->{'OrganizationName'} ) : ( ), | ||||||||||||||||||||||||||||
| 155 | is_string( $response->{'JobTitle'} ) ? ( job_title => $response->{'JobTitle'} ) : ( ), | ||||||||||||||||||||||||||||
| 156 | address1 => $response->{'Address1'}, | ||||||||||||||||||||||||||||
| 157 | is_string( $response->{'Address2'} ) ? ( address2 => $response->{'Address2'} ) : ( ), | ||||||||||||||||||||||||||||
| 158 | city => $response->{'City'}, | ||||||||||||||||||||||||||||
| 159 | is_string( $response->{'StateProvince'} ) ? ( state => $response->{'StateProvince'} ) : ( ), | ||||||||||||||||||||||||||||
| 160 | country => $response->{'Country'}, | ||||||||||||||||||||||||||||
| 161 | zipcode => $response->{'PostalCode'}, | ||||||||||||||||||||||||||||
| 162 | email => $response->{'EmailAddress'}, | ||||||||||||||||||||||||||||
| 163 | phone_number => $response->{'Phone'}, | ||||||||||||||||||||||||||||
| 164 | 0 | ▶ | is_string( $response->{'Fax'} ) ? ( fax_number => $response->{'Fax'} ) : ( ), | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 165 | }); | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | catch { | ||||||||||||||||||||||||||||
| 168 | 0 | ▶ | croak "Error constructing contact from response: $_"; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 169 | 0 | }; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 54 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 173 | 54 | 1; | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | __END__ | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =pod | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =head1 NAME | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | WWW::eNom::Contact - Representation of eNom Contact | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | use strict; | ||||||||||||||||||||||||||||
| 186 | use warnings; | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | use WWW::eNom; | ||||||||||||||||||||||||||||
| 189 | use WWW::eNom::Contact; | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | my $api = WWW::eNom->new( ... ); | ||||||||||||||||||||||||||||
| 192 | my $contact = WWW::eNom::Contact->new( ... ); | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | # New Contact Object | ||||||||||||||||||||||||||||
| 195 | my $contact = WWW::eNom::Contact->new( | ||||||||||||||||||||||||||||
| 196 | first_name => 'Ada', | ||||||||||||||||||||||||||||
| 197 | last_name => 'Byron', | ||||||||||||||||||||||||||||
| 198 | organization_name => 'Lovelace', # Optional | ||||||||||||||||||||||||||||
| 199 | job_title => 'Countess', # Optional if no organization_name, otherwise required | ||||||||||||||||||||||||||||
| 200 | address1 => 'University of London', | ||||||||||||||||||||||||||||
| 201 | address2 => 'Analytical Engine Dept', # Optional | ||||||||||||||||||||||||||||
| 202 | city => 'London', | ||||||||||||||||||||||||||||
| 203 | #state => 'Texas', # Optional, primarily used for US Contacts | ||||||||||||||||||||||||||||
| 204 | country => 'GB', | ||||||||||||||||||||||||||||
| 205 | zipcode => 'WC1E 7HU', | ||||||||||||||||||||||||||||
| 206 | email => 'ada.byron@lovelace.com', | ||||||||||||||||||||||||||||
| 207 | phone_number => '18005551212', | ||||||||||||||||||||||||||||
| 208 | fax_number => '18005551212', # Optional if no organization_name, otherwise required | ||||||||||||||||||||||||||||
| 209 | ); | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | # Contact Creation | ||||||||||||||||||||||||||||
| 212 | my $registrant_contact_creation_payload = $contact->construct_creation_request('Registrant'); | ||||||||||||||||||||||||||||
| 213 | my $admin_contact_creation_payload = $contact->construct_creation_request('Admin'); | ||||||||||||||||||||||||||||
| 214 | my $technical_contact_creation_payload = $contact->construct_creation_request('Tech'); | ||||||||||||||||||||||||||||
| 215 | my $billing_contact_creation_payload = $contact->construct_creation_request('AuxBilling'); | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | my $response = $api->submit({ | ||||||||||||||||||||||||||||
| 218 | method => 'Purchase', | ||||||||||||||||||||||||||||
| 219 | params => { | ||||||||||||||||||||||||||||
| 220 | ..., | ||||||||||||||||||||||||||||
| 221 | %{ $registrant_contact_creation_payload }, | ||||||||||||||||||||||||||||
| 222 | %{ $admin_contact_creation_payload }, | ||||||||||||||||||||||||||||
| 223 | %{ $technical_contact_creation_payload }, | ||||||||||||||||||||||||||||
| 224 | %{ $billing_contact_creation_payload }, | ||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | }); | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | # Contact Retrieval | ||||||||||||||||||||||||||||
| 229 | my $response = $self->submit({ | ||||||||||||||||||||||||||||
| 230 | method => 'GetContacts', | ||||||||||||||||||||||||||||
| 231 | params => { | ||||||||||||||||||||||||||||
| 232 | Domain => $domain_name | ||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | }); | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | my $contacts; | ||||||||||||||||||||||||||||
| 237 | for my $contact_type (qw( Registrant Admin Tech AuxBilling )) { | ||||||||||||||||||||||||||||
| 238 | my $raw_contact_response = $response->{GetContacts}{$contact_type}; | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | my $common_contact_response; | ||||||||||||||||||||||||||||
| 241 | for my $field ( keys %{ $raw_contact_response } ) { | ||||||||||||||||||||||||||||
| 242 | if( $field !~ m/$contact_type/ ) { | ||||||||||||||||||||||||||||
| 243 | next; | ||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | $common_contact_response->{ substr( $field, length( $contact_type ) ) } = | ||||||||||||||||||||||||||||
| 247 | $raw_contact_response->{ $field } // { }; | ||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | $contacts->{ $contact_type } = WWW::eNom::Contact->construct_from_response( $common_contact_response ); | ||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | Representation of an L<eNom|http://www.enom.com> Contact. | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | =head2 B<first_name> | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | =head2 B<last_name> | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | =head2 organization_name | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | Predicate of has_organization_name and clearer of clear_organization_name. | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | B<NOTE> If the organization_name is specified then the previously optional L<job_title|WWW::eNom::Contact/job_title> and L<fax_number|WWW::eNom::Contact/fax_number> attributes become B<required>. | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | =head2 job_title | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | Predicate of has_job_title and clearer of clear_job_title. | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | B<NOTE> this field is B<required> if an L<organization_name|WWW::eNom::Contact/organization_name> was provided. | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | =head2 B<address1> | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | =head2 address2 | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | Predicate of has_address2 and clearer of clear_address2 | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | =head2 B<city> | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | =head2 state | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | Required for Contacts with a US Address, the full name of the state so Texas rather than TX should be used. | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | Predicate of has_state and clearer of clear_state. | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | =head2 B<country> | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | The L<ISO-3166-1 alpha-2 (two character country code)|https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2> is preferred. You can use a full country name, just keep in mind your response from eNom will be the country code. | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | =head2 B<zipcode> | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | =head2 B<email> | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | =head2 B<phone_number> | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | An instance of L<WWW::eNom::PhoneNumber>, but this will coerce from a L<Number::Phone> object or a string based representation of the phone number. This will also stringify to a human readable phone number. | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | =head2 fax_number | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | An instance of L<WWW::eNom::PhoneNumber>, but this will coerce from a L<Number::Phone> object or a string based representation of the phone number. This will also stringify to a human readable phone number. | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | Predicate of has_fax_number and clearer of clear_fax_number. | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | B<NOTE> this field is B<required> if an L<organization_name|WWW::eNom::Contact/organization_name> was provided. | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | =head1 METHODS | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | =head2 construct_creation_request | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | my $api = WWW::eNom->new( ... ); | ||||||||||||||||||||||||||||
| 315 | my $contact = WWW::eNom::Contact->new( ... ); | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | my $registrant_contact_creation_payload = $contact->construct_creation_request('Registrant'); | ||||||||||||||||||||||||||||
| 318 | my $admin_contact_creation_payload = $contact->construct_creation_request('Admin'); | ||||||||||||||||||||||||||||
| 319 | my $technical_contact_creation_payload = $contact->construct_creation_request('Tech'); | ||||||||||||||||||||||||||||
| 320 | my $billing_contact_creation_payload = $contact->construct_creation_request('AuxBilling'); | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | my $response = $api->submit({ | ||||||||||||||||||||||||||||
| 323 | method => 'Purchase', | ||||||||||||||||||||||||||||
| 324 | params => { | ||||||||||||||||||||||||||||
| 325 | ..., | ||||||||||||||||||||||||||||
| 326 | %{ $registrant_contact_creation_payload }, | ||||||||||||||||||||||||||||
| 327 | %{ $admin_contact_creation_payload }, | ||||||||||||||||||||||||||||
| 328 | %{ $technical_contact_creation_payload }, | ||||||||||||||||||||||||||||
| 329 | %{ $billing_contact_creation_payload }, | ||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | }); | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | Converts $self into a HashRef suitable for creation of a contact with L<eNom|https://www.enom.com>. Accepts a string that must be one of the following: | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | =over 4 | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | =item Registrant | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | =item Admin | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | =item Tech | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | =item AuxBilling | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | AuxBilling is what eNom calls the "Billing" contact for WHOIS data since the Billing contact is actually the reseller. | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | =back | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | =head2 construct_from_response | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | my $response = $api->submit({ | ||||||||||||||||||||||||||||
| 352 | method => 'GetContacts', | ||||||||||||||||||||||||||||
| 353 | params => { | ||||||||||||||||||||||||||||
| 354 | Domain => $domain_name | ||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | }); | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | my $contacts; | ||||||||||||||||||||||||||||
| 359 | for my $contact_type (qw( Registrant Admin Tech AuxBilling )) { | ||||||||||||||||||||||||||||
| 360 | my $raw_contact_response = $response->{GetContacts}{$contact_type}; | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | my $common_contact_response; | ||||||||||||||||||||||||||||
| 363 | for my $field ( keys %{ $raw_contact_response } ) { | ||||||||||||||||||||||||||||
| 364 | if( $field !~ m/$contact_type/ ) { | ||||||||||||||||||||||||||||
| 365 | next; | ||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | $common_contact_response->{ substr( $field, length( $contact_type ) ) } = | ||||||||||||||||||||||||||||
| 369 | $raw_contact_response->{ $field } // { }; | ||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | $contacts->{ $contact_type } = WWW::eNom::Contact->construct_from_response( $common_contact_response ); | ||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 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. | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | =cut | ||||||||||||||||||||||||||||