WWW-CNic-0.38/0000755000076500007650000000000011563231345011751 5ustar gavingavinWWW-CNic-0.38/Makefile.PL0000755000076500007650000000060111563231305013717 0ustar gavingavin#!/usr/bin/perl # Makefile.PL for WWW::CNic # $Id: Makefile.PL,v 1.9 2011/05/13 13:31:49 gavin Exp $ use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'WWW::CNic', 'VERSION_FROM' => 'lib/WWW/CNic.pm', 'PREREQ_PM' => { LWP => 0, Digest::MD5 => 0, Crypt::SSLeay => 0, }, 'AUTHOR' => 'CentralNic Ltd ', 'ABSTRACT_FROM' => 'lib/WWW/CNic.pm', ); WWW-CNic-0.38/cnic-www-cnic.spec0000755000076500007650000000273211432535755015313 0ustar gavingavin# $Id: %define VERSION {{VERSION}} Name: cnic-WWW-CNic Summary: The CentralNic WWW::CNic Perl Module Version: %{VERSION} Release: 1%{dist} Epoch: 0 Group: Libraries License: GPLv2 Source: %{name}-%{version}.tar.gz Packager: Achim Regendoerp Vendor: http://www.centralnic.com/ BuildRoot: %{_tmppath}/%(whoami)-%{name}-%{VERSION} AutoReq: no BuildArch: noarch Requires: perl-Date-Manip %description The CentralNic WWW:CNic Perl Module %prep %setup %build %install rm -rf %{buildroot} mkdir -p %{buildroot}/export/cnic/WWW-CNic cp -Rp * %{buildroot}/export/cnic/WWW-CNic rm -f %{buildroot}/export/cnic/WWW-CNic/%{name}.spec mkdir -p %{buildroot}/etc/cron.daily cat > %{buildroot}/etc/cron.daily/%{name} << EBD #!/bin/sh cd /export/cnic/WWW-CNic perl Makefile.pl END %post if [ "$1" = "1" ] ; then cd /export/cnic/WWW-CNic perl Makefile.PL fi %clean rm -rf %{buildroot} %files %attr(0755, root, root) /etc/cron.daily/%{name} %attr(0755, root, root) %dir /export/cnic/WWW-CNic %attr(0644, root, root) /export/cnic/WWW-CNic/* %changelog *Tue Aug 17 2010 Achim Regendoerp - 20100817 - Added dist to the Release field *Tue Jun 29 2010 Achim Regendoerp - 20100629 - Replaced END with fi in the post routine - Replaced .pl with .PL in the post routine *Tue Jun 22 2010 Achim Regendoerp - 20100622 - Initial spec file - Adjusted name capitalization - Added imssing /* in the attributes WWW-CNic-0.38/COPYING0000755000076500007650000004313110122534531013002 0ustar gavingavin GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. WWW-CNic-0.38/examples/0000755000076500007650000000000011563231345013567 5ustar gavingavinWWW-CNic-0.38/examples/search.cgi0000755000076500007650000000305211563231305015517 0ustar gavingavin#!/usr/bin/perl # an example of how to use WWW::CNic in a web environment. # a comparable script using the whois server works substantially slower. # $Id: search.cgi,v 1.2 2011/05/13 13:31:49 gavin Exp $ use WWW::CNic; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use Date::Manip; use strict; my $doc_title = 'Domain Search'; my @suffixes = qw(uk.com uk.net us.com eu.com de.com); print header() . start_html($doc_title), h1($doc_title) . start_form() . p('Enter domain: '.textfield('domain')) . scrolling_list( -name => 'suffixes', -values => \@suffixes, -size => 5, -multiple => 'true') . br() . submit() . end_form(); my @suffixlist = param('suffixes'); if (param('domain') ne '' && scalar(@suffixlist) > 0) { print hr() . h2('Results'); my $query = WWW::CNic->new( command => 'search', use_ssl => 0, domain => param('domain'), ); $query->set(suffixlist => \@suffixlist); my $response = $query->execute(); if ($response->is_error) { print h2('Error') . p($response->error()); } else { my @results; foreach my $suffix(@suffixlist) { if ($response->is_registered($suffix)) { push(@results, li(sprintf( "Domain %s.%s is registered to %s and expires on %s.", param('domain'), $suffix, $response->registrant($suffix), UnixDate('epoch '.$response->expiry($suffix), "%b %e %Y") )) ); } else { push(@results, li(sprintf("Domain %s.%s is available for registration.", param('domain'), $suffix))); } } print ul(\@results); } } print end_html(); exit; WWW-CNic-0.38/lib/0000755000076500007650000000000011563231345012517 5ustar gavingavinWWW-CNic-0.38/lib/WWW/0000755000076500007650000000000011563231345013203 5ustar gavingavinWWW-CNic-0.38/lib/WWW/CNic.pm0000755000076500007650000010055111563231305014356 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: CNic.pm,v 1.68 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic; use LWP; use LWP::ConnCache; use HTTP::Request::Common; use URI::Escape; use Digest::MD5 qw(md5_hex); use vars qw($VERSION $CONNECTION_CACHE); use strict; our $VERSION = '0.38'; =pod =head1 NAME WWW::CNic - a web-based API for the CentralNic domain registry system. =head1 SYNOPSIS use WWW::CNic; my @suffixlist = qw(uk.com us.com de.com eu.com); my $query = WWW::CNic->new(command => 'search', 'domain' => 'example'); $query->set(suffixlist => \@suffixlist); my $response = $query->execute; if ($response->is_error) { printf("Error: %s\n", $response->error); } else { foreach my $suffix(@suffixlist) { if ($response->is_registered) { printf("Domain %s.%s is registered to %s\n", $domain, $suffix, $response->registrant($suffix)); } else { printf("Domain %s.%s is available for registration\n", $domain, $suffix); } } } =head1 DESCRIPTION C provides a powerful object-oriented Perl interface to the CentralNic Toolkit system. The design of C is inspired greatly by C, which is a prerequisite. Essentially, making a transaction requires building a I object, which is then executed and returns a I object. While each transaction type (search, registration, modification...) requires a different set of data to be sent by the client, all the response objects have common properties, inherited from the C base class, with just a few extra methods for accessing specific information. =head1 INSTALLATION Installing C is as simple as: cd /usr/src wget http://toolkit.centralnic.com/dist/WWW-CNic-x.xx.tar.gz tar zxvf WWW-CNic-x.xx.tar.gz cd WWW-CNic-x.xx perl Makefile.PL make make install =head1 PREREQUISITES =over =item 1 C - the WWW Library for Perl. This in turn requires C, C and C. =item 2 An SSL toolkit (C, C) for doing HTTPS transactions. =item 4 C is needed for hashing passwords. =back =head1 USAGE Consult L for detailed information on using WWW::CNic. =head1 CONSTRUCTOR my $query = WWW::CNic->new( [OPTIONS] ); The constructor for this class accepts the following options: =over =item 1 C - only needed for doing domain registrations and modifications. This is the User ID of your Registrar Handle. =item 1 C - the password for your Registrar Handle. =item 3 C - required for every transaction. This is a scalar containing the command name. The list of allowed commands is always growing, you should consult the Toolkit website for a complete list. =item 4 C - only needed for domain registrations, modifications and other commands that act upon domains. =item 5 C - allows you to use to a non-standard host. This is mainly useful for client debugging purposes. =item 6 C - when set to C<1>, this causes any domain registration and modification transactions to use the test database. Again, this is useful for testing and debugging. =item 7 C - by default, WWW::CNic will use C to cache server connections. Setting C to C<0> or C will turn this off. =back =head1 METHODS $query->set( NAME => VALUE ); This method allows you to set any number of parameters prior to executing the query. The specifics of what parameters are required for what type of transaction is explained in L. my $response = $query->execute(); This method makes the transaction and returns an instance of a C child class. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut BEGIN { our $CONNECTION_CACHE = LWP::ConnCache->new; } sub new { # shift off the package name: my $package = shift; # convert to a hash: my %args = @_; # initialise the object: my $self = { _test => 0, }; foreach my $key(keys %args) { $self->{"_$key"} = $args{$key}; } # create an LWP useragent: $self->{_agent} = LWP::UserAgent->new(); $self->{_agent}->timeout($self->{_timeout} || 10); $self->{_agent}->agent(sprintf('%s/%s (LWP %s, Perl %vd, %s)', $package, $VERSION, $LWP::VERSION, $^V, ucfirst($^O))); $self->{_agent}->conn_cache($CONNECTION_CACHE) unless (!$self->{_keep_alive}); $self->{_base} = 'http://' . (defined($self->{_host}) ? $self->{_host} : 'toolkit.centralnic.com').'/srv'; # bless into this package: bless($self, $package); return $self; } sub set { my $self = shift; my %params = @_; foreach my $name(keys %params) { $self->{_params}->{$name} = $params{$name}; } return; } sub execute { my $self = shift; SWITCH: { # No SSL/authentication required $self->{_command} eq 'whois' && return $self->_whois(); $self->{_command} eq 'search' && return $self->_search(); $self->{_command} eq 'suffixes' && return $self->_suffixes(); # SSL/authentication required $self->{_command} eq 'create_handle' && return $self->_create_handle(); $self->{_command} eq 'handle_info' && return $self->_handle_info(); $self->{_command} eq 'register' && return $self->_register(); $self->{_command} eq 'register_idn' && return $self->_register(idn => 1); $self->{_command} eq 'modify' && return $self->_modify(); $self->{_command} eq 'modify_handle' && return $self->_modify_handle(); $self->{_command} eq 'renewals' && return $self->_upcoming_renewals(); $self->{_command} eq 'list_domains' && return $self->_list_domains(); $self->{_command} eq 'issue_renewals' && return $self->_issue_renewals(); $self->{_command} eq 'get_pricing' && return $self->_get_pricing(); $self->{_command} eq 'delete' && return $self->_delete_domain(); $self->{_command} eq 'decline' && return $self->_decline_domain(); $self->{_command} eq 'undecline' && return $self->_undecline_domain(); $self->{_command} eq 'start_transfer' && return $self->_start_transfer(); $self->{_command} eq 'check_transfer' && return $self->_check_transfer(); $self->{_command} eq 'cancel_transfer' && return $self->_cancel_transfer(); $self->{_command} eq 'reactivate' && return $self->_reactivate_domain(); $self->{_command} eq 'push_domain' && return $self->_push_domain(); $self->{_command} eq 'auth_info' && return $self->_auth_info(); $self->{_command} eq 'poll_transfers' && return $self->_poll_transfers(); $self->{_command} eq 'approve_transfer' && return $self->_approve_transfer(); $self->{_command} eq 'reject_transfer' && return $self->_reject_transfer(); $self->{_command} eq 'list_outstanding_domains' && return $self->_list_outstanding_domains(); $self->{_command} eq 'submit_payment_batch' && return $self->_submit_payment_batch(); $self->{_command} eq 'registrant_transfer' && return $self->_registrant_transfer(); $self->{_command} eq 'lock_domain' && return $self->_lock_domain(); $self->{_command} eq 'unlock_domain' && return $self->_unlock_domain(); $self->{_command} eq 'validate_domain' && return $self->_validate_domain(); die("Invalid command '$self->{_command}'"); } } # # No SSL/authentication required # sub _whois { my $self = shift; $self->{_base} =~ s/^https:/http:/g; # No SSL required die("Missing domain name") if $self->{_domain} eq ''; $self->{_response}->{_raw} = $self->_get(GET("$self->{_base}/wwwhois?domain=$self->{_domain}&test=$self->{_test}")); use WWW::CNic::Response::Whois; return WWW::CNic::Response::Whois->new($self->{_response}->{_raw}); } sub _search { my $self = shift; $self->{_base} =~ s/^https:/http:/g; # No SSL required die("Missing domain name") if $self->{_domain} eq ''; my $url = "$self->{_base}/search?domain=$self->{_domain}"; if (defined(@{$self->{_params}->{suffixlist}})) { $url .= '&suffixlist='.join(',', @{$self->{_params}->{suffixlist}}).'&test='.$self->{_test}; } $self->{_response}->{_raw} = $self->_get(GET($url)); use WWW::CNic::Response::Search; return WWW::CNic::Response::Search->new($self->{_response}->{_raw}); } sub _suffixes { my $self = shift; $self->{_base} =~ s/^https:/http:/g; # No SSL required $self->{_response}->{_raw} = $self->_get(GET("$self->{_base}/suffixes?test=$self->{_test}")); use WWW::CNic::Response::Suffixes; return WWW::CNic::Response::Suffixes->new($self->{_response}->{_raw}); } # # SSL/authentication required # sub _create_handle { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Invalid type for handle") unless (ref($self->{_params}->{handle}) eq 'HASH'); my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, visible => ($self->{_params}->{visible} == 0 ? 0 : 1), ); if (defined($self->{_params}->{handle}->{street1})) { $params{name} = $self->{_params}->{handle}->{name}; $params{company} = $self->{_params}->{handle}->{company}; $params{street1} = $self->{_params}->{handle}->{street1}; $params{street2} = $self->{_params}->{handle}->{street2}; $params{street3} = $self->{_params}->{handle}->{street3}; $params{city} = $self->{_params}->{handle}->{city}; $params{sp} = $self->{_params}->{handle}->{sp}; $params{postcode} = $self->{_params}->{handle}->{postcode}; $params{country} = $self->{_params}->{handle}->{country}; $params{phone} = $self->{_params}->{handle}->{phone}; $params{fax} = $self->{_params}->{handle}->{fax}; $params{email} = $self->{_params}->{handle}->{email}; } else { $params{handle} = $self->_build_handle_string($self->{_params}->{handle}); } my $req = HTTP::Request->new(POST => "$self->{_base}/create_handle"); $req->content_type('application/x-www-form-urlencoded'); my @content; foreach my $name(keys %params) { my $pair; if ($name eq 'dns[]') { $pair = "$name=$params{$name}"; } else { $pair = uri_escape($name).'='.uri_escape($params{$name}); } push(@content, $pair); } $req->content(join('&', @content)); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::CreateHandle; return WWW::CNic::Response::CreateHandle->new($self->{_response}->{_raw}); } sub _handle_info { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, handle => $self->{_params}->{handle}, ); my $req = POST("$self->{_base}/handle_info", \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::HandleInfo; return WWW::CNic::Response::HandleInfo->new($self->{_response}->{_raw}); } sub _register { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL my %args = @_; die("Missing domain name") if $self->{_domain} eq ''; die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; my ($domain, $suffix) = split(/\./, $self->{_domain}, 2); my $chandle = (ref($self->{_params}->{chandle}) eq 'HASH' ? $self->_build_handle_string($self->{_params}->{chandle}) : $self->{_params}->{chandle}); my $thandle = (ref($self->{_params}->{thandle}) eq 'HASH' ? $self->_build_handle_string($self->{_params}->{thandle}) : $self->{_params}->{thandle}); my $dns; my $dns_param = 'dns[]'; if (ref($self->{_params}->{dns}) eq 'ARRAY') { $dns = join('&dns[]=', @{$self->{_params}->{dns}}); } elsif (ref($self->{_params}->{dns}) eq 'HASH') { my @entries; foreach my $name(keys %{$self->{_params}->{dns}}) { push(@entries, $name.'::'.${$self->{_params}->{dns}}->{$name}); } $dns = join('&dns[]=', @entries); } elsif ($dns == 'defaults') { $dns = 'defaults'; $dns_param = 'dns' } my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $domain, suffix => $suffix, registrant => $self->{_params}->{registrant}, chandle => $chandle, thandle => $thandle, period => $self->{_params}->{period}, $dns_param => $dns, ); $params{ahandle} = $self->{_params}->{ahandle} if (defined($self->{_params}->{ahandle})); $params{bhandle} = $self->{_params}->{bhandle} if (defined($self->{_params}->{bhandle})); $params{url} = $self->{_params}->{url} if ($self->{_params}->{url} ne ''); my $POST_URL = $self->{_base}.'/'.($args{idn} == 1 ? 'register_idn' : 'register'); my $req = HTTP::Request->new(POST => $POST_URL); $req->content_type('application/x-www-form-urlencoded'); my @content; foreach my $name(keys %params) { my $pair; if ($name eq 'dns[]') { $pair = "$name=$params{$name}"; } else { $pair = uri_escape($name).'='.uri_escape($params{$name}); } push(@content, $pair); } $req->content(join('&', @content)); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::Register; return WWW::CNic::Response::Register->new($self->{_response}->{_raw}); } sub _modify { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing domain name") if $self->{_domain} eq ''; die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); $params{url} = $self->{_params}->{url} if ($self->{_params}->{url} ne ''); if (defined($self->{_params}->{chandle})) { $params{chandle} = (ref($self->{_params}->{chandle}) eq 'HASH' ? $self->_build_handle_string($self->{_params}->{chandle}) : $self->{_params}->{chandle}); } if (defined($self->{_params}->{ahandle})) { $params{ahandle} = $self->{_params}->{ahandle}; } if (defined($self->{_params}->{thandle})) { $params{thandle} = (ref($self->{_params}->{thandle}) eq 'HASH' ? $self->_build_handle_string($self->{_params}->{thandle}) : $self->{_params}->{thandle}); } if (defined($self->{_params}->{bhandle})) { $params{bhandle} = $self->{_params}->{bhandle}; } $params{ttl} = int($self->{_params}->{ttl}) if (defined($self->{_params}->{ttl})); if (defined($self->{_params}->{dns})) { my @dns; if ($self->{_params}->{dns}->{drop} eq 'all') { push(@dns, "drop:all"); } elsif (defined(@{$self->{_params}->{dns}->{drop}})) { foreach my $name(@{$self->{_params}->{dns}->{drop}}) { push(@dns, "drop:$name"); } } if (defined(@{$self->{_params}->{dns}->{add}})) { foreach my $name(@{$self->{_params}->{dns}->{add}}) { push(@dns, "add:$name"); } } $params{'dns[]'} = join('&dns[]=', @dns); } my $req = HTTP::Request->new( POST => "$self->{_base}/modify"); $req->content_type('application/x-www-form-urlencoded'); my @content; foreach my $name(keys %params) { my $pair; if ($name eq 'dns[]') { $pair = "$name=$params{$name}"; } else { $pair = uri_escape($name).'='.uri_escape($params{$name}); } push(@content, $pair); } $req->content(join('&', @content)); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::Modify; return WWW::CNic::Response::Modify->new($self->{_response}->{_raw}); } sub _modify_handle { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing handle ID") if ($self->{_params}->{handle} eq ''); my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, ); foreach my $key (keys(%{$self->{_params}})) { $params{$key} = $self->{_params}->{$key}; } my $req = HTTP::Request->new( POST => "$self->{_base}/modify_handle"); $req->content_type('application/x-www-form-urlencoded'); my @content; foreach my $name(keys %params) { push(@content, uri_escape($name).'='.uri_escape($params{$name})); } $req->content(join('&', @content)); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::ModifyHandle; return WWW::CNic::Response::ModifyHandle->new($self->{_response}->{_raw}); } sub _upcoming_renewals { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, months => $self->{_months}, ); foreach my $key (keys(%{$self->{_params}})) { $params{$key} = $self->{_params}->{$key}; } my $req = POST("$self->{_base}/upcoming_renewals", \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::Renewals; return WWW::CNic::Response::Renewals->new($self->{_response}->{_raw}); } sub _list_domains { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, offset => $self->{_params}->{offset}, length => $self->{_params}->{length}, orderby => $self->{_params}->{orderby}, ); my $req = POST("$self->{_base}/list_domains", \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::DomainList; return WWW::CNic::Response::DomainList->new($self->{_response}->{_raw}); } sub _issue_renewals { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domains") if scalar(@{$self->{_params}->{domains}}) < 1; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, period => $self->{_params}->{period}, immediate => $self->{_params}->{immediate}, ); my $i = 0; foreach my $domain(@{$self->{_params}->{domains}}) { $params{"domains[$i]"} = $domain; $i++; } my $req = POST("$self->{_base}/issue_renewals", \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::IssueRenewals; return WWW::CNic::Response::IssueRenewals->new($self->{_response}->{_raw}); } sub _get_pricing { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, type => $self->{_type}, ); my $url = "$self->{_base}/get_pricing"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::GetPricing; return WWW::CNic::Response::GetPricing->new($self->{_response}->{_raw}); } sub _delete_domain { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, reason => $self->{_reason} || $self->{_params}->{reason}, immediate => $self->{_immediate}, ); die("Missing reason") if ($params{reason} eq ''); $params{immediate} = 1 if ($self->{_params}->{immediate}); my $url = "$self->{_base}/delete_domain"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::DeleteDomain; return WWW::CNic::Response::DeleteDomain->new($self->{_response}->{_raw}); } sub _decline_domain { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/decline_domain"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::DeclineDomain; return WWW::CNic::Response::DeclineDomain->new($self->{_response}->{_raw}); } sub _undecline_domain { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/undecline_domain"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::UnDeclineDomain; return WWW::CNic::Response::UnDeclineDomain->new($self->{_response}->{_raw}); } sub _start_transfer { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domains") if scalar(@{$self->{_params}->{domains}}) < 1; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, ); my $i = 0; foreach my $domain(@{$self->{_params}->{domains}}) { $params{"domains[$i]"} = $domain; $i++; } $i = 0; foreach my $info(@{$self->{_params}->{authinfo}}) { $params{"authinfo[$i]"} = $info; $i++; } my $url = "$self->{_base}/start_transfer"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::StartTransfer; return WWW::CNic::Response::StartTransfer->new($self->{_response}->{_raw}); } sub _check_transfer { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/check_transfer"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::CheckTransfer; return WWW::CNic::Response::CheckTransfer->new($self->{_response}->{_raw}); } sub _cancel_transfer { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/cancel_transfer"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::CancelTransfer; return WWW::CNic::Response::CancelTransfer->new($self->{_response}->{_raw}); } sub _reactivate_domain { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); $params{email} = $self->{_email} if (defined($self->{_email})); $params{period} = $self->{_period} if (defined($self->{_period})); my $url = "$self->{_base}/reactivation_request"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::ReactivateDomain; return WWW::CNic::Response::ReactivateDomain->new($self->{_response}->{_raw}); } sub _push_domain { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; die("Missing handle") if $self->{_handle} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, handle => $self->{_handle}, ); my $url = "$self->{_base}/push_domain"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::PushDomain; return WWW::CNic::Response::PushDomain->new($self->{_response}->{_raw}); } sub _auth_info { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/auth_info"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::AuthInfo; return WWW::CNic::Response::AuthInfo->new($self->{_response}->{_raw}); } sub _poll_transfers { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, ); my $url = "$self->{_base}/poll_transfers"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::PollTransfers; return WWW::CNic::Response::PollTransfers->new($self->{_response}->{_raw}); } sub _approve_transfer { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/approve_transfer"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::ApproveTransfer; return WWW::CNic::Response::ApproveTransfer->new($self->{_response}->{_raw}); } sub _reject_transfer { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/reject_transfer"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::RejectTransfer; return WWW::CNic::Response::RejectTransfer->new($self->{_response}->{_raw}); } sub _registrant_transfer { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die ("Missing username") if $self->{_username} eq ''; die ("Missing password") if $self->{_password} eq ''; die ("Missing domain") if ($self->{_params}->{domain} eq ''); die ("Missing registrant") if ($self->{_params}->{registrant} eq ''); my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, ); foreach my $key (keys(%{$self->{_params}})) { $params{$key} = $self->{_params}->{$key}; } my $url = "$self->{_base}/registrant_transfer"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::RegistrantTransfer; return WWW::CNic::Response::RegistrantTransfer->new($self->{_response}->{_raw}); } sub _list_outstanding_domains { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, ); my $url = "$self->{_base}/list_outstanding_domains"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::ListOutstandingDomains; return WWW::CNic::Response::ListOutstandingDomains->new($self->{_response}->{_raw}); } sub _submit_payment_batch { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domains") if scalar(@{$self->{_params}->{domains}}) < 1; die("Missing method") if $self->{_params}->{method} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, method => $self->{_params}->{method}, ); my $i = 0; foreach my $domain(@{$self->{_params}->{domains}}) { $params{"domains[$i]"} = $domain; $i++; } my $req = POST("$self->{_base}/submit_payment_batch", \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::SubmitPaymentBatch; return WWW::CNic::Response::SubmitPaymentBatch->new($self->{_response}->{_raw}); } sub _lock_domain { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/lock_domain"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::LockDomain; return WWW::CNic::Response::LockDomain->new($self->{_response}->{_raw}); } sub _unlock_domain { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/unlock_domain"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::UnlockDomain; return WWW::CNic::Response::UnlockDomain->new($self->{_response}->{_raw}); } sub _validate_domain { my $self = shift; $self->{_base} =~ s/^http:/https:/g; # Requires SSL die("Missing username") if $self->{_username} eq ''; die("Missing password") if $self->{_password} eq ''; die("Missing domain") if $self->{_domain} eq ''; my %params = ( user => $self->{_username}, password => $self->_crypt_md5($self->{_password}), test => $self->{_test}, domain => $self->{_domain}, ); my $url = "$self->{_base}/validate_domain"; my $req = POST($url, \%params); $self->{_response}->{_raw} = $self->_get($req); use WWW::CNic::Response::ValidateDomain; return WWW::CNic::Response::ValidateDomain->new($self->{_response}->{_raw}); } sub _get { my ($self, $request) = @_; my $response = $self->{_agent}->request($request); if ($response->is_error()) { return "Status: 1\nMessage: ".$response->status_line(); } else { return $response->content(); } } sub _build_handle_string { my ($self, $data) = @_; my @str = ('new'); foreach my $key (qw(name company address postcode country phone fax email)) { push(@str, $data->{$key}); } return join("::", @str); } sub _salt { return join('', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]); } sub _crypt_md5 { my ($self, $str) = @_; ### special hack: Mac OS X and Windows don't support MD5 in the crypt() function ### so use plaintext passwords: if ($^O eq 'darwin' || $^O eq 'MSWin32') { return 'plain:'.$str; } else { return crypt($str, '$1$' . substr(md5_hex(rand()), 0, 8) . '$'); } } 1; WWW-CNic-0.38/lib/WWW/CNic/0000755000076500007650000000000011563231345014017 5ustar gavingavinWWW-CNic-0.38/lib/WWW/CNic/Cookbook.pm0000755000076500007650000007627611563231305016144 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: Cookbook.pm,v 1.53 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Cookbook; use vars qw($VERSION); =pod =head1 Name WWW::CNic::Cookbook - The WWW::CNic Cookbook =head1 Description This document provides a fairly complete explanation of how to implement basic Registrar-Registry functions with CentralNic using C. This document is a work in progress, if you want to see something in it that isn't, or find an error, please let us know by e-mailing L. =head1 Test Mode The Toolkit can be told to run in I, that is, to use a non-live copy of the database so that any changes made don't affect the live domains. To enable test mode, simply set the C argument on the constructor, like so: my $query = WWW::CNic->new(test => 1, ... ); You will also need to supply B credentials rather than production account credentials. These can be obtained from the Registrar Console. =head1 Getting Information about Domains =head2 Getting a Suffix List CentralNic's range of available domain names changes occasionally and you may want to periodically update the list of domains we support. You can use the C command to retrieve an array containing all the domain suffixes CentralNic supports. use WWW::CNic; # create a request object: my $query = WWW::CNic->new( command => 'suffixes', ); # execute the query to return a response object: my $response = $query->execute; # use the suffixes() method to get a list of suffixes: my @suffixes = $response->suffixes; This can be shortened to: use WWW::CNic; my @suffixes = WWW::CNic->new(command=>'suffixes')->execute->suffixes; =head2 Doing a Domain Availability Search The traditional method for checking the availability of a domain name is to query the registry's whois server, and do a pattern match against the response looking for indications that the domain is registered. This is not an optimal approach for several reasons - firstly, the whois protocol was never designed for it. Secondly, the lack of a whois record does not signify availablity. It also can't handle multiple lookups very well. The C function is a very powerful way to check on the availability of a domain name. It allows you to check the availability of a domain name across one, several or all of CentralNic's suffixes. Here's how you might do a check against a particular domain name: use WWW::CNic; my $domain = 'example'; my $suffix = 'uk.com'; my $query = WWW::CNic->new( command => 'search', domain => $domain, ); $query->set(suffixlist => [$suffix]); my $response = $query->execute; if ($response->is_registered($suffix)) { printf("domain is registered to %s\n", $response->registrant($suffix)); } else { print "domain is available.\n"; } Notice the extra step (using the C method), where we set the 'suffixlist' parameter to be an anonymous array containing the single suffix we want to check. Omitting this step would make the query check against all CentralNic suffixes. The response object returned has a method C which returns true if the domain is already registered. Additionally, you can use the C and C methods to get the registrant name and a UNIX timestamp of the expiry date respectively. =head2 Getting Detailed Information About a Domain Prior to submitting a modification, you may wish to get detailed information about a domain name to present to your users. The C command allows the lookup of the same detailed information that a whois server provides. For example: use WWW::CNic; my $domain = 'example.uk.com'; my $query = WWW::CNic->new( command => 'whois', domain => $domain, ); my $response = $query->execute; print "Domain: $domain\n"; my %tech_handle = %{$response->response('thandle')}; printf("Tech Handle: %s (%s)\n", $tech_handle{userid}, $tech_handle{name}); my $dns = $response->response('dns'); foreach my $server(@{$dns}) { if (ref($server) eq 'ARRAY') { my ($name, $ipv4) = @{$server}; print "Server: $name ($ipv4)\n"; } else { print "Server: $server\n"; } } The response object contains values for the following keys: registrant the domain's registrant created registration date expires expiry date status status (e.g. Live, On Hold, Pending Deletion etc) chandle Client Handle bhandle Technical Handle thandle Billing Handle dns DNS Servers The C and C keys are just strings. The C and C keys are UNIX timestamps. The C, C and C keys are all references to hashes with the following keys: userid name company addr street1 street2 street3 city sp postcode country phone fax email These values can be accessed in the following way: # get the tech handle: my $tech_handle = $response->response('thandle'); print $tech_handle->{addr}; # and so on for the other keys The C key is an array. Elements in the array may be either a plain scalar containing the DNS hostname of the server, or an anonymous array containing the DNS hostname and IPV4 address in that order. Use the C function to work out which. B
handles in the CentralNic database follow one of two "styles": old-style handles have flat address data (stored in the C
property), but new-style handles have separate properties for street, city and state/province. All handles will have at least a non-empty C
property (for new-style handles this is created by flattening the C, C... properties). All new-style handles will have a non-empty C property. =head2 Retrieving the Transfer Code For a Domain Name use WWW::CNic; my $query = WWW::CNic->new( command => 'auth_info', domain => 'example.uk.com', username => $handle, password => $passwd, ); my $response = $query->execute; if ($response->is_error) { printf("Error: %s\n", $response->error); } else { printf("Transfer code: %s\n", $response->auth_code); } This command is used to retrieve the transfer code for a domain name. Those registrars who use our EPP system are required to provide a security code when they initiate a transfer request, which they get from the registrant, who in turn gets it from the losing registrar. Registrars are required to provide this code to registrants upon request. =head2 Getting Detailed Information About a Handle This command can be used to retrieve information about a handle I. You are the sponsor of a handle if you created it as part of a domain registration or modification process, or it is associated with a domain name for which you are Billing Handle. use WWW::CNic; my $query = WWW::CNic->new( command => 'handle_info', username => $handle, password => $passwd, ); $query->set(handle => 'H12345'); my $response = $query->execute; if ($response->is_error) { printf("Error: %s\n", $response->error); } else { foreach my $key (qw(name company address street1 street2 street3 city sp postcode country tel fax email visible)) { printf("%s: %s\n", $key, $response->response($key)); } } The C value is a binary value (1 or 0) that indicates whether this handle's details are show in WHOIS records for domains with which it is associated. B
handles in the CentralNic database follow one of two "styles": old-style handles have flat address data (stored in the C
property), but new-style handles have separate properties for street, city and state/province. All handles will have at least a non-empty C
property (for new-style handles this is created by flattening the C, C... properties). All new-style handles will have a non-empty C property. =head1 Creating New Domains and Handles =head2 Creating a Handle If you are going to be registering multiple domains, you should create a new handle and use that to register the domains using its ID, rather than supply new contact details for each registration, which will result in a new client handle being created each time. To do so, use the C command: use WWW::CNic; my $query = WWW::CNic->new( command => 'create_handle', username => $handle, password => $passwd, ); $query->set(handle => { name => 'John Doe', company => 'Example, Inc', street1 => 'Example House', street2 => 'Example Street', city => 'London', sp => 'England', postcode=> 'EC1 123', country => 'UK', phone => '+44.8700170900', fax => '+44.8700170901', email => 'jd@example.com', }); # make the handle hidden on whois records: $query->set(visible => 0); my $response = $query->execute; if ($response->is_success) { printf("New handle created with ID %s\n", $response->handle); } else { printf("Error: %s\n", $response->error); } The C parameter must be a reference to a hash containing the following keys: name company street1 street2 street3 city sp postcode country phone fax email Only C, C and C are mandatory. The C and C fields can be in any format, but we request that you use the e164a format: +AA.BBB(xCC) where C is the dialling code for the country in question, C is the phone number without a local dialling prefix (eg, for the UK, emit the leading zero), and C is an optional extension. C, C and C are street address lines, C is the postal city/town and C is the state, province or county. The C field must be a valid ISO3166 2-character country code. The C parameter controls whether the handle's contact details are shown on whois records for domain names to which it is associated. By default, the value of C is C<1>. A value of C<0> hides the handle from whois records. You can use the C method to return the ID of the created handle, for use when registering. =head2 Registering a Domain Name We require that you use SSL when making registration and modification requests. WWW::CNic supports SSL communications transparently, since it uses C to do all HTTP communication. C will handle SSL if the C or C modules have been installed. use WWW::CNic; my $query = WWW::CNic->new( command => 'register', domain => 'example.uk.com', username => $handle, password => $passwd, ); $query->set( registrant => 'Example, Inc', chandle => $chandle, thandle => $thandle, period => 2, ); # Set DNS servers $query->set(dns => ['ns0.example.com', 'ns1.example.com']); # OR $query->set(url => 'http://www.example.com/'); my $response = $query->execute; if ($response->is_success) { printf("Domain registered at price %01.2f\n", $response->amount); } else { printf("Error: %s\n", $response->error); } IMPORTANT NOTE: the details you enter for the Client Handle (C) should be the contact details of your customer. In order to make a registration transaction, you need to supply the C and C parameters - these correspond to your Registrar Handle's ID and password. Your password is Ced before it is sent. You need to set a range of extra parameters to register a domain. These are explained below. =over =item 1 C - the name of the domain's registrant. This is a text string corresponding to your customer's name and/or organisation. It should B be a handle ID. =item 2 C - the Client Handle. The Client Handle should correspond to your customer's contact details. =item 3 C - the Technical Handle. This may take two values. It can be a scalar containing the Handle ID of an existing handle, or "C" to set it to be whatever C is. =item 4 C - the DNS servers for the domain. This can either be an anonymous array of DNS hostnames, or a reference to hash such as that below: my $dns = { 'ns0.example.com' => '192.168.1.1', 'ns1.example.com' => '192.168.1.2', }; If you have specified default DNS servers using the Registrar Console you can set C<$dns> to be 'C' and the system will use these. =item 5 C - if this parameter is provided and is not empty, it will be used to set a simple web forwarding for the domain I. =item 6 C - the registration period for the domain name. This is an integer number of years and must be between 2 and 10, or 100. If this field is omitted the domain will be registered for 2 years. =back The response object for this command has all the usual methods (as documented in L), plus the C method, which returns the price in Sterling for the domain. B: In addition to specifying a handle ID or "C" in the C and C fields, it is also possible to use an anonymous hash to supply the details of a new handle. However this is a legacy feature for compatibility with older versions of WWW::CNic and its use is not recommended. =head1 Modifying Domain Names and Handles =head2 Modifying a Domain Name You can use C to do real-time modification of a domain. The procedure is somewhat similar to that of registration. use WWW::CNic; my $query = WWW::CNic->new( command => 'modify', domain => 'example.uk.com', username => $handle, password => $passwd, ); $query->set( thandle => $handle, dns => { drop => 'all', add => ['ns0.example.com', 'ns1.example.com'], } url => 'drop', ); my $response = $query->execute; if ($response->is_success) { print "Domain modified OK.\n"; } else { printf("Error, could not modify domain: %s\n", $response->error); } The C command allows you to add and remove DNS servers and to change the Technical Handle. You can set two parameters for the transaction: =over =item 1 C corresponds to a new Technical Handle. =item 2 C must be an anonymous hash (or a reference to a hash) with two keys: C and C. Their values are anonymous arrays of DNS hostnames. When dropping DNS servers, you can use the string C<'all'> to indicate that you want to delete all the previously delegated DNS servers (this doesn't affect any servers you might add during the same transaction). B: In addition to specifying a handle ID in the C field, it is also possible to use an anonymous hash to supply the details of a new handle. However this usage is not recommended. =item 3 C is an optional element containing a new URL to which to forward the domain. If this parameter is set, then the C parameter is ignored, and any existing DNS servers are removed from the domain. If this parameter contains the special keyword C<'drop'> then the web forwarding will be removed, and the domain will be 'parked'. =back =head2 Modifying a Handle When a handle is created by the C or C commands, or via other interfaces such as the Registrar Console, it is associated with your account. This allows you to update the contact details for that handle. B: this command B be used to completely change the contact details for a handle for a domain name. Instead you should use the C function to change the ID of the handle on the domain name (see above). This function is only for incremental changes to contact details. use WWW::CNic; my $query = WWW::CNic->new( command => 'modify_handle', username => $handle, password => $passwd, ); $query->set( handle => 'H12345', name => 'John Doe', company => 'Example, Inc', street1 => 'Example House', street2 => 'Example Street', city => 'London', sp => 'England', postcode => 'EC1 123', country => 'UK', phone => '+44.8700170900', fax => '+44.8700170901', email => 'jd@example.com', visible => 0, ); my $response = $query->execute; if ($response->is_success) { print "Handle modified OK.\n"; } else { printf("Error, could not modify handle: %s\n", $response->error); } You can change the following values: name company street1 street2 street3 city sp postcode country phone fax email visible The meaning of these fields is identical to those described in the "Creating a Handle" section. Note that C, C and C are all mandatory and cannot be blank. =head2 Renewing a Domain Name use WWW::CNic; use strict; my $query = WWW::CNic->new( command => 'issue_renewals', username => $handle, password => $passwd ); $query->set( domains => ['example1.uk.com', 'example2.uk.com'], period => 2, # 2 years ); my $response = $query->execute; if ($response->is_success) { print "Domain(s) renewed.\n"; } else { printf("Error: %s\n", $response->error); } You can issue advance renewals for domains using this command. You simply set a C parameter to be an anonymous array of domain names, or a reference to an array (eg C<\@domains>). Under normal circumstances, a renewal invoice or proforma is not issued right away, but is queued until the end of the day. If you want to generate a renewal invoice immediately, set the C parameter, like so: $query->set(immediate => 1); my $response = $query->execute; if ($response->is_success) { printf( "%s #%d issued at a value of %01.2f.\n", ($response->invoice > 0 ? 'Invoice' : 'Pro forma'), ($response->invoice > 0 ? $response->invoice : $response->proforma), $response->amount ); } else { printf("Error: %s\n", $response->error); } =head2 Deleting a Domain Name my $query = WWW::CNic->new( command => 'delete', domain => $domain, username => $handle, password => $password, ); my $response = $query->execute; if ($response->is_success) { print "Domain has been deleted.\n"; } else { printf("Error: %s\n", $response->error); } Using this service, you can delete an unwanted domain name. However, you must supply a reason code in order for the deletion to take place. The currently available codes are listed below: Code Meaning R1 Payment not received R2 Fraudulent Registration R3 Domain no longer required by registrant R4 Domain registered in error In accordance with our policy, an e-mail will be sent to the domain's Client Handle informing them that the domain has been deleted. =head2 Requesting Reactivation of a Domain Name Domains that are on the "Pending Deletion" status may be reactivated upon request. This function provides a way to automatically submit a reactivation request. When we receive your request, it will be processed by a member of our Domain Administration team. The domain will then be placed back on the "Live" status, and a registration or renewal invoice will be re-issed. my $query = WWW::CNic->new( command => 'reactivate', domain => $domain, username => $handle, password => $password, ); $query->set('email', 'yourname@example.com'); $query->set('period', 1); # renewal period in years my $response = $query->execute; if ($response->is_success) { print "Reactivation request accepted.\n"; } else { printf("Error: %s\n", $response->error); } If you specify an C parameter, our administrators will send a notification to that address. C may be any integer between 1 and 10. =head2 Pushing a Domain Name To Another Registrar You may request that a domain name on your account be "pushed" to another registrar account. A domain name may only be pushed if: =over =item the domain name is on your account =item the domain name's status is "Live" =item the "gaining" registrar has not opted-out of the "push" system =item there are no unpaid registration or renewal fees against it =back my $query = WWW::CNic->new( command => 'push_domain', username => $handle, password => $password, domain => $domain, handle => $gaining_handle_id, ); my $response = $query->execute; if ($response->is_success) { print "Domain transferred OK.\n"; } else { printf("Error: %s\n", $response->error); } If the transaction is successful, the domain name will be immediately removed from your account. If you are also listed as Technical Contact for the domain name, then this handle will also be changed to the gaining registrar account. This command will also transfer sponsorship of the client and/or technical handles for the domain name, but only if these handles are not associated with any other domains on your account. Where a handle is associated with domains on multiple registrar accounts, the handle becomes "unsponsored". We will send an e-mail to the gaining registrar notifying them of the domain transfer. =head1 Transferring Domain Names =head2 Starting a Domain Transfer You can B a transfer process for one or more domain names using the C command. However, there are "out-of-band" authorisations that must take place before a transfer is completed. The procedure for domain transfers is as follows: 1. The B registrar submits a transfer request. At this point, the transfer status is C. 2. Our system sees the new request and sends an authorisation message to the B registrar. The status of the transfer is now C. 3. The B registrar may then explicitly I or I the transfer request within 5 days. The status of the transfer is now either C or C. 4. If the transfer was B, the B registrar is notified. 5. If the transfer was B, the object is transferred to the B registrar. If the Technical Contact for the domain name matches the B registrar, then this is also changed to the B registrar. 6. If the transfer B submitted with the C parameter, and is not explicitly I or I by the B registrar B, then the transfer is automatically marked as C. The transfer may still be actioned if the B registrar can acquire written authorisation (ideally on company letterhead) from the Registrant. 7. If the transfer B submitted with the C parameter, and is not explicitly I or I by the B registrar B, then the transfer is approved as per 5 above. my $query = WWW::CNic->new( command => 'start_transfer', username => $handle, password => $password, ); $query->set(domains => ['example.uk.com']); $query->set(authinfo => ['abc123xyz']); # optional my $response = $query->execute; if ($response->is_success) { print "Transfer request has been accepted."; } else { printf("Error: %s\n", $response->error); } =head2 Getting a List of Pending Transfers my $query = WWW::CNic->new( use_ssl => 1, command => 'poll_transfers', username => $handle, password => $password, ); my $response = $query->execute; if ($response->is_error) { printf("Error: %s\n", $response->error); } foreach my $transfer ($response->transfers) { printf("Domain: %s\n", $transfer->{domain}); if ($transfer->{type} eq 'in') { printf("\tLosing handle: %s (email %s)\n", $transfer->{losing_id}, $transfer->{losing_email}); } elsif ($transfer->{type} eq 'out') { printf("\tGaining handle: %s (email %s)\n", $transfer->{gaining_id}, $transfer->{gaining_email}); } printf( "\tTransfer initiated on %s\n", scalar(localtime($transfer->{initiated})) ); printf( "\tTransfer expires on on %s\n", scalar(localtime($transfer->{actiondate})) ); } The C method returns an array of hashrefs containing transfer information. If there are no transfers, then the array will be empty. =head2 Cancelling a Domain Transfer my $query = WWW::CNic->new( use_ssl => 1, command => 'cancel_transfer', username => $handle, password => $password, domain => 'example.uk.com', ); my $response = $query->execute; if ($response->is_success) { print "Transfer cancelled.\n"; } else { printf("Error: %s\n", $response->error); } If you are the gaining registrar for a domain transfer, you can cancel the request before it is approved or rejected by the losing registrar. If the transfer has already been approved or rejected, then the server will return an error. =head2 Checking the Status of a Domain Transfer my $query = WWW::CNic->new( use_ssl => 1, command => 'check_transfer', username => $handle, password => $password, domain => 'example.uk.com', ); my $response = $query->execute; if ($response->is_success) { printf("The transfer status of example.uk.com is '%s'\n", $response->status); } else { printf("Error: %s\n", $response->error); } This lets you query the status of a domain name transfer. The returned status is a string and is one of: C, C, C, C. If there have been other transfer requests in the past, the server will return the status of the most recent one. If there are no transfers for the domain name, or you are not the gaining handle, the server will return an error. =head2 Approving a Domain Transfer my $query = WWW::CNic->new( use_ssl => 1, command => 'approve_transfer', username => $handle, password => $password, domain => 'example.uk.com', ); my $response = $query->execute; if ($response->is_success) { print "Transfer approved.\n"; } else { printf("Error: %s\n", $response->error); } If there are no transfers for the domain name, or you are not the losing handle, the server will return an error. =head2 Rejecting a Domain Transfer my $query = WWW::CNic->new( use_ssl => 1, command => 'reject_transfer', username => $handle, password => $password, domain => 'example.uk.com', ); my $response = $query->execute; if ($response->is_success) { print "Transfer rejected.\n"; } else { printf("Error: %s\n", $response->error); } If there are no transfers for the domain name, or you are not the losing handle, the server will return an error. =head1 Account Management =head2 Getting a List of Upcoming Renewals use WWW::CNic; use POSIX qw(strftime); my $months = 3; my $query = WWW::CNic->new( use_ssl => 1, command => 'renewals', username => $handle, password => $passwd, months => $months ); my $response = $query->execute; if ($response->is_success) { foreach my $domain ($response->domains) { printf( "Domain %s expires on %s and will cost %01.2f", $domain, strftime('%d/%m/%Y', localtime($response->expiry($domain))), $response->amount($domain) ); } } else { printf("Error, couldn't get list of upcoming renewals: %s\n", $response->error); } This command lets you retrieve a list of domain names due for renewal in the last C<$months> months. You can use the C and C methods to retrieve the renewal price and expiry date for each domain. =head2 Getting a Domain List use WWW::CNic; use POSIX qw(strftime); my $query = WWW::CNic->new( use_ssl => 1, command => 'list_domains', username => $handle, password => $passwd, ); $query->set( offset => 5, length => 10, orderby => 'name' ); my $response = $query->execute; if ($response->is_success) { foreach my $domain ($response->domains) { printf( "%s: %s - %s (%s)\n", $domain, strftime('%d/%m/%Y', localtime($response->regdate($domain))), strftime('%d/%m/%Y', localtime($response->expirydate($domain))), $response->status($domain), ); } } else { printf("Error: %s\n", $response->error); } You can use this command to retrieve a list of domains against your handle. The response object returned has methods allowing the retrieval of the registration date and expiry date and status. The C and C parameters work in the SQL-ish way you'd expect. The C parameter can be C, C or C. =head2 Getting Pricing Information use WWW::CNic; use strict; my $query = WWW::CNic->new( use_ssl => 1, command => 'get_pricing', username => $handle, password => $password, ); $query->set(type => 'renewal'); my $response = $query->execute; if ($response->is_success) { printf("the price we pay for renewals of uk.com domains is %.2f\n", $response->response('uk.com')); } else { printf("Error: %s\n", $response->error); } This command allows you to retrieve pricing information for your registrar account. You must specify a C parameter, which can be either 'C' (the default) or 'C'. =head2 Listing Outstanding Domains use WWW::CNic; use strict; my $query = WWW::CNic->new( use_ssl => 1, command => 'list_outstanding_domains', username => $handle, password => $password, ); my $response = $query->execute; if ($response->is_error) { printf("Error: %s\n", $response->error); } foreach my $domain ($response->domains) { printf( "Domain: %s\n". "\tExpired: %s\n". "\tDocument: %s #%d\n". "\tIssued on: %s\n". "\tAmount: %s%01.2f\n". "\tType: %s\n". "\tYears: %s\n". "\tBatch: %d\n\n", $domain->{domain}, $domain->{expiry}, ($domain->{invoice} > 0 ? 'Invoice' : 'Pro forma'), ($domain->{invoice} > 0 ? $domain->{invoice} : $domain->{proforma}), $domain->{date}, $domain->{currency}, $domain->{amount}, $domain->{type}, $domain->{years}, $domain->{batch}, ); } This command retrieves a list of all unpaid invoice items for domain names on your account. Each registration or renewal causes on item to be added to an invoice (or pro forma invoice for VAT-paying registrars). You can combine this function with the one below to automatically submit payment advice for invoices (you still need to send us the actual money!). =head2 Submitting Payment Advice use WWW::CNic; use strict; my $query = WWW::CNic->new( use_ssl => 1, command => 'submit_payment_batch', username => $handle, password => $password, ); $query->set('method', 'CH'); # CH for a cheque, BA for a bank transfer $query->set('domains', \@domains); my $response = $query->execute; if ($response->is_error) { printf("Error: %s\n", $response->error); } printf( "Payment Batch #%d created for %d items at %s%01.2f (plus %s%01.2f VAT)\n", $response->response('batch'), $response->response('items'), $response->response('currency'), $response->response('amount'), $response->response('currency'), $response->response('vat'), ); You can use this function to submit advice about a payment for outstanding domain registrations and renewals. Combining this function with the function above allows you to retrieve a list of outstanding domain names, filter them based on whether or not you've received payment or a deletion request from your customer, and generate a payment batch that can be associated with a cheque or wire transfer issued by your company. Please note that you will need to factor in the amount of VAT (if applicable) - this amount is available in the response object. =head1 Feedback We're always keen to find out about how people are using our Toolkit system, and we're happy to accept any comments, suggestions or problems you might have. If you want to get in touch, please e-mail L. =head1 Copyright This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 See Also =over =item * L =item * L =item * L =back =cut WWW-CNic-0.38/lib/WWW/CNic/Simple.pm0000755000076500007650000000660111563231305015610 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: Simple.pm,v 1.12 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Simple; @ISA = qw(Exporter); @EXPORT = qw(&suffixes &check &whois); use WWW::CNic; use strict; =pod =head1 NAME WWW::CNic::Simple - a procedural interface to WWW::CNic =head1 SYNOPSIS #!/usr/bin/perl use WWW::CNic::Simple; my @suffixes = suffixes(); my %results = check('test-domain', 'uk.com', 'uk.net'); print "test-domain.uk.com is registered.\n" if ($results{'uk.com'} == 1); my %whois = whois('test-domain.uk.com'); print "domain status: $whois{status}\n"; =head1 DESCRIPTION This interface is intended for those who want a simplified view of the WWW::CNic library. It provides simple functions for querying the CentralNic system, making it ideal for one-liners and other tasks. Please note that it is not possible to make domain registrations or modifications using C. =head1 FUNCTIONS my @suffixes = suffixes(); This function returns an array containing the currently live CentralNic suffixes. my %result = check($domain, @suffixes); This function does an availability check on C<$domain> against the suffixes contained in C<@suffixes>. Note that if C<@suffixes> is omitted the check will run against all CentralNic domains. The function returns a hash of the form: my %result = ( 'uk.com' => 1, 'uk.net' => 0, 'eu.com' => 0); where C<1> indicates that the domain is already registered. my %whois = whois($domain); This function returns a hash containing whois data for the given C<$domain> This hash is of the form: my %whois = { chandle => { postcode => 'SW6 4SN', country => 'UK', userid => 'C11480', fax => 'N/A', addr => "163 New King's Road, Fulham, London", name => 'Hostmaster', email => 'webservices@centralnic.com', phone => '020 7751 9000', company => 'CentralNic Ltd' }, expires => '1001458800', status => 'Live', thandle => # as chandle above bhandle => # as chandle above registrant => 'CentralNic Ltd', domain => 'toolkit-test.uk.com', created => '1001458800' }; =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut our $HOSTNAME = 'toolkit.centralnic.com'; our $USE_SSL = 0; sub suffixes { return WWW::CNic->new(host=>$HOSTNAME,command=>'suffixes')->execute()->suffixes() } sub check { my $domain = shift; my @suffixes = @_; my $query = WWW::CNic->new( command => 'search', domain => $domain, host => $HOSTNAME); $query->set(suffixlist => @suffixes) if (scalar @suffixes > 0); my $response = $query->execute(); my %results; foreach my $suffix(@suffixes) { $results{$suffix} = ($response->is_registered($suffix) ? 1 : 0); } return %results; } sub whois { my $domain = shift; my %return; my $query = WWW::CNic->new( command => 'whois', domain => $domain, host => $HOSTNAME); my $response = $query->execute(); foreach my $key($response->keys()) { $return{$key} = $response->response($key); } return %return; } 1; WWW-CNic-0.38/lib/WWW/CNic/NG.pm0000755000076500007650000000504711563231305014666 0ustar gavingavin# $Id: NG.pm,v 1.10 2011/05/13 13:31:49 gavin Exp $ # Copyright (c) 2011 CentralNic Ltd. This program is Free Software; you # can use it and/or modify it under the same terms as Perl itself. package WWW::CNic::NG; use WWW::CNic; use strict; our $AUTOLOAD; sub new { use Data::Dumper; my $package = shift(@_); my $self = bless({'package' => $package}, $package); my %params = @_; foreach my $name (keys(%params)) { $self->{$name} = $params{$name}; } return $self; } sub AUTOLOAD { my ($self, %params) = @_; $AUTOLOAD =~ s/^$self->{'package'}:://g; return if ($AUTOLOAD eq 'DESTROY'); my $query = WWW::CNic->new( 'command' => $AUTOLOAD, 'test' => $self->{'test'}, 'username' => $self->{'username'}, 'password' => $self->{'password'}, 'domain' => $params{'domain'}, 'host' => $self->{'host'}, ); $query->set(%params); return $query->execute; }; =pod =head1 NAME WWW::CNic::NG - a next generation interface to C. =head1 USAGE #!/usr/bin/perl use WWW::CNic::NG; use strict; my $cnic = WWW::CNic::NG->new( 'username' => 'H12345', 'password' => 'password', 'test' => 1, # run against the test database ); # $response is a WWW::CNic::Response submodule: my $response = $cnic->whois('domain' => 'example.uk.com'); =head1 SYNOPSIS C provides a simpler and more consistent interface to the C module. It allows you to reuse the same object for multiple API calls, and provides Toolkit commands as methods of the object. =head1 Executing Toolkit Commands If you have used C you will be familiar with using it like so: my $query = WWW::CNic->new( 'command' => 'whois', 'username' => 'H12345', 'password' => 'password', 'domain' => 'example.uk.com', ); $query->set(%more_params); # $response is a WWW::CNic::Response submodule: my $response = $query->execute; This is somewhat cumbersome compared to the earlier example. C serves to tidy up some of this mess. Instead of specifying the desired command as a parameter supplied to the constructor, you simply call the method you want to use on the C object. The method's parameters are then used to prepare a query, and the response from the server is returned from the method. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut 1; WWW-CNic-0.38/lib/WWW/CNic/Response/0000755000076500007650000000000011563231345015615 5ustar gavingavinWWW-CNic-0.38/lib/WWW/CNic/Response/LockDomain.pm0000755000076500007650000000243411563231305020175 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: LockDomain.pm,v 1.2 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::LockDomain; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::LockDomain - a WWW::CNic response object for locking a domain name. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for locking domain names via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/CancelTransfer.pm0000755000076500007650000000257011563231305021050 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: CancelTransfer.pm,v 1.5 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::CancelTransfer; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::CancelTransfer - a WWW::CNic response object for cancelling domain transfer requests. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for cancelling a domain transfer via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); sub status { return $_[0]->response('transfer-status') } 1; WWW-CNic-0.38/lib/WWW/CNic/Response/DeleteDomain.pm0000755000076500007650000000244011563231305020504 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: DeleteDomain.pm,v 1.6 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::DeleteDomain; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::DeleteDomain - a WWW::CNic response object for domain deletion. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for domain deletion requests via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/ValidateDomain.pm0000644000076500007650000000245611563231305021037 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: ValidateDomain.pm,v 1.1 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::ValidateDomain; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::ValidateDomain - a WWW::CNic response object for validating a domain name. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for validating domain names via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/PushDomain.pm0000755000076500007650000000243011563231305020220 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: PushDomain.pm,v 1.4 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::PushDomain; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::PushDomain - a WWW::CNic response object for domain "pushes". =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for domain "push" requests via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/StartTransfer.pm0000755000076500007650000000246011563231305020756 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: StartTransfer.pm,v 1.5 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::StartTransfer; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::StartTransfer - a WWW::CNic response object for domain transfer requests. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for initiating a domain transfer via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/ModifyHandle.pm0000755000076500007650000000245011563231305020516 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: ModifyHandle.pm,v 1.5 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::ModifyHandle; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::ModifyHandle - a WWW::CNic response object for handle modification. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for handle modification requests via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/HandleInfo.pm0000755000076500007650000000245111563231305020163 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: HandleInfo.pm,v 1.5 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::HandleInfo; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::HandleInfo - a WWW::CNic response object for handle information requests. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for handle information requests via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/SubmitPaymentBatch.pm0000755000076500007650000000247511563231305021725 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: SubmitPaymentBatch.pm,v 1.3 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::SubmitPaymentBatch; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::SubmitPaymentBatch - a WWW::CNic response object for submitting payment advice. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for submitting payment advice via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/Renewals.pm0000755000076500007650000000344211563231305017735 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: Renewals.pm,v 1.10 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::Renewals; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::Renewals - a WWW::CNic response object for renewal lists. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for retrieving upcoming renewal lists via the CentralNic Toolkit (I). This module inherits most of its methods from the base class, I. =head1 METHODS Check L for information about methods available from the base class. $response->domains(); This returns an array of domain names that are due for renewal in the given period. $response->amount($domain); This returns the price of the domain renewal (in Sterling) of the C<$domain>. $response->expiry($domain); This returns a UNIX timestamp of the expiry date for C<$domain>. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); sub domains { return grep { /\..{3}$/i } $_[0]->keys() } sub amount { my ($self, $domain) = @_; my @stuff = @{$self->response($domain)}; return $stuff[0]; } sub expiry { my ($self, $domain) = @_; my @stuff = @{$self->response($domain)}; return $stuff[1]; } 1;WWW-CNic-0.38/lib/WWW/CNic/Response/ReactivateDomain.pm0000755000076500007650000000246411563231305021377 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: ReactivateDomain.pm,v 1.5 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::ReactivateDomain; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::ReactivateDomain - a WWW::CNic response object for domain reactivation. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for domain reactivation requests via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/Modify.pm0000755000076500007650000000242611563231305017405 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: Modify.pm,v 1.11 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::Modify; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::Modify - a WWW::CNic response object for domain modification. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for domain modification requests via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1;WWW-CNic-0.38/lib/WWW/CNic/Response/DeclineDomain.pm0000755000076500007650000000244611563231305020653 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: DeclineDomain.pm,v 1.6 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::DeclineDomain; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::DeclineDomain - a WWW::CNic response object for declining renewal. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for declining domain renewals via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/Suffixes.pm0000755000076500007650000000246311563231305017753 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: Suffixes.pm,v 1.12 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::Suffixes; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::Suffixes - a WWW::CNic response object for suffix list lookup. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for suffix list lookup via the CentralNic Toolkit (I). This module inherits most of its methods from the base class, I. =head1 METHODS $response->suffixes(); Returns an array containing a list of all the domain suffixes currently supported by CentralNic. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); sub suffixes { return grep { /[A-Z]{2}\.[A-Z]{3}$/i } sort(keys(%{$_[0]->{_response}})) } 1; WWW-CNic-0.38/lib/WWW/CNic/Response/ListOutstandingDomains.pm0000755000076500007650000000322111563231305022616 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: ListOutstandingDomains.pm,v 1.4 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::ListOutstandingDomains; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::ListOutstandingDomains - a WWW::CNic response object for listing outstanding domains. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for listing all outstanding domains via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS my @domains = $response->domains; This method returns an array of hashrefs detailing currently outstanding domains. The keys of the hashref are: domain expiry type years proforma or invoice date currency amount batch =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); use strict; sub domains { my @domains; my $self = shift; foreach my $domain ($self->keys) { my $info = $self->response($domain); next unless (ref($info) eq 'HASH'); $info->{domain} = $domain; push(@domains, $info); } return @domains; } 1; WWW-CNic-0.38/lib/WWW/CNic/Response/PollTransfers.pm0000755000076500007650000000363511563231305020757 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: PollTransfers.pm,v 1.5 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::PollTransfers; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::PollTransfers - a WWW::CNic::Response object for WWW::CNic::Response. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for listing all pending domain transfers via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all but one of its methods from the base class, I. =head1 METHODS my @transfers = $response->transfers; This returns an array of hashrefs containing information about a transfer. The hashref has the following keys: domain initiated (timestamp) actiondate (timestamp) auto (integer) gaining_id (only present for outgoing transfers) gaining_email (only present for outgoing transfers) losing_id (only present for incoming transfers) losing_email (only present for incoming transfers) type (in or out) =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); use strict; sub transfers { my $self = shift; my @transfers; foreach my $key (grep { /^domain=/ } $self->keys) { my $info = $self->response($key); $info->{type} = $info->{':type'}; delete($info->{':type'}); $key =~ s/^domain=//g; $info->{domain} = $key; push(@transfers, $info); } return @transfers; } 1; WWW-CNic-0.38/lib/WWW/CNic/Response/Whois.pm0000755000076500007650000000313611563231305017246 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: Whois.pm,v 1.14 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::Whois; use vars qw($VERSION); sub response { my ($self, $key) = @_; if (lc($key) =~ /^(c|t|b)handle$/) { my $response = $self->SUPER::response($key); if (ref($response) eq '') { my ($name, $value) = split(/=/, $response, 2); $value =~ s/^\"//g; $value =~ s/\"$//g; return { $name => $value }; } else { return $response; } } else { return $self->SUPER::response($key); } } =pod =head1 NAME WWW::CNic::Response::Whois - a WWW::CNic response object for whois lookups. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for whois lookups via the CentralNic Toolkit (I). This module inherits all of its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/UnlockDomain.pm0000755000076500007650000000244611563231305020543 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: UnlockDomain.pm,v 1.2 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::UnlockDomain; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::UnlockDomain - a WWW::CNic response object for unlocking a domain name. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for unlocking domain names via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/AuthInfo.pm0000755000076500007650000000242311563231305017670 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: AuthInfo.pm,v 1.5 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::AuthInfo; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::AuthInfo - a WWW::CNic response object for retrieving domain transfer auth codes. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for retrieving domain transfer auth codes via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits most of its methods from the base class, I. =head1 METHODS $code = $response->auth_code; This returns the auth code. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); use strict; sub auth_code { $_[0]->response('authcode') } 1; WWW-CNic-0.38/lib/WWW/CNic/Response/RejectTransfer.pm0000755000076500007650000000247411563231305021102 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: RejectTransfer.pm,v 1.3 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::RejectTransfer; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::RejectTransfer - a WWW::CNic response object for rejecting domain transfer requests. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for rejecting a domain transfer via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/Search.pm0000755000076500007650000000361411563231305017363 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: Search.pm,v 1.14 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::Search; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::Search - a WWW::CNic response object for domain searching. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for domain searching via the CentralNic Toolkit (I). This module inherits most of its methods from the base class, I. =head1 METHODS $response->is_registered($suffix); This methods returns true if the domain with the suffix C<$suffix> is registered. $response->registrant($suffix); Returns the registrant string for a registered domain. $response->expiry($suffix); Returns a UNIX timestamp corresponding to the expiry date of the domain name. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); sub is_registered { my ($self, $suffix) = @_; my $domain = (grep { /$suffix$/i } keys %{$self->{_response}})[0]; my $r = $self->response($domain); return ($r == 0 ? undef : (@{$r}[0] == 1)); } sub registrant { my ($self, $suffix) = @_; my $domain = (grep { /$suffix$/i } keys %{$self->{_response}})[0]; return @{$self->response($domain)}[1]; } sub expiry { my ($self, $suffix) = @_; my $domain = (grep { /$suffix$/i } keys %{$self->{_response}})[0]; return @{$self->response($domain)}[2]; } 1; WWW-CNic-0.38/lib/WWW/CNic/Response/DomainList.pm0000755000076500007650000000361711563231305020224 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: DomainList.pm,v 1.11 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::DomainList; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::DomainList - a WWW::CNic response object for domain lists. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for domain list requests via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits most of its methods from the base class, I. =head1 METHODS $response->domains(); Returns an array containing all the domains that match the query. $response->regdate($domain); Returns a Unix timestamp corresponding to the registration date of the domain. $response->expirydate($domain); Returns a Unix timestamp corresponding to the expiry date of the domain. $response->status($domain); Returns a string containing the current status of the domain, for example: 'Live', 'Pending Deletion'. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); sub domains { return grep { /\..{3}$/i } $_[0]->keys() } sub regdate { my ($self, $domain) = @_; my @stuff = @{$self->response($domain)}; return $stuff[1]; } sub expirydate { my ($self, $domain) = @_; my @stuff = @{$self->response($domain)}; return $stuff[2]; } sub status { my ($self, $domain) = @_; my @stuff = @{$self->response($domain)}; return $stuff[0]; } 1; WWW-CNic-0.38/lib/WWW/CNic/Response/CreateHandle.pm0000755000076500007650000000263211563231305020474 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: CreateHandle.pm,v 1.9 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::CreateHandle; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::CreateHandle - a WWW::CNic response object for creating new handles. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for handle creation requests via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS Check L for information about methods available from the base class. $response->handle(); Returns the ID of the handle created. This will be the letter 'H' followed by digits, eg H12345. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); sub handle { return $_[0]->_expand($_[0]->response('handle')) } 1; WWW-CNic-0.38/lib/WWW/CNic/Response/Register.pm0000755000076500007650000000262011563231305017736 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: Register.pm,v 1.12 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::Register; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::Register - a WWW::CNic response object for domain registration. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for domain registrations requests via the CentralNic Toolkit (I). This module inherits most of its methods from the base class, I. =head1 METHODS Check L for information about methods available from the base class. $response->amount(); This method returns the amount (in Sterling) that will be invoiced for the domain name. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); sub amount { return $_[0]->_expand($_[0]->response('amount')) } 1;WWW-CNic-0.38/lib/WWW/CNic/Response/ApproveTransfer.pm0000755000076500007650000000247711563231305021305 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: ApproveTransfer.pm,v 1.3 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::ApproveTransfer; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::ApproveTransfer - a WWW::CNic response object for approving domain transfer requests. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for approving a domain transfer via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/RegistrantTransfer.pm0000755000076500007650000000251711563231305022006 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: RegistrantTransfer.pm,v 1.2 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::RegistrantTransfer; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::RegistrantTransfer - a WWW::CNic response object for domain registrant transfer requests. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for transfering the domain registrant via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/UnDeclineDomain.pm0000755000076500007650000000250111563231305021146 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: UnDeclineDomain.pm,v 1.5 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::UnDeclineDomain; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::UnDeclineDomain - a WWW::CNic response object for reversing a declined renewal. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for reversion a declined domain renewal via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/GetPricing.pm0000755000076500007650000000241211563231305020204 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: GetPricing.pm,v 1.9 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::GetPricing; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::GetPricing - a WWW::CNic response object for retrieving pricing information. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for pricing lookups via the CentralNic Toolkit (I). This module inherits all of its methods from the base class, I. =head1 METHODS This class has no additional methods than those it inherits from I. Check L for information about available methods. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); 1; WWW-CNic-0.38/lib/WWW/CNic/Response/IssueRenewals.pm0000755000076500007650000000274211563231305020750 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: IssueRenewals.pm,v 1.9 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::IssueRenewals; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::IssueRenewals - a WWW::CNic response object for issuing renewals. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for renewals via the CentralNic Toolkit (I). This module inherits most of its methods from the base class, I. =head1 METHODS $response->invoice(); Returns the invoice number, if applicable. $response->proforma(); Returns the pro forma number, if applicable. $response->amount(); Returns the value of the invoice/pro forma, in sterling, excluding VAT. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); sub invoice { return $_[0]->response('invoice') } sub proforma { return $_[0]->response('proforma') } sub amount { return $_[0]->response('amount') } 1;WWW-CNic-0.38/lib/WWW/CNic/Response/CheckTransfer.pm0000755000076500007650000000262511563231305020701 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: CheckTransfer.pm,v 1.5 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response::CheckTransfer; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response::CheckTransfer - a WWW::CNic response object for checking the status of domain transfer requests. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); $query->set( PARAMETERS ); my $response = $query->execute(); =head1 DESCRIPTION Response module for checking the status of a domain transfer via the CentralNic Toolkit (http://toolkit.centralnic.com/). This module inherits all its methods from the base class, I. =head1 METHODS my $status = $response->status; This returns a string representing the status of a transfer. This may be one of: C, C, C, C. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =item * L =back =cut use WWW::CNic::Response; @ISA = qw(WWW::CNic::Response); sub status { return $_[0]->response('transfer-status') } 1; WWW-CNic-0.38/lib/WWW/CNic/Response.pm0000755000076500007650000000771511563231305016164 0ustar gavingavin# Copyright (c) 2011 CentralNic Ltd. All rights reserved. This program is # free software; you can redistribute it and/or modify it under the same # terms as Perl itself. # $Id: Response.pm,v 1.15 2011/05/13 13:31:49 gavin Exp $ package WWW::CNic::Response; use vars qw($VERSION); =pod =head1 NAME WWW::CNic::Response - base class for WWW::CNic response objects. =head1 SYNOPSIS use WWW::CNic; my $query = WWW::CNic->new( OPTIONS ); my $response = $query->execute(); =head1 DESCRIPTION This is the base class for all response objects returned by WWW::CNic. Each query type returns a different object, all of which inherit their basic functionality from this module. This module should never be accessed directly, only through its children. =head1 METHODS All the child classes of WWW::CNic::Response inherit the following methods: $response->is_success(); This returns true if the transaction was completed successfully. If there was a server-side error due to invalid data or a system error, or there was an HTTP error this method will return undef. $response->is_error(); This is the converse of C. It returns true if there was an error. $response->error(); This returns the error message generated, if any. This can be either a server-side error message or an HTTP error. $response->message(); This returns the message returned when the transaction was successful. $response->keys(); This returns an array containing all the keys returned by the server. $response->response($key); This returns the value corresponding to C<$key> as returned by the server. This may be a scalar, or a reference to an array or hash, depending on the context. $response->dump(); This prints a human-readable dump of the data stored in the object to C. Mainly useful in debugging. =head1 COPYRIGHT This module is (c) 2011 CentralNic Ltd. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over =item * http://toolkit.centralnic.com/ =item * L =back =cut sub new { my $self = {}; (my $package, $self->{_raw}) = @_; foreach my $line(split(/\n/, $self->{_raw})) { chomp($line); my ($name, $value) = split(/:\s?/, $line, 2); if ($value =~ /::/) { if ($value =~ /=/) { my %values; foreach my $value(split(/::/, $value)) { my ($n, $v) = split(/=/, $value, 2); $v =~ s/^\"?//; $v =~ s/\"?$//; $values{$n} = $v; } push(@{$self->{_response}{lc($name)}}, \%values); } else { my @values = split(/::/, $value); push(@{$self->{_response}{lc($name)}}, \@values); } } else { push(@{$self->{_response}{lc($name)}}, $value); } } bless($self, $package); return $self; } sub is_success { my $self = shift; return 1 if (($self->{_response}{'query-status'}[0] ? $self->{_response}{'query-status'}[0] : $self->{_response}{'status'}[0]) == 0); return undef; } sub is_error { my $self = shift; return undef if ($self->is_success()); return 1; } sub error { my $self = shift; return $self->{_response}{message}[0]; } sub message { my $self = shift; return $self->response('message'); } sub keys { my $self = shift; return CORE::keys(%{$self->{_response}}); } sub response { my ($self, $key) = @_; my $value = $self->{_response}{$key}; if (ref($value) eq 'ARRAY' && scalar(@{$value}) == 1) { return ${$value}[0]; } else { return $value; } } sub dump { my $self = shift; foreach my $key($self->keys()) { print $key . (' ' x (19 - length($key))) . ': ' . $self->_expand($self->response($key)) . "\n"; } return; } sub _expand { my ($self, $ref) = @_; if (ref($ref) eq 'ARRAY') { my @values; foreach my $el(@{$ref}) { push (@values, $self->_expand($el)); } return join(', ', @values); } elsif (ref($ref) eq 'HASH') { my @values; foreach my $key(CORE::keys(%{$ref})) { push(@values, $key.'='.$self->_expand(${$ref}{$key})); } return join(', ', @values); } else { return $ref; } } 1; WWW-CNic-0.38/t/0000755000076500007650000000000011563231345012214 5ustar gavingavinWWW-CNic-0.38/t/use.t0000755000076500007650000000023011563231306013170 0ustar gavingavin#!/usr/bin/env perl -w # $Id: use.t,v 1.2 2011/05/13 13:31:50 gavin Exp $ use strict; use Test; BEGIN { plan tests => 1 } use WWW::CNic; ok(1); exit;