1## Domain Registry Interface, AFNIC Email Protocol
2##
3## Copyright (c) 2006,2008,2009 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4##
5## This file is part of Net::DRI
6##
7## Net::DRI is free software; you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation; either version 2 of the License, or
10## (at your option) any later version.
11##
12## See the LICENSE file that comes with this distribution for more details.
13#
14#
15#
16####################################################################################################
17
18package Net::DRI::Protocol::AFNIC::Email;
19
20use strict;
21
22use base qw(Net::DRI::Protocol);
23
24use Email::Valid;
25
26use Net::DRI::Exception;
27use Net::DRI::Protocol::AFNIC::Email::Message;
28use Net::DRI::Data::Contact::AFNIC;
29
30our $VERSION=do { my @r=(q$Revision: 1.5 $=~/\d+/g); sprintf("%d".".%02d" x $#r, @r); };
31
32=pod
33
34=head1 NAME
35
36Net::DRI::Protocol::AFNIC::Email - AFNIC Email Protocol for Net::DRI
37
38=head1 DESCRIPTION
39
40Please see the README file for details.
41
42=head1 SUPPORT
43
44For now, support questions should be sent to:
45
46E<lt>netdri@dotandco.comE<gt>
47
48Please also see the SUPPORT file in the distribution.
49
50=head1 SEE ALSO
51
52E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
53
54=head1 AUTHOR
55
56Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
57
58=head1 COPYRIGHT
59
60Copyright (c) 2006,2008,2009 Patrick Mevzek <netdri@dotandco.com>.
61All rights reserved.
62
63This program is free software; you can redistribute it and/or modify
64it under the terms of the GNU General Public License as published by
65the Free Software Foundation; either version 2 of the License, or
66(at your option) any later version.
67
68See the LICENSE file that comes with this distribution for more details.
69
70=cut
71
72####################################################################################################
73
74sub new
75{
76 my ($c,$drd,$rp)=@_;
77 my $clientid=$rp->{username};
78 my $clientpw=$rp->{password};
79 my $emailfrom=$rp->{email_from};
80
81 Net::DRI::Exception::usererr_insufficient_parameters('client id must be defined') unless $clientid;
82 Net::DRI::Exception::usererr_insufficient_parameters('client password must be defined') unless $clientpw;
83 Net::DRI::Exception::usererr_insufficient_parameters('from email must be defined') unless $emailfrom;
84 Net::DRI::Exception::usererr_invalid_parameters($emailfrom.' is not a valid email address') unless Email::Valid->rfc822($emailfrom);
85
86 my $self=$c->SUPER::new();
87 $self->name('afnic_email');
88 $self->version($VERSION);
89
90 foreach my $o (qw/ns contact/) { $self->capabilities('domain_update',$o,['set']); } ## no registrant, as there is a separate trade() call
91
92 $self->factories('message',sub { my $m=Net::DRI::Protocol::AFNIC::Email::Message->new(@_); $m->client_auth({id => $clientid, pw => $clientpw}); $m->email_from($emailfrom); return $m; });
93 $self->factories('contact',sub { return Net::DRI::Data::Contact::AFNIC->new(); });
94 $self->_load();
95 return $self;
96}
97
98sub _load
99{
100 my ($self)=@_;
101
102 my @class=map { 'Net::DRI::Protocol::AFNIC::Email::'.$_ } ('Domain');
103
104 $self->SUPER::_load(@class);
105}
106
107####################################################################################################
1081;
109