line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## Domain Registry Interface, CentralNic EPP Pricing extension |
2
|
|
|
|
|
|
|
## From https://www.centralnic.com/company/labs/epp/ext/pricing |
3
|
|
|
|
|
|
|
## |
4
|
|
|
|
|
|
|
## Copyright (c) 2011,2013 Patrick Mevzek . All rights reserved. |
5
|
|
|
|
|
|
|
## |
6
|
|
|
|
|
|
|
## This file is part of Net::DRI |
7
|
|
|
|
|
|
|
## |
8
|
|
|
|
|
|
|
## Net::DRI is free software; you can redistribute it and/or modify |
9
|
|
|
|
|
|
|
## it under the terms of the GNU General Public License as published by |
10
|
|
|
|
|
|
|
## the Free Software Foundation; either version 2 of the License, or |
11
|
|
|
|
|
|
|
## (at your option) any later version. |
12
|
|
|
|
|
|
|
## |
13
|
|
|
|
|
|
|
## See the LICENSE file that comes with this distribution for more details. |
14
|
|
|
|
|
|
|
#################################################################################################### |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Net::DRI::Protocol::EPP::Extensions::CentralNic::Pricing; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
667
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
19
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
3
|
use Net::DRI::Util; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
22
|
1
|
|
|
1
|
|
5
|
use Net::DRI::Exception; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
23
|
1
|
|
|
1
|
|
5
|
use Net::DRI::Protocol::EPP::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
9
|
use DateTime::Duration; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
589
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=pod |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Net::DRI::Protocol::EPP::Extensions::CentralNic::Pricing - CentralNic EPP Pricing extension commands for Net::DRI |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Please see the README file for details. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SUPPORT |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
For now, support questions should be sent to: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Enetdri@dotandco.comE |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Please also see the SUPPORT file in the distribution. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Ehttp://www.dotandco.com/services/software/Net-DRI/E |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Patrick Mevzek, Enetdri@dotandco.comE |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 COPYRIGHT |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Copyright (c) 2011,2013 Patrick Mevzek . |
56
|
|
|
|
|
|
|
All rights reserved. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
59
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
60
|
|
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or |
61
|
|
|
|
|
|
|
(at your option) any later version. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
See the LICENSE file that comes with this distribution for more details. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#################################################################################################### |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub register_commands |
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
0
|
0
|
|
my ($class,$version)=@_; |
72
|
0
|
|
|
|
|
|
my %tmp=( |
73
|
|
|
|
|
|
|
check => [ \&check, \&check_parse ], |
74
|
|
|
|
|
|
|
); |
75
|
0
|
|
|
|
|
|
return { 'domain' => \%tmp }; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub setup |
79
|
|
|
|
|
|
|
{ |
80
|
0
|
|
|
0
|
0
|
|
my ($class,$po,$version)=@_; |
81
|
0
|
|
|
|
|
|
$po->ns({ 'pricing' => [ 'urn:centralnic:params:xml:ns:pricing-1.0','pricing-1.0.xsd' ] }); |
82
|
0
|
|
|
|
|
|
return; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#################################################################################################### |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub check |
88
|
|
|
|
|
|
|
{ |
89
|
0
|
|
|
0
|
0
|
|
my ($epp,$domain,$rd)=@_; |
90
|
0
|
|
|
|
|
|
my $mes=$epp->message(); |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
return unless Net::DRI::Util::has_key($rd,'pricing'); |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
0
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('pricing extension can be used only with one domain:name in check operation') if (ref $domain && @$domain > 1); |
95
|
0
|
0
|
0
|
|
|
|
Net::DRI::Exception::usererr_insufficient_parameters('For "pricing" key parameter the value must be a ref hash with keys: currency, action, duration') unless Net::DRI::Util::has_key($rd->{pricing},'currency') && Net::DRI::Util::has_key($rd->{pricing},'action') && Net::DRI::Util::has_key($rd->{pricing},'duration'); |
|
|
|
0
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my @n; |
98
|
0
|
|
|
|
|
|
my $rp=$rd->{pricing}; |
99
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('currency should be 3 letters ISO-4217 code') unless $rp->{currency}=~m/^[A-Z]{3}$/; |
100
|
0
|
|
|
|
|
|
push @n,['pricing:currency',$rp->{currency}]; |
101
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('action should be: create, transfer, renew or restore') unless $rp->{action}=~m/^(?:create|transfer|renew|restore)$/; |
102
|
0
|
|
|
|
|
|
push @n,['pricing:action',$rp->{action}]; |
103
|
0
|
0
|
|
|
|
|
Net::DRI::Exception::usererr_invalid_parameters('duration should be a DateTime::Duration object') unless Net::DRI::Util::is_class($rp->{duration},'DateTime::Duration'); |
104
|
0
|
|
|
|
|
|
my $rj=Net::DRI::Protocol::EPP::Util::build_period($rp->{duration}); |
105
|
0
|
|
|
|
|
|
push @n,['pricing:period',$rj->[1],$rj->[2]]; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my $eid=$mes->command_extension_register('pricing','check'); |
108
|
0
|
|
|
|
|
|
$mes->command_extension($eid,\@n); |
109
|
0
|
|
|
|
|
|
return; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub check_parse |
113
|
|
|
|
|
|
|
{ |
114
|
0
|
|
|
0
|
0
|
|
my ($po,$otype,$oaction,$oname,$rinfo)=@_; |
115
|
0
|
|
|
|
|
|
my $mes=$po->message(); |
116
|
0
|
0
|
|
|
|
|
return unless $mes->is_success(); |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my $chkdata=$mes->get_extension('pricing','chkData'); |
119
|
0
|
0
|
|
|
|
|
return unless $chkdata; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my %p; |
122
|
0
|
|
|
|
|
|
foreach my $el (Net::DRI::Util::xml_list_children($chkdata)) |
123
|
|
|
|
|
|
|
{ |
124
|
0
|
|
|
|
|
|
my ($name,$node)=@$el; |
125
|
0
|
0
|
|
|
|
|
if ($name=~m/^(currency|action)$/) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
126
|
|
|
|
|
|
|
{ |
127
|
0
|
|
|
|
|
|
$p{$1}=$node->textContent(); |
128
|
|
|
|
|
|
|
} elsif ($name eq 'period') |
129
|
|
|
|
|
|
|
{ |
130
|
0
|
|
|
|
|
|
my $unit={y=>'years',m=>'months'}->{$node->getAttribute('unit')}; |
131
|
0
|
|
|
|
|
|
$p{duration}=DateTime::Duration->new($unit => 0+$node->textContent()); |
132
|
|
|
|
|
|
|
} elsif ($name eq 'price') |
133
|
|
|
|
|
|
|
{ |
134
|
0
|
|
|
|
|
|
$p{price}=0+$node->textContent(); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
$rinfo->{domain}->{$oname}->{pricing}=\%p; |
139
|
0
|
|
|
|
|
|
return; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
#################################################################################################### |
143
|
|
|
|
|
|
|
1; |