| 1 | ## Domain Registry Interface, Price Extension Mapping for EPP | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2015,2018 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 | package Net::DRI::Protocol::EPP::Extensions::AusRegistry::Price; | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use feature 'state'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Net::DRI::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Net::DRI::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use Net::DRI::Protocol::EPP::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | #################################################################################################### | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub register_commands | ||||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my ($class,$version)=@_; | ||||||||||||||||||||||||||
|
Subroutine
register_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | state $rops = { 'domain' => { check => [ \&check_build, \&check_parse ], | |||||||||||||||||||||||||||
| 32 | check_multi => [ \&check_build, \&check_parse ], | ||||||||||||||||||||||||||||
| 33 | create => [ \&create_build, undef ], | ||||||||||||||||||||||||||||
| 34 | renew => [ \&renew_build, undef ], | ||||||||||||||||||||||||||||
| 35 | transfer_request => [ \&transfer_build, undef ], | ||||||||||||||||||||||||||||
| 36 | update => [ \&update_build, undef ], | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | }; | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | return $rops; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub setup | ||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my ($class,$po,$version)=@_; | ||||||||||||||||||||||||||
|
Subroutine
setup: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | 0 | state $ns = { 'price' => 'urn:ar:params:xml:ns:price-1.2' }; | |||||||||||||||||||||||||||
| 47 | 0 | $po->ns($ns); | |||||||||||||||||||||||||||
| 48 | 0 | return; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub implements { return 'https://ausregistry.github.io/doc/price-1.2/price-1.2.html'; } | ||||||||||||||||||||||||||
|
Subroutine
implements: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | #################################################################################################### | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | sub check_build | ||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my ($epp,$domain,$rp)=@_; | ||||||||||||||||||||||||||
|
Subroutine
check_build: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 58 | 0 | my $mes=$epp->message(); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return unless Net::DRI::Util::has_key($rp,'price'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | return unless $rp->{price}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | my $eid=$mes->command_extension_register('price','check'); | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | $mes->command_extension($eid,Net::DRI::Protocol::EPP::Util::build_period($rp->{price},'price')) if Net::DRI::Util::is_class($rp->{price},'DateTime::Duration'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | return; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | sub check_parse | ||||||||||||||||||||||||||||
| 70 | { | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | ||||||||||||||||||||||||||
|
Subroutine
check_parse: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | my $data=$mes->get_extension('price','chkData'); | |||||||||||||||||||||||||||
| 76 | 0 | ▶ | return unless defined $data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | foreach my $cd (grep { $_->[0] eq 'cd' } Net::DRI::Util::xml_list_children($data)) | |||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||
| 80 | 0 | my ($domain,%p); | |||||||||||||||||||||||||||
| 81 | 0 | foreach my $el (Net::DRI::Util::xml_list_children($cd->[1])) | |||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||
| 83 | 0 | my ($name,$node)=@$el; | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | if ($name eq 'name') | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||
| 86 | 0 | $domain=$node->textContent(); | |||||||||||||||||||||||||||
| 87 | } elsif ($name=~m/^(category|reason)$/) | ||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||
| 89 | 0 | $p{$name}=$node->textContent(); | |||||||||||||||||||||||||||
| 90 | } elsif ($name eq 'period') | ||||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||
| 92 | 0 | state $rperiods={qw/y years m months/}; | |||||||||||||||||||||||||||
| 93 | 0 | $p{duration}=$po->create_local_object('duration',$rperiods->{$node->getAttribute('unit')},$node->textContent()); | |||||||||||||||||||||||||||
| 94 | } elsif ($name=~m/^(create|renew|transfer|restore)Price$/) | ||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||
| 96 | 0 | $p{$1}=0+$node->textContent(); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | 0 | $rinfo->{$otype}->{$domain}->{price}=\%p; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | return; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | sub _build | ||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||
| 107 | 0 | ▶ | my ($epp,$domain,$rp,$topname)=@_; | ||||||||||||||||||||||||||
|
Subroutine
_build: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 108 | 0 | my $mes=$epp->message(); | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | return unless Net::DRI::Util::has_key($rp,'price'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | return unless $rp->{price}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters('if provided, price element must be "ack" or a decimal number') unless $rp->{price}=~m/^(?:ack|\d+(?:\.\d+)?)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | my $eid=$mes->command_extension_register('price',$topname); | |||||||||||||||||||||||||||
| 115 | 0 | ▶ | $mes->command_extension($eid,['price:ack',$rp->{price} ne 'ack' ? ['price:price', 0+$rp->{price}] : ()]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | return; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub create_build { return _build(@_,'create'); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
create_build: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub renew_build { return _build(@_,'renew'); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
renew_build: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub transfer_build { return _build(@_,'transfer'); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
transfer_build: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | sub update_build | ||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||
| 125 | 0 | ▶ | my ($epp,$domain,$todo,$rp)=@_; | ||||||||||||||||||||||||||
|
Subroutine
update_build: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 126 | 0 | my $rgp=$todo->set('rgp'); | |||||||||||||||||||||||||||
| 127 | 0 | ▶ | return unless Net::DRI::Util::has_key($rgp,'op') && $rgp->{op} eq 'request'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Net::DRI::Util::has_key($rgp, "op") and $rgp->{"op"} eq "request"
MC/DC0%0/2
Net::DRI::Util::has_key($rgp, "op") and $rgp->{"op"} eq "request"
Net::DRI::Util::has_key($rgp, "op")
$rgp->{"op"} eq "request"
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rgp, "op")B= $rgp->{"op"} eq "request"
| |||||||||||||||||||||||||||||
| 128 | 0 | return _build($epp,$domain,$rp,'update'); | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | #################################################################################################### | ||||||||||||||||||||||||||||
| 132 | 1 | 1; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | __END__ | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =pod | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =head1 NAME | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | Net::DRI::Protocol::EPP::Extensions::AusRegistry::Price - EPP Price Extension mapping (https://ausregistry.github.io/doc/price-1.2/price-1.2.html) for Net::DRI | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | Please see the README file for details. | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | For now, support questions should be sent to: | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | Please also see the SUPPORT file in the distribution. | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | Copyright (c) 2015,2018 Patrick Mevzek <netdri@dotandco.com>. | ||||||||||||||||||||||||||||
| 165 | All rights reserved. | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 168 | it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||
| 169 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||
| 170 | (at your option) any later version. | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =cut | ||||||||||||||||||||||||||||