summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-02-19 20:03:01 -0800
committerIvan Kohler <ivan@freeside.biz>2012-02-19 20:03:01 -0800
commit66cc0307173888d7c5f907d055186e3031faf33b (patch)
treef845bd2c919d3c6ee8070a64d5b0f02418e1274d
parentc767137d8443af8fea41b7513dd0746740999ca4 (diff)
- Apply patch from Justin Hunter:HEADmaster
+ Setting custom nameservers (closes: CPAN#66902) + EPP phone number conversion (closes: CPAN#49340) + $c can now have same keys as OpenSRS api (postal_code, address1, address2, etc) while keeping backcompat (address, zip, etc) + massive country list was replaced with Locales (closes: CPAN#49341) - reorder changelog newest first - doc: update Authors
-rw-r--r--Changes35
-rw-r--r--Makefile.PL8
-rw-r--r--lib/Net/OpenSRS.pm309
3 files changed, 72 insertions, 280 deletions
diff --git a/Changes b/Changes
index 060a1a6..5552686 100644
--- a/Changes
+++ b/Changes
@@ -1,21 +1,30 @@
-0.01 Thu Feb 16 2006
- - Initial release to CPAN. Yay.
+0.07 unreleased
+ - Apply patch from Justin Hunter:
+ + Setting custom nameservers (closes: CPAN#66902)
+ + EPP phone number conversion (closes: CPAN#49340)
+ + $c can now have same keys as OpenSRS api (postal_code, address1,
+ address2, etc) while keeping backcompat (address, zip, etc)
+ + massive country list was replaced with Locales (closes: CPAN#49341)
+ - reorder changelog newest first
+ - doc: update Authors
-0.02 Sat Apr 8 2006
- - Allow countries to be two letter codes or the full country name.
- Contributed by Sten Spans <sten@bit.nl>.
+0.06 Thu Sep 16 00:21:06 EDT 2010
+ - escape the XML special characters
-0.03 Tue Sep 1 2009
- - Ugly fix for Expat parser error due to spaces in an element name
- in the OpenSRS renew domain response.
+0.05 Sun Jun 27 16:54:23 EDT 2010
+ - Correct de-nastification to handle single item dt_assoc
+ (eg belongs_to_rsp response)
0.04
- Correct de-nastification to handle lists
-0.05 Sun Jun 27 16:54:23 EDT 2010
- - Correct de-nastification to handle single item dt_assoc
- (eg belongs_to_rsp response)
+0.03 Tue Sep 1 2009
+ - Ugly fix for Expat parser error due to spaces in an element name
+ in the OpenSRS renew domain response.
-0.06 Thu Sep 16 00:21:06 EDT 2010
- - escape the XML special characters
+0.02 Sat Apr 8 2006
+ - Allow countries to be two letter codes or the full country name.
+ Contributed by Sten Spans <sten@bit.nl>.
+0.01 Thu Feb 16 2006
+ - Initial release to CPAN. Yay.
diff --git a/Makefile.PL b/Makefile.PL
index b5f38df..0f6fd46 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,16 +4,20 @@ use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Net::OpenSRS',
- AUTHOR => 'Richard L. Siddall <opensrs@elirion.net>', # Really just maintainer
+ AUTHOR => 'Ivan Kohler <ivan-opensrs@freeside.biz>', # Really just the current maintainer
VERSION_FROM => 'lib/Net/OpenSRS.pm',
ABSTRACT_FROM => 'lib/Net/OpenSRS.pm',
PL_FILES => {},
PREREQ_PM => {
- 'Test::More' => 0,
'LWP::UserAgent' => 0,
'XML::Simple' => 0,
'Digest::MD5' => 0,
'Date::Calc' => 0,
+ 'Locales' => 0,
+ 'Number::Phone' => 0,
+ },
+ BUILD_REQUIRES => {
+ 'Test::More' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'Net-OpenSRS-*' },
diff --git a/lib/Net/OpenSRS.pm b/lib/Net/OpenSRS.pm
index c39b3d5..40f83d3 100644
--- a/lib/Net/OpenSRS.pm
+++ b/lib/Net/OpenSRS.pm
@@ -150,7 +150,7 @@ use XML::Simple;
use Digest::MD5;
use Date::Calc qw/ Add_Delta_Days Today This_Year /;
-our $VERSION = '0.06';
+our $VERSION = '0.07_01';
my $rv;
*hash = \&Digest::MD5::md5_hex;
@@ -636,259 +636,10 @@ sub register_domain
return undef;
}
- my $epp_phone = $c->{phone};
- $epp_phone =~ s/[\.\-]//g;
- $epp_phone = '+1.' . $epp_phone;
-
- # blah, this sucks.
- # it would be really nice if OpenSRS figured out the country -> code
- # conversion on their end of things.
- my %country_codes = (
- 'Afghanistan' => 'AF',
- 'Albania' => 'AL',
- 'Algeria' => 'DZ',
- 'American Samoa' => 'AS',
- 'Andorra' => 'AD',
- 'Angola' => 'AO',
- 'Anguilla' => 'AI',
- 'Antarctica' => 'AQ',
- 'Antigua And Barbuda' => 'AG',
- 'Argentina' => 'AR',
- 'Armenia' => 'AM',
- 'Aruba' => 'AW',
- 'Australia' => 'AU',
- 'Austria' => 'AT',
- 'Azerbaijan' => 'AZ',
- 'Bahamas' => 'BS',
- 'Bahrain' => 'BH',
- 'Bangladesh' => 'BD',
- 'Barbados' => 'BB',
- 'Belarus' => 'BY',
- 'Belgium' => 'BE',
- 'Belize' => 'BZ',
- 'Benin' => 'BJ',
- 'Bermuda' => 'BM',
- 'Bhutan' => 'BT',
- 'Bolivia' => 'BO',
- 'Bosnia Hercegovina' => 'BA',
- 'Botswana' => 'BW',
- 'Bouvet Island' => 'BV',
- 'Brazil' => 'BR',
- 'British Indian Ocean Territory' => 'IO',
- 'Brunei Darussalam' => 'BN',
- 'Bulgaria' => 'BG',
- 'Burkina Faso' => 'BF',
- 'Burundi' => 'BI',
- 'Cambodia' => 'KH',
- 'Cameroon' => 'CM',
- 'Canada' => 'CA',
- 'Cape Verde' => 'CV',
- 'Cayman Islands' => 'KY',
- 'Central African Republic' => 'CF',
- 'Chad' => 'TD',
- 'Chile' => 'CL',
- 'China' => 'CN',
- 'Christmas Island' => 'CX',
- 'Cocos (Keeling) Islands' => 'CC',
- 'Colombia' => 'CO',
- 'Comoros' => 'KM',
- 'Congo' => 'CG',
- 'Congo The Democratic Republic Of' => 'CD',
- 'Cook Islands' => 'CK',
- 'Costa Rica' => 'CR',
- 'Cote D\'Ivoire' => 'CI',
- 'Croatia' => 'HR',
- 'Cuba' => 'CU',
- 'Cyprus' => 'CY',
- 'Czech Republic' => 'CZ',
- 'Denmark' => 'DK',
- 'Djibouti' => 'DJ',
- 'Dominica' => 'DM',
- 'Dominican Republic' => 'DO',
- 'Ecuador' => 'EC',
- 'Egypt' => 'EG',
- 'El Salvador' => 'SV',
- 'Equatorial Guinea' => 'GQ',
- 'Eritrea' => 'ER',
- 'Estonia' => 'EE',
- 'Ethiopia' => 'ET',
- 'Falkland Islands (Malvinas)' => 'FK',
- 'Faroe Islands' => 'FO',
- 'Fiji' => 'FJ',
- 'Finland' => 'FI',
- 'France' => 'FR',
- 'French Guiana' => 'GF',
- 'French Polynesia' => 'PF',
- 'French Southern Territories' => 'TF',
- 'Gabon' => 'GA',
- 'Gambia' => 'GM',
- 'Georgia' => 'GE',
- 'Germany' => 'DE',
- 'Ghana' => 'GH',
- 'Gibraltar' => 'GI',
- 'Greece' => 'GR',
- 'Greenland' => 'GL',
- 'Grenada' => 'GD',
- 'Guadeloupe' => 'GP',
- 'Guam' => 'GU',
- 'Guatemela' => 'GT',
- 'Guinea' => 'GN',
- 'Guinea-Bissau' => 'GW',
- 'Guyana' => 'GY',
- 'Haiti' => 'HT',
- 'Heard and McDonald Islands' => 'HM',
- 'Honduras' => 'HN',
- 'Hong Kong' => 'HK',
- 'Hungary' => 'HU',
- 'Iceland' => 'IS',
- 'India' => 'IN',
- 'Indonesia' => 'ID',
- 'Iran (Islamic Republic Of)' => 'IR',
- 'Iraq' => 'IQ',
- 'Ireland' => 'IE',
- 'Israel' => 'IL',
- 'Italy' => 'IT',
- 'Jamaica' => 'JM',
- 'Japan' => 'JP',
- 'Jordan' => 'JO',
- 'Kazakhstan' => 'KZ',
- 'Kenya' => 'KE',
- 'Kiribati' => 'KI',
- 'Korea, Democratic People\'s Republic Of' => 'KP',
- 'Korea, Republic Of' => 'KR',
- 'Kuwait' => 'KW',
- 'Kyrgyzstan' => 'KG',
- 'Lao People\'s Democratic Republic' => 'LA',
- 'Latvia' => 'LV',
- 'Lebanon' => 'LB',
- 'Lesotho' => 'LS',
- 'Liberia' => 'LR',
- 'Libyan Arab Jamahiriya' => 'LY',
- 'Liechtenstein' => 'LI',
- 'Lithuania' => 'LT',
- 'Luxembourg' => 'LU',
- 'Macau' => 'MO',
- 'Macedonia' => 'MK',
- 'Madagascar' => 'MG',
- 'Malawi' => 'MW',
- 'Malaysia' => 'MY',
- 'Maldives' => 'MV',
- 'Mali' => 'ML',
- 'Malta' => 'MT',
- 'Marshall Islands' => 'MH',
- 'Martinique' => 'MQ',
- 'Mauritania' => 'MR',
- 'Mauritius' => 'MU',
- 'Mayotte' => 'YT',
- 'Mexico' => 'MX',
- 'Micronesia, Federated States Of' => 'FM',
- 'Moldova, Republic Of' => 'MD',
- 'Monaco' => 'MC',
- 'Mongolia' => 'MN',
- 'Montserrat' => 'MS',
- 'Morocco' => 'MA',
- 'Mozambique' => 'MZ',
- 'Myanmar' => 'MM',
- 'Namibia' => 'NA',
- 'Nauru' => 'NR',
- 'Nepal' => 'NP',
- 'Netherlands' => 'NL',
- 'Netherlands Antilles' => 'AN',
- 'New Caledonia' => 'NC',
- 'New Zealand' => 'NZ',
- 'Nicaragua' => 'NI',
- 'Niger' => 'NE',
- 'Nigeria' => 'NG',
- 'Niue' => 'NU',
- 'Norfolk Island' => 'NF',
- 'Northern Mariana Islands' => 'MP',
- 'Norway' => 'NO',
- 'Oman' => 'OM',
- 'Pakistan' => 'PK',
- 'Palau' => 'PW',
- 'Palestine' => 'PS',
- 'Panama' => 'PA',
- 'Papua New Guinea' => 'PG',
- 'Paraguay' => 'PY',
- 'Peru' => 'PE',
- 'Philippines' => 'PH',
- 'Pitcairn' => 'PN',
- 'Poland' => 'PL',
- 'Portugal' => 'PT',
- 'Puerto Rico' => 'PR',
- 'Qatar' => 'QA',
- 'Reunion' => 'RE',
- 'Romania' => 'RO',
- 'Russian Federation' => 'RU',
- 'Rwanda' => 'RW',
- 'Saint Helena' => 'SH',
- 'Saint Kitts And Nevis' => 'KN',
- 'Saint Lucia' => 'LC',
- 'Saint Pierre and Miquelon' => 'PM',
- 'Saint Vincent and The Grenadines' => 'VC',
- 'Samoa' => 'WS',
- 'San Marino' => 'SM',
- 'Sao Tome and Principe' => 'ST',
- 'Saudi Arabia' => 'SA',
- 'Senegal' => 'SN',
- 'Serbia and Montenegro' => 'CS',
- 'Seychelles' => 'SC',
- 'Sierra Leone' => 'SL',
- 'Singapore' => 'SG',
- 'Slovakia' => 'SK',
- 'Slovenia' => 'SI',
- 'Solomon Islands' => 'SB',
- 'Somalia' => 'SO',
- 'South Africa' => 'ZA',
- 'South Georgia and The Sandwich Islands' => 'GS',
- 'Spain' => 'ES',
- 'Sri Lanka' => 'LK',
- 'Sudan' => 'SD',
- 'Suriname' => 'SR',
- 'Svalbard and Jan Mayen Islands' => 'SJ',
- 'Swaziland' => 'SZ',
- 'Sweden' => 'SE',
- 'Switzerland' => 'CH',
- 'Syrian Arab Republic' => 'SY',
- 'Taiwan' => 'TW',
- 'Tajikista' => 'TJ',
- 'Tanzania, United Republic Of' => 'TZ',
- 'Thailand' => 'TH',
- 'Timor-Leste' => 'TL',
- 'Togo' => 'TG',
- 'Tokelau' => 'TK',
- 'Tonga' => 'TO',
- 'Trinidad and Tobago' => 'TT',
- 'Tunisia' => 'TN',
- 'Turkey' => 'TR',
- 'Turkmenistan' => 'TM',
- 'Turks and Caicos Islands' => 'TC',
- 'Tuvalu' => 'TV',
- 'Uganda' => 'UG',
- 'Ukraine' => 'UA',
- 'United Arab Emirates' => 'AE',
- 'United Kingdom (GB)' => 'GB',
- 'United Kingdom (UK)' => 'UK',
- 'United States' => 'US',
- 'United States Minor Outlying Islands' => 'UM',
- 'Uruguay' => 'UY',
- 'Uzbekistan' => 'UZ',
- 'Vanuatu' => 'VU',
- 'Vatican City State' => 'VA',
- 'Venezuela' => 'VE',
- 'Vietnam' => 'VN',
- 'Virgin Islands (British)' => 'VG',
- 'Virgin Islands (U.S.)' => 'VI',
- 'Wallis and Futuna Islands' => 'WF',
- 'Western Sahara' => 'EH',
- 'Yemen Republic of' => 'YE',
- 'Zambia' => 'ZM',
- 'Zimbabwe' => 'ZW'
- ); # end suckage
-
# attempt countryname translation if needed
if ( $c->{country} !~ m/^[A-Z]{2,3}$/ ) {
- $c->{country} = $country_codes{$c->{country}};
+ require Locales;
+ $c->{country} = uc( Locales->new->get_code_from_territory($c->{country}) );
unless ( defined( $c->{country} ) ) {
$self->debug("Invalid country.");
@@ -896,30 +647,37 @@ sub register_domain
}
}
+ my $epp_phone = _parse_phone($c->{phone});
+ unless ( defined( $epp_phone ) ) {
+ $self->debug("Invalid phone number.");
+ return undef;
+ }
+
# build contact hashref from customer info.
my $contact_info = {
- first_name => $c->{firstname},
- last_name => $c->{lastname},
+ first_name => $c->{first_name} || $c->{firstname},
+ last_name => $c->{last_name} || $c->{lastname},
city => $c->{city},
state => $c->{state},
country => $c->{country},
- address1 => $c->{address},
- postal_code => $c->{zip},
+ address1 => $c->{address1} || $c->{address},
+ $c->{address2} ? ( address2 => $c->{address2} ) : (),
+ postal_code => $c->{postal_code} || $c->{zip},
email => $c->{email},
phone => $epp_phone,
- org_name => $c->{company} || 'n/a',
+ org_name => $c->{org_name} || $c->{company} || 'n/a',
};
-
my $hashref = {
action => 'sw_register',
object => 'domain',
attributes => {
domain => $domain,
- custom_nameservers => 0,
+ custom_nameservers => exists $c->{nameserver_list} ? 1 : 0,
+ exists $c->{nameserver_list} ? ( nameserver_list => $c->{nameserver_list} ) : (),
custom_tech_contact => 0,
- auto_renew => 0,
- period => 1,
+ auto_renew => $c->{auto_renew} || 0,
+ period => $c->{period} || 1,
f_lock_domain => 1,
contact_set => {
admin => $contact_info,
@@ -1236,7 +994,10 @@ sub _format
$xml .= "$sp<item key=\"$_\">\n";
$xml .= "$sp <dt_array>\n";
foreach (map { _encode($_) } sort @$val) {
- $xml .= "$sp <item key=\"$c\">$_</item>\n";
+# $xml .= "$sp <item key=\"$c\">$_</item>\n";
+ $xml .= "$sp <item key=\"$c\">\n";
+ $xml .= $self->_format($_);
+ $xml .= "$sp </item>\n";
$c++;
}
$xml .= "$sp </dt_array>\n";
@@ -1244,13 +1005,13 @@ sub _format
}
elsif ( ref $val eq 'HASH' ) {
- $xml .= "$sp<item key=\"$_\">\n";
+ $xml .= "$sp<item key=\"$_\">\n" unless /^HASH/;
$xml .= "$sp<dt_assoc>\n";
foreach (sort keys %$val) {
$xml .= $self->_format( $val->{$_} );
}
$xml .= "$sp</dt_assoc>\n";
- $xml .= "$sp</item>\n";
+ $xml .= "$sp</item>\n" unless /^HASH/;
}
else {
@@ -1292,13 +1053,31 @@ sub _denastify {
();
}
+sub _parse_phone {
+ require Number::Phone;
+ my ($phone) = shift;
+ my ($country, $idd) = Number::Phone::Country::phone2country_and_idd($phone);
+ return undef unless $country;
+ my $np = Number::Phone->new($phone);
+ $np = Number::Phone->new($country, $phone) unless defined $np;
+ return undef unless defined $np;
+ (my $epp = $np->format) =~ s/\s+/\./;
+ $epp =~ s/\s+//g;
+ return $epp;
+}
+
=back
=head1 Author
-Mahlon E. Smith I<mahlon@martini.nu> for Spime Solutions Group
+Original author: Mahlon E. Smith I<mahlon@martini.nu> for Spime Solutions Group
I<(www.spime.net)>
+Contributors: Sten Spans, Jeff Finucane and Richard Siddall for Freeside
+Internet Services I<(www.freeside.biz)>, Justin Hunter.
+
+Current maintainer: Ivan Kohler <ivan-opensrs@freeside.biz>
+
=cut
1;