| 1 | # Copyright (c) 2016 CentralNic Ltd. All rights reserved. This program is | ||||||||||
| 2 | # free software; you can redistribute it and/or modify it under the same | ||||||||||
| 3 | # terms as Perl itself. | ||||||||||
| 4 | # | ||||||||||
| 5 | # $Id: Command.pm,v 1.4 2011/12/03 11:44:51 gavin Exp $ | ||||||||||
| 6 | package Net::EPP::Frame::Command; | ||||||||||
| 7 | 1 | ▶ | use Net::EPP::Frame::Command::Check; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Net::EPP::Frame::Command::Create; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Net::EPP::Frame::Command::Delete; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Net::EPP::Frame::Command::Info; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Net::EPP::Frame::Command::Login; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Net::EPP::Frame::Command::Logout; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use Net::EPP::Frame::Command::Poll; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use Net::EPP::Frame::Command::Renew; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use Net::EPP::Frame::Command::Transfer; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use Net::EPP::Frame::Command::Update; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | ▶ | use base qw(Net::EPP::Frame); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | =pod | ||||||||||
| 21 | |||||||||||
| 22 | =head1 NAME | ||||||||||
| 23 | |||||||||||
| 24 | Net::EPP::Frame::Command - an instance of L<Net::EPP::Frame> for client commands | ||||||||||
| 25 | |||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||
| 27 | |||||||||||
| 28 | This module is a base class for the Net::EPP::Frame::* subclasses, you should | ||||||||||
| 29 | never need to access it directly. | ||||||||||
| 30 | |||||||||||
| 31 | =head1 OBJECT HIERARCHY | ||||||||||
| 32 | |||||||||||
| 33 | L<XML::LibXML::Node> | ||||||||||
| 34 | +----L<XML::LibXML::Document> | ||||||||||
| 35 | +----L<Net::EPP::Frame> | ||||||||||
| 36 | +----L<Net::EPP::Frame::Command> | ||||||||||
| 37 | |||||||||||
| 38 | =cut | ||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | 0 | my $package = shift; | |||||||||
| 42 | 0 | my $self = $package->SUPER::new('command'); | |||||||||
| 43 | 0 | return bless($self, $package); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub addObject() { | ||||||||
|
Subroutine
addObject: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 47 | 0 | my ($self, $object, $ns, $schema) = @_; | |||||||||
| 48 | |||||||||||
| 49 | 0 | my $obj = $self->createElement($self->getCommandType); | |||||||||
| 50 | 0 | $obj->setNamespace($ns, $object); | |||||||||
| 51 | 0 | $self->getNode($self->getCommandType)->addChild($obj); | |||||||||
| 52 | |||||||||||
| 53 | 0 | return $obj; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub _addExtraElements { | ||||||||
|
Subroutine
_addExtraElements: not called CC=2 SCAR=17.9
| |||||||||||
| 57 | 0 | my $self = shift; | |||||||||
| 58 | |||||||||||
| 59 | 0 | ▶ | $self->command->addChild($self->createElement($self->getCommandType)) if ($self->getCommandType ne ''); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 0 | $self->command->addChild($self->createElement('clTRID')); | |||||||||
| 61 | |||||||||||
| 62 | 0 | $self->_addCommandElements; | |||||||||
| 63 | 0 | return 1; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub _addCommandElements { | ||||||||
|
Subroutine
_addCommandElements: not called CC=1 SCAR=0.0
| |||||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | =pod | ||||||||||
| 70 | |||||||||||
| 71 | =head1 METHODS | ||||||||||
| 72 | |||||||||||
| 73 | my $object = $frame->addObject(@spec); | ||||||||||
| 74 | |||||||||||
| 75 | This method creates and returns a new element corresponding to the data in | ||||||||||
| 76 | C<@spec>, and appends it to the "command" element (as returned by the | ||||||||||
| 77 | C<getCommandType()> method below). | ||||||||||
| 78 | |||||||||||
| 79 | The L<Net::EPP::Frame::ObjectSpec> module can be used to quickly retrieve EPP | ||||||||||
| 80 | object specifications. | ||||||||||
| 81 | |||||||||||
| 82 | my $type = $frame->getCommandType; | ||||||||||
| 83 | |||||||||||
| 84 | This method returns a scalar containing the command type (eg L<'create'>). | ||||||||||
| 85 | |||||||||||
| 86 | my $type = $frame->getCommandNode; | ||||||||||
| 87 | |||||||||||
| 88 | This method returns the L<XML::LibXML::Element> object corresponding to the | ||||||||||
| 89 | command in question, eg the C<E<lt>createE<gt>> element (for a | ||||||||||
| 90 | L<Net::EPP::Frame::Command::Create> object). It is within this element that | ||||||||||
| 91 | EPP objects are placed. | ||||||||||
| 92 | |||||||||||
| 93 | my $node = $frame->command; | ||||||||||
| 94 | |||||||||||
| 95 | This method returns the L<XML::LibXML::Element> object corresponding to the | ||||||||||
| 96 | C<E<lt>commandE<gt>> element. | ||||||||||
| 97 | |||||||||||
| 98 | my $node = $frame->clTRID; | ||||||||||
| 99 | |||||||||||
| 100 | This method returns the L<XML::LibXML::Element> object corresponding to the | ||||||||||
| 101 | C<E<lt>clTRIDE<gt>> element. | ||||||||||
| 102 | |||||||||||
| 103 | =cut | ||||||||||
| 104 | |||||||||||
| 105 | 0 | ▶ | sub getCommandType { | ||||||||
|
Subroutine
getCommandType: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 106 | 0 | my $self = shift; | |||||||||
| 107 | 0 | my $type = ref($self); | |||||||||
| 108 | 0 | my $me = __PACKAGE__; | |||||||||
| 109 | 0 | $type =~ s/^$me\:+//; | |||||||||
| 110 | 0 | $type =~ s/\:{2}.+//; | |||||||||
| 111 | 0 | return lc($type); | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | 0 | ▶ | sub getCommandNode { | ||||||||
|
Subroutine
getCommandNode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 115 | 0 | my $self = shift; | |||||||||
| 116 | 0 | return $self->getNode($self->getCommandType); | |||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | 0 | ▶ | sub command { $_[0]->getNode('command') } | ||||||||
|
Subroutine
command: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 120 | 0 | ▶ | sub clTRID { $_[0]->getNode('clTRID') } | ||||||||
|
Subroutine
clTRID: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 121 | |||||||||||
| 122 | =pod | ||||||||||
| 123 | |||||||||||
| 124 | my $extension = $frame->extension; | ||||||||||
| 125 | |||||||||||
| 126 | This method returns the L<XML::LibXML::Element> object corresponding to the | ||||||||||
| 127 | C<E<lt>extensionE<gt>> element. If one does not exist, it will be created and | ||||||||||
| 128 | inserted at the correct position. | ||||||||||
| 129 | |||||||||||
| 130 | =cut | ||||||||||
| 131 | |||||||||||
| 132 | 0 | ▶ | sub extension { | ||||||||
|
Subroutine
extension: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 133 | 0 | my $self = shift; | |||||||||
| 134 | |||||||||||
| 135 | 0 | my $extension = $self->getNode('extension'); | |||||||||
| 136 | |||||||||||
| 137 | 0 | ▶ | $extension = $self->getCommandNode->parentNode->insertAfter($self->createElement('extension'), $self->getCommandNode) if (!$extension); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 138 | |||||||||||
| 139 | 0 | return $extension; | |||||||||
| 140 | } | ||||||||||
| 141 | |||||||||||
| 142 | =pod | ||||||||||
| 143 | |||||||||||
| 144 | my $element = $frame->createExtensionElementFor($xmlns); | ||||||||||
| 145 | |||||||||||
| 146 | This methods creates a new element in the C<E<lt>extensionE<gt>> element for the | ||||||||||
| 147 | EPP extension specified by C<$xmlns> which can be obtained from | ||||||||||
| 148 | L<Net::EPP::Frame::ObjectSpec>. The element's tag name will correspond to the | ||||||||||
| 149 | command name (C<create>, C<update> etc). | ||||||||||
| 150 | |||||||||||
| 151 | Example usage: | ||||||||||
| 152 | |||||||||||
| 153 | my $frame = Net::EPP::Frame::Command::Info::Domain->new; | ||||||||||
| 154 | |||||||||||
| 155 | my $element = $frame->createExtensionElementFor( | ||||||||||
| 156 | Net::EPP::Frame::ObjectSpec->xmlns('foobar') | ||||||||||
| 157 | ); | ||||||||||
| 158 | |||||||||||
| 159 | // prints <info xmlns="namespace:for:foobar"/> | ||||||||||
| 160 | print $element->toString(); | ||||||||||
| 161 | |||||||||||
| 162 | =cut | ||||||||||
| 163 | |||||||||||
| 164 | 0 | ▶ | sub createExtensionElementFor { | ||||||||
|
Subroutine
createExtensionElementFor: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 165 | 0 | my ($self, $xmlns) = @_; | |||||||||
| 166 | |||||||||||
| 167 | 0 | return $self->extension->appendChild($self->createElementNS($xmlns, $self->getCommandType)); | |||||||||
| 168 | } | ||||||||||
| 169 | |||||||||||
| 170 | 1 | 1; | |||||||||