Provided by: libwww-cnic-perl_0.38-1_all bug

Name

       WWW::CNic::Cookbook - The WWW::CNic Cookbook

Description

       This document provides a fairly complete explanation of how to implement basic Registrar-
       Registry functions with CentralNic using "WWW::CNic".

       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 toolkit@centralnic.com.

Test Mode

       The Toolkit can be told to run in test mode, 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 "test" argument on the constructor, like so:

               my $query = WWW::CNic->new(test => 1, ... );

       You will also need to supply test account credentials rather than production account
       credentials. These can be obtained from the Registrar Console.

Getting Information about Domains

   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 "suffixes" 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;

   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 availability. It also can't handle multiple lookups very
       well.

       The "search" 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 "set()" 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 "is_registered()" which returns true if the
       domain is already registered. Additionally, you can use the "registrant($suffix)" and
       "expiry($suffix)" methods to get the registrant name and a UNIX timestamp of the expiry
       date respectively.

   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 "whois" 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 "registrant" and "status" keys are just strings. The "created" and "expires" keys are
       UNIX timestamps. The "chandle", "thandle" and "bhandle" 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 "dns" 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 "ref()" function to work out which.

       Address data: handles in the CentralNic database follow one of two "styles": old-style
       handles have flat address data (stored in the "address" property), but new-style handles
       have separate properties for street, city and state/province. All handles will have at
       least a non-empty "address" property (for new-style handles this is created by flattening
       the "street1", "street2"... properties). All new-style handles will have a non-empty
       "street1" property.

   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.

   Getting Detailed Information About a Handle
       This command can be used to retrieve information about a handle for which you are the
       sponsor. 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 "visible" 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.

       Address data: handles in the CentralNic database follow one of two "styles": old-style
       handles have flat address data (stored in the "address" property), but new-style handles
       have separate properties for street, city and state/province. All handles will have at
       least a non-empty "address" property (for new-style handles this is created by flattening
       the "street1", "street2"... properties). All new-style handles will have a non-empty
       "street1" property.

Creating New Domains and Handles

   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 "create_handle" 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 "handle" 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 "name", "country" and "email" are mandatory. The "phone" and "fax" fields can be in
       any format, but we request that you use the e164a format:

               +AA.BBB(xCC)

       where "AA" is the dialling code for the country in question, "BBB" is the phone number
       without a local dialling prefix (eg, for the UK, emit the leading zero), and "CC" is an
       optional extension.

       "street1", "street2" and "street3" are street address lines, "city" is the postal
       city/town and "sp" is the state, province or county.

       The "country" field must be a valid ISO3166 2-character country code.

       The "visible" 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 "visible" is
       1. A value of 0 hides the handle from whois records.

       You can use the "handle()" method to return the ID of the created handle, for use when
       registering.

   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 "LWP" to do all HTTP
       communication. "LWP" will handle SSL if the "Crypt::SSLeay" or "IO::Socket::SSL" 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 ("chandle") should be the
       contact details of your customer.

       In order to make a registration transaction, you need to supply the "username" and
       "password" parameters - these correspond to your Registrar Handle's ID and password. Your
       password is "crypt()"ed before it is sent.

       You need to set a range of extra parameters to register a domain. These are explained
       below.

       1.  "registrant" - the name of the domain's registrant. This is a text string
           corresponding to your customer's name and/or organisation. It should not be a handle
           ID.

       2.  "chandle" - the Client Handle. The Client Handle should correspond to your customer's
           contact details.

       3.  "thandle" - the Technical Handle. This may take two values. It can be a scalar
           containing the Handle ID of an existing handle, or ""chandle"" to set it to be
           whatever "chandle" is.

       4.  "dns" - 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 $dns
           to be '"defaults"' and the system will use these.

       5.  "url" - if this parameter is provided and is not empty, it will be used to set a
           simple web forwarding for the domain instead of any DNS servers provided.

       6.  "period" - 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.

       The response object for this command has all the usual methods (as documented in
       WWW::CNic::Response), plus the "amount()" method, which returns the price in Sterling for
       the domain.

       NB: In addition to specifying a handle ID or ""chandle"" in the "chandle" and "thandle"
       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.

