« DRI/Protocol/EPP/Extensions/CloudRegistry/LaunchPhase.pm
↑ Summary
DRI/Protocol/Gandi/WS/Domain.pm »
| 1 | ## Domain Registry Interface, Auxiliary Contacts Extension Mapping for EPP | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2016,2018-2019 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::CentralNic::AuxContact; | ||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||
| 23 | #################################################################################################### | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub register_commands | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
register_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | my ($class,$version)=@_; | |||||||||||||||||||||||||||
| 28 | 0 | state $rcmds = { 'domain' => { | |||||||||||||||||||||||||||
| 29 | 'info' => [ undef, \&info_parse ], | ||||||||||||||||||||||||||||
| 30 | 'create' => [ \&create, undef ], | ||||||||||||||||||||||||||||
| 31 | 'update' => [ \&update, undef ], | ||||||||||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||||||||||
| 33 | }; | ||||||||||||||||||||||||||||
| 34 | 0 | return $rcmds; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub setup | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
setup: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 0 | my ($class,$po,$version)=@_; | |||||||||||||||||||||||||||
| 40 | 0 | state $rns = { 'auxcontact' => 'urn:ietf:params:xml:ns:auxcontact-0.1' }; | |||||||||||||||||||||||||||
| 41 | 0 | $po->ns($rns); | |||||||||||||||||||||||||||
| 42 | 0 | return; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub implements { return 'https://gitlab.centralnic.com/centralnic/epp-auxcontact-extension/blob/1b7a0e935523b306387d236908017ea7ba72f794/draft-brown-auxcontact.txt'; } | ||||||||||||||||||||||||||
|
Subroutine
implements: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | #################################################################################################### | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub info_parse | ||||||||||||||||||||||||||||
| 50 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
info_parse: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 0 | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | |||||||||||||||||||||||||||
| 52 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | my $ns=$mes->ns('auxcontact'); | |||||||||||||||||||||||||||
| 56 | 0 | my $data=$mes->get_extension('auxcontact', 'infData'); | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | return unless defined $data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | my $cs=$rinfo->{domain}->{$oname}->{contact}; | |||||||||||||||||||||||||||
| 60 | 0 | my %ccache=map { $_->id() => $_ } $cs->get_all(); | |||||||||||||||||||||||||||
| 61 | 0 | foreach my $el (Net::DRI::Util::xml_list_children($data)) | |||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||
| 63 | 0 | my ($name,$node)=@$el; | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ($name eq 'contact') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||
| 66 | 0 | my $id=$node->textContent(); | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | $ccache{$id}=$po->create_local_object('contact')->srid($id) unless exists $ccache{$id}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | $cs->add($ccache{$id},$node->getAttribute('type')); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | return; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | sub _build_contacts | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_build_contacts: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 77 | 0 | my ($epp, $cs) = @_; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | my @d; | |||||||||||||||||||||||||||
| 80 | 0 | my %r=map { $_ => 1 } ('registrant', $epp->core_contact_types()); | |||||||||||||||||||||||||||
| 81 | 0 | foreach my $t (sort { $a cmp $b } grep { ! exists $r{$_} } $cs->types()) | |||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||
| 83 | 0 | my @o=$cs->get($t); | |||||||||||||||||||||||||||
| 84 | 0 | push @d,map { [ 'auxcontact:contact',$_->srid(),{'type'=>$t}] } @o; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | return @d; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | sub create | ||||||||||||||||||||||||||||
| 91 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
create: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 92 | 0 | my ($epp,$domain,$rd)=@_; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return unless Net::DRI::Util::has_contact($rd); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | my $cs=$rd->{contact}; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | my @d = _build_contacts($epp, $cs); | |||||||||||||||||||||||||||
| 98 | 0 | ▶ | $epp->message()->command_extension('auxcontact', ['create', @d]) if @d; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | return; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | sub update | ||||||||||||||||||||||||||||
| 104 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
update: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 105 | 0 | my ($epp,$domain,$todo)=@_; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | my $cadd=$todo->add('contact'); | |||||||||||||||||||||||||||
| 108 | 0 | my $cdel=$todo->del('contact'); | |||||||||||||||||||||||||||
| 109 | 0 | my (@add,@del); | |||||||||||||||||||||||||||
| 110 | 0 | ▶ | push @add,_build_contacts($epp,$cadd) if Net::DRI::Util::isa_contactset($cadd); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | push @del,_build_contacts($epp,$cdel) if Net::DRI::Util::isa_contactset($cdel); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | return unless @add || @del; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@add or @del
MC/DC0%0/2
@add or @del
@add
@del
Truth table0%0/3
A or B
A= @addB= @del
| |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | my @d; | |||||||||||||||||||||||||||
| 116 | 0 | ▶ | push @d,['auxcontact:rem',@del] if @del; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | push @d,['auxcontact:add',@add] if @add; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | $epp->message()->command_extension('auxcontact', ['update', @d]) if @d; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | return; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | #################################################################################################### | ||||||||||||||||||||||||||||
| 125 | 1 | 1; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | __END__ | ||||||||||||||||||||||||||||