blib/lib/WWW/eNom/Role/Command.pm

filter: Statementstmt 61.7% 29 / 47 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.3% 8 / 15 Podpod 100% 1 / 1 totaltotal 56.7% 38 / 67 CC 3 SCAR 9.0
CC
3
Cov
57%
__ANON__
6.0
__ANON__
6.0
__ANON__
2.0
CRAP 2.5
« blib/lib/WWW/eNom/Domain.pm ↑ Summary blib/lib/WWW/eNom.pm »
1 package WWW::eNom::Role::Command;
2  
3 42 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 42 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 42 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 42 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 42 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 42 ▶use WWW::eNom::Types qw( HashRef Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 42 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 42 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 42 requires 'response_type';
16 42 with 'WWW::eNom::Role::Command::Raw',
17 'WWW::eNom::Role::Command::Contact',
18 'WWW::eNom::Role::Command::Domain',
19 'WWW::eNom::Role::Command::Domain::Availability',
20 'WWW::eNom::Role::Command::Domain::Registration',
21 'WWW::eNom::Role::Command::Domain::Transfer',
22 'WWW::eNom::Role::Command::Domain::PrivateNameServer',
23 'WWW::eNom::Role::Command::Service';
24  
25 42 our $VERSION = 'v2.0.0'; # VERSION
26 # ABSTRACT: Submission of eNom Commands
27  
28 # Used to force xml_simple response type and restore the existing type afterwards
29 around submit => sub {
30 0 ▶ my ( $orig, $self, $args ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
31  
32 0 my $current_response_type = $self->response_type;
33  
34 0 my $response;
35 try {
36 0 ▶ if( $current_response_type ne 'xml_simple' ) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($current_response_type ne "xml_simple") 0 0 0
37 0 $self->response_type( 'xml_simple' );
38 }
39  
40 0 $response = $self->$orig( $args );
41 }
42 catch {
43 0 ▶ croak $_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
44 }
45 finally {
46 0 ▶ if( $self->response_type ne $current_response_type ) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($self->response_type ne $current_response_type) 0 0 0
47 0 $self->response_type( $current_response_type );
48 }
49 0 };
50 42 };
51  
52 sub submit {
53 0 ▶ my $self = shift;
Subroutine submit: not called CC=1 SCAR=6.9
Pod documented
54 0 my ( %args ) = validated_hash(
55 \@_,
56 method => { isa => Str },
57 params => { isa => HashRef },
58 );
59  
60 0 my $response;
61 try {
62 0 ▶ my $method = $args{method};
Subroutine __ANON__: not called CC=1 SCAR=6.9
63 0 $response = $self->$method( $args{params} );
64 }
65 catch {
66 0 ▶ croak "Error making eNom request: $_";
Subroutine __ANON__: not called CC=1 SCAR=6.9
67 0 };
68  
69 0 return $response;
70 }
71  
72 42 1;
73  
74 __END__
75  
76 =pod
77  
78 =head1 NAME
79  
80 WWW::eNom::Role::Command - Basic Logic for Submission of Requests to eNom
81  
82 =head1 SYNOPSIS
83  
84 use WWW::eNom;
85  
86 my $eNom = WWW::eNom->new( ... );
87 my $response = $eNom->submit({
88 method => 'Check',
89 params => {
90 DomainList => 'drzigman.com, drzigman.net, enom.biz',
91 }
92 });
93  
94 =head1 WITH
95  
96 =over 4
97  
98 =item L<WWW::eNom::Role::Command::Raw>
99  
100 =item L<WWW::eNom::Role::Command::Contact>
101  
102 =item L<WWW::eNom::Role::Command::Domain>
103  
104 =item L<WWW::eNom::Role::Command::Domain::Availability>
105  
106 =item L<WWW::eNom::Role::Command::Domain::Registration>
107  
108 =item L<WWW::eNom::Role::Command::Domain::Transfer>
109  
110 =item L<WWW::eNom::Role::Command::Domain::PrivateNameServer>
111  
112 =item L<WWW::eNom::Role::Command::Service>
113  
114 =back
115  
116 =head1 REQUIRES
117  
118 response_type
119  
120 =head1 DESCRIPTION
121  
122 Primary interface to L<eNom|http://www.enom.com/APICommandCatalog/> API that is used by the rest of the WWW::eNom::Role::Command::* roles. The only reason a consumer would use the submit method directly would be if there was no corresponding Command for the needed operation.
123  
124 =head1 METHODS
125  
126 =head2 submit
127  
128 use WWW::eNom;
129  
130 my $eNom = WWW::eNom->new( ... );
131 my $response = $eNom->submit({
132 method => 'Check',
133 params => {
134 DomainList => 'drzigman.com, drzigman.net, enom.biz',
135 }
136 });
137  
138 The submit method is what sends requests over to L<eNom|http://www.enom.com/APICommandCatalog/>. It accepts a L<raw method|WWW::eNom::Role::Command::Raw> and an HashRef of params. For details on the structure of the params please see L<WWW::eNom::Role::Command::Raw>.
139  
140 The submit method returns a HashRef that represents the data returned by eNom. There is logic built into submit such that requests are always made with an xml_simple response_type which is what drives the creation of the HashRef to form the response.
141  
142 =cut
« blib/lib/WWW/eNom/Domain.pm ↑ Summary blib/lib/WWW/eNom.pm »