Modifying Domain Names and Handles

   Modifying a Domain Name
       You can use "WWW::CNic" 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 "modify" command allows you to add and remove DNS servers and to change the Technical
       Handle. You can set two parameters for the transaction:

       1.  "thandle" corresponds to a new Technical Handle.

       2.  "dns" must be an anonymous hash (or a reference to a hash) with two keys: "add" and
           "drop". Their values are anonymous arrays of DNS hostnames. When dropping DNS servers,
           you can use the string '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).

           NB: In addition to specifying a handle ID in the "thandle" field, it is also possible
           to use an anonymous hash to supply the details of a new handle. However this usage is
           not recommended.

       3.  "url" is an optional element containing a new URL to which to forward the domain. If
           this parameter is set, then the "dns" parameter is ignored, and any existing DNS
           servers are removed from the domain.

           If this parameter contains the special keyword 'drop' then the web forwarding will be
           removed, and the domain will be 'parked'.

   Modifying a Handle
       When a handle is created by the "create_handle" or "register" 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.

       IMPORTANT: this command must not be used to completely change the contact details for a
       handle for a domain name. Instead you should use the "modify" 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 "name", "country" and "email" are all mandatory and cannot be blank.

   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 "domains"
       parameter to be an anonymous array of domain names, or a reference to an array (eg
       "\@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 "immediate" 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);

               }

   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.

   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 "email" parameter, our administrators will send a notification to that
       address. "period" may be any integer between 1 and 10.

   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:

       the domain name is on your account
       the domain name's status is "Live"
       the "gaining" registrar has not opted-out of the "push" system
       there are no unpaid registration or renewal fees against it

               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.

Transferring Domain Names

   Starting a Domain Transfer
       You can start a transfer process for one or more domain names using the "start_transfer"
       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 gaining registrar submits a transfer request. At this point, the transfer status is
       "new".

       2. Our system sees the new request and sends an authorisation message to the losing
       registrar. The status of the transfer is now "pending".

       3. The losing registrar may then explicitly approve or reject the transfer request within
       5 days. The status of the transfer is now either "approved" or "rejected".

       4. If the transfer was rejected, the gaining registrar is notified.

       5. If the transfer was approved, the object is transferred to the gaining registrar. If
       the Technical Contact for the domain name matches the losing registrar, then this is also
       changed to the gaining registrar.

       6. If the transfer was not submitted with the "authinfo" parameter, and is not explicitly
       approved or rejected by the losing registrar within five calendar days, then the transfer
       is automatically marked as "rejected". The transfer may still be actioned if the gaining
       registrar can acquire written authorisation (ideally on company letterhead) from the
       Registrant.

       7. If the transfer was submitted with the "authinfo" parameter, and is not explicitly
       approved or rejected by the losing registrar within five calendar days, 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);

               }

   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 "transfers()" method returns an array of hashrefs containing transfer information. If
       there are no transfers, then the array will be empty.

   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.

   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: "pending", "cancelled", "approved", "rejected". 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.

   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.

   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.

Account Management

   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 $months
       months. You can use the "amount" and "expiry" methods to retrieve the renewal price and
       expiry date for each domain.

   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 "offset" and "length" parameters work in the SQL-ish way you'd
       expect. The "orderby" parameter can be "name", "regdate" or "expirydate".

   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 "type" parameter, which can be either '"registration"' (the default) or
       '"renewal"'.

   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!).

   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.

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 toolkit@centralnic.com.

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.

See Also

       •   <http://toolkit.centralnic.com/>

       •   WWW::CNic

       •   WWW::CNic::Simple