WWW/eNom/Role/Command/Raw.pm

filter: Statementstmt 46.3% 45 / 97 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 56.5% 13 / 23 Podpod 0.0% 0 / 2 totaltotal 35.1% 58 / 165 CC 18 SCAR 29.9
CC
18
Cov
34%
_serialize_xml_simple_response
56.0
_make_query_string
42.0
__ANON__
20.0
CRAP 19.9
« WWW/eNom/Role/Command/Domain.pm ↑ Summary WWW/eNom/Role/Command/Service.pm »
1 package WWW::eNom::Role::Command::Raw;
2  
3 47 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 47 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 47 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 47 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 47 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 47 ▶use WWW::eNom::Types qw( HTTPTiny Str Strs );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 47 ▶use Data::Util qw( is_hash_ref );
Subroutine BEGIN: called CC=1 SCAR=0.0
13 47 ▶use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 47 ▶use XML::LibXML::Simple qw( XMLin );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 47 ▶use Mozilla::PublicSuffix qw( public_suffix );
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 47 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 47 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 47 requires 'username', 'password', '_uri', 'response_type';
21  
22 47 our $VERSION = 'v2.7.0'; # VERSION
23 # ABSTRACT: Raw eNom API Commands
24  
25 47 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 # Create methods to support eNom API version 7.8:
27 47 Readonly my $COMMANDS => [qw(
28 AddBulkDomains AddContact AddDomainFolder AddDomainHeader AddHostHeader
29 AddToCart AdvancedDomainSearch AM_AutoRenew AM_Configure AM_GetAccountDetail
30 AM_GetAccounts AssignToDomainFolder AuthorizeTLD CalculateAllHostPackagePricing
31 CalculateHostPackagePricing CancelHostAccount CancelOrder CertChangeApproverEmail
32 CertConfigureCert CertGetApproverEmail CertGetCertDetail CertGetCerts CertModifyOrder
33 CertParseCSR CertReissueCert CertPurchaseCert CertResendApproverEmail
34 CertResendFulfillmentEmail Check CheckLogin CheckNSStatus CommissionAccount
35 Contacts CreateAccount CreateHostAccount CreateSubAccount DeleteAllPOPPaks DeleteContact
36 DeleteCustomerDefinedData DeleteDomainFolder DeleteDomainHeader DeleteFromCart
37 DeleteHostedDomain DeleteHostHeader DeleteNameServer DeletePOP3 DeletePOPPak
38 DeleteRegistration DeleteSubaccount DisableFolderApp DisableServices EnableFolderApp
39 EnableServices Extend Extend_RGP ExtendDomainDNS Forwarding GetAccountInfo GetAccountPassword
40 GetAccountValidation GetAddressBook GetAgreementPage GetAllAccountInfo GetAllDomains
41 GetAllHostAccounts GetAllResellerHostPricing GetBalance GetCartContent GetCatchAll GetCerts
42 GetConfirmationSettings GetContacts GetCusPreferences GetCustomerDefinedData GetCustomerPaymentInfo
43 GetDNS GetDNSStatus GetDomainCount GetDomainExp GetDomainFolderDetail GetDomainFolderList
44 GetDomainHeader GetDomainInfo GetDomainNameID GetDomains GetDomainServices GetDomainSLDTLD
45 GetDomainSRVHosts GetDomainStatus GetDomainSubServices GetDotNameForwarding GetExpiredDomains
46 GetExtAttributes GetExtendInfo GetFilePermissions GetForwarding GetGlobalChangeStatus
47 GetGlobalChangeStatusDetail GetHomeDomainList GetHostAccount GetHostAccounts GetHostHeader GetHosts
48 GetIDNCodes GetIPResolver GetMailHosts GetMetaTag GetNameSuggestions GetNews GetOrderDetail
49 GetOrderList GetPasswordBit GetPOP3 GetPOPExpirations GetPOPForwarding GetProductNews
50 GetProductSelectionList GetRegHosts GetRegistrationStatus GetRegLock GetRenew GetReport
51 GetResellerHostPricing GetResellerInfo GetServiceContact GetSPFHosts GetStorageUsage
52 GetSubAccountDetails GetSubAccountPassword GetSubAccounts GetSubaccountsDetailList GetTLDDetails
53 GetTLDList GetTransHistory GetWebHostingAll GetWhoisContact GetWPPSInfo GM_CancelSubscription
54 GM_CheckDomain GM_GetCancelReasons GM_GetControlPanelLoginURL GM_GetRedirectScript GM_GetStatuses
55 GM_GetSubscriptionDetails GM_GetSubscriptions GM_ReactivateSubscription GM_RenewSubscription
56 GM_UpdateBillingCycle GM_UpdateSubscriptionDetails HostPackageDefine HostPackageDelete HostPackageModify
57 HostPackageView HostParkingPage InsertNewOrder IsFolderEnabled ListDomainHeaders ListHostHeaders
58 ListWebFiles MetaBaseGetValue MetaBaseSetValue ModifyDomainHeader ModifyHostHeader ModifyNS
59 ModifyNSHosting ModifyPOP3 MySQL_GetDBInfo NameSpinner NM_CancelOrder NM_ExtendOrder
60 NM_GetPremiumDomainSettings NM_GetSearchCategories NM_ProcessOrder NM_Search
61 NM_SetPremiumDomainSettings ParseDomain PE_GetCustomerPricing PE_GetDomainPricing PE_GetEapPricing
62 PE_GetPOPPrice PE_GetPremiumPricing PE_GetProductPrice PE_GetResellerPrice PE_GetRetailPrice
63 PE_GetRetailPricing PE_GetRocketPrice PE_GetTLDID PE_SetPricing PP_CancelSubscription PP_CheckUpgrade
64 PP_GetCancelReasons PP_GetControlPanelLoginURL PP_GetStatuses PP_GetSubscriptionDetails PP_GetSubscriptions
65 PP_ReactivateSubscription PP_UpdateSubscriptionDetails PP_ValidatePassword Portal_GetDomainInfo
66 Portal_GetAwardedDomains Portal_GetToken Portal_UpdateAwardedDomains PreConfigure Purchase PurchaseHosting
67 PurchasePOPBundle PurchasePreview PurchaseServices PushDomain Queue_GetInfo Queue_GetExtAttributes
68 Queue_DomainPurchase Queue_GetDomains Queue_GetOrders Queue_GetOrderDetail RAA_GetInfo RAA_ResendNotification
69 RC_CancelSubscription RC_FreeTrialCheck RC_GetLoginToken RC_GetSubscriptionDetails RC_GetSubscriptions
70 RC_RebillSubscription RC_ResetPassword RC_SetBillingCycle RC_SetPassword RC_SetSubscriptionDomain
71 RC_SetSubscriptionName RefillAccount RegisterNameServer RemoveTLD RemoveUnsyncedDomains RenewPOPBundle
72 RenewServices RPT_GetReport SendAccountEmail ServiceSelect SetCatchAll SetCustomerDefinedData SetDNSHost
73 SetDomainSRVHosts SetDomainSubServices SetDotNameForwarding SetFilePermissions SetHosts SetIPResolver
74 SetPakRenew SetPassword SetPOPForwarding SetRegLock SetRenew SetResellerServicesPricing SetResellerTLDPricing
75 SetSPFHosts SetUpPOP3User SL_AutoRenew SL_Configure SL_GetAccountDetail SL_GetAccounts StatusDomain
76 SubAccountDomains SynchAuthInfo TEL_AddCTHUser TEL_GetCTHUserInfo TEL_GetCTHUserList TEL_GetPrivacy TEL_IsCTHUser
77 TEL_UpdateCTHUser TEL_UpdatePrivacy TLD_AddWatchlist TLD_DeleteWatchlist TLD_GetTLD TLD_GetWatchlist
78 TLD_GetWatchlistTlds TLD_Overview TLD_PortalGetAccountInfo TLD_PortalUpdateAccountInfo TM_Check TM_GetNotice
79 TM_UpdateCart TP_CancelOrder TP_CreateOrder TP_GetDetailsByDomain TP_GetOrder TP_GetOrderDetail TP_GetOrderReview
80 TP_GetOrdersByDomain TP_GetOrderStatuses TP_GetTLDInfo TP_ResendEmail TP_ResubmitLocked TP_SubmitOrder
81 TP_UpdateOrderDetail TS_AutoRenew TS_Configure TS_GetAccountDetail TS_GetAccounts UpdateAccountInfo
82 UpdateAccountPricing UpdateCart UpdateCusPreferences UpdateDomainFolder UpdateExpiredDomains
83 UpdateHostPackagePricing UpdateMetaTag UpdateNameServer UpdateNotificationAmount UpdatePushList
84 UpdateRenewalSettings ValidatePassword WBLConfigure WBLGetCategories WBLGetFields WBLGetStatus
85 WebHostCreateDirectory WebHostCreatePOPBox WebHostDeletePOPBox WebHostGetCartItem WebHostGetOverageOptions
86 WebHostGetOverages WebHostGetPackageComponentList WebHostGetPackageMinimums WebHostGetPackages WebHostGetPOPBoxes
87 WebHostGetResellerPackages WebHostGetStats WebHostHelpInfo WebHostSetCustomPackage WebHostSetOverageOptions
88 WebHostUpdatePassword WebHostUpdatePOPPassword WSC_GetAccountInfo WSC_GetAllPackages WSC_GetPricing WSC_Update_Ops
89 XXX_GetMemberId XXX_RemoveMemberId XXX_SetMemberId
90 )];
91  
92 has '_api_commands' => (
93 is => 'ro',
94 isa => Strs,
95 0 ▶ default => sub { $COMMANDS },
Subroutine __ANON__: not called CC=1 SCAR=6.9
96 47 init_arg => undef,
97 );
98  
99 has '_ua' => (
100 is => 'ro',
101 isa => HTTPTiny,
102 lazy => 1,
103 0 ▶ default => sub { HTTP::Tiny->new },
Subroutine __ANON__: not called CC=1 SCAR=6.9
104 47 );
105  
106 0 ▶sub BUILD {
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
107 0 my $self = shift;
108  
109 0 $self->install_methods();
110  
111 0 return;
112 }
113  
114 0 ▶sub install_methods {
Subroutine install_methods: not called CC=2 SCAR=17.9
Pod undocumented
115 0 my $self = shift;
116  
117 0 for my $command (@{ $self->_api_commands }) {
118 $self->meta->add_method(
119 0 ▶ $command => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
120 0 my $self = shift;
121 0 ▶ my %args = @_ == 1 && is_hash_ref( $_[0] ) ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && is_hash_ref($_[0]) ? : 0 0 0
Condition0%0/3
@_ == 1 and is_hash_ref($_[0])
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and is_hash_ref($_[0])
@_ == 1 is_hash_ref($_[0])
Truth table0%0/3
A and B
A= @_ == 1B= is_hash_ref($_[0])
ABresult
0X0
100
111
122  
123 0 my $uri = $self->_make_query_string( $command, \%args );
124 0 my $response = $self->_ua->get( $uri )->{content};
125  
126 # print STDERR "URI: $uri\n";
127  
128 0 ▶ if ( $self->response_type eq "xml_simple" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->response_type eq "xml_simple") 0 0 0
129 0 $response = $self->_serialize_xml_simple_response( $response );
130 }
131  
132 # use Data::Dumper;
133 # print STDERR 'Response: ' . Dumper( $response );
134  
135 0 return $response;
136 }
137 0 );
138 }
139  
140 0 return;
141 }
142  
143 0 ▶sub _make_query_string {
Subroutine _make_query_string: not called CC=6 SCAR=37.4
144 0 my $self = shift;
145 0 my $command = shift;
146 0 ▶ my %args = @_ == 1 && is_hash_ref( $_[0] ) ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && is_hash_ref($_[0]) ? : 0 0 0
Condition0%0/3
@_ == 1 and is_hash_ref($_[0])
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and is_hash_ref($_[0])
@_ == 1 is_hash_ref($_[0])
Truth table0%0/3
A and B
A= @_ == 1B= is_hash_ref($_[0])
ABresult
0X0
100
111
147  
148 0 my $uri = $self->_uri;
149 0 ▶ if ( $command ne "CertGetApproverEmail" && exists $args{Domain} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command ne "CertGetApproverEmail" and exists $args{"Domain"}) 0 0 0
Condition0%0/3
$command ne "CertGetApproverEmail" and exists $args{"Domain"}
!ll&&!rl&&r
000
MC/DC0%0/2
$command ne "CertGetApproverEmail" and exists $args{"Domain"}
$command ne "CertGetApproverEmail" exists $args{"Domain"}
Truth table0%0/3
A and B
A= $command ne "CertGetApproverEmail"B= exists $args{"Domain"}
ABresult
0X0
100
111
150 0 @args{qw(SLD TLD)} = $self->_split_domain(delete $args{Domain});
151 }
152  
153 0 ▶ my $response_type = $self->response_type eq 'xml_simple' ? 'xml' : $self->response_type;
Branch: 1 branch
BranchTrueFalseTotal
$self->response_type eq 'xml_simple' ? : 0 0 0
154  
155 0 $uri->query_form(
156 command => $command,
157 uid => $self->username,
158 pw => $self->password,
159 responseType => $response_type,
160 %args,
161 );
162  
163 0 return $uri;
164 }
165  
166 0 ▶sub _split_domain {
Subroutine _split_domain: not called CC=1 SCAR=6.9
167 0 my $self = shift;
168 0 my ( $domain ) = pos_validated_list( \@_, { isa => Str } );
169  
170 0 ▶ return try {
Subroutine __ANON__: not called CC=3 SCAR=24.8
171 # Look for an eNom wildcard TLD:
172 0 ▶ if( $domain =~ qr|(.+)\.([*12@]+)$|x ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($domain =~ qr/(.+)\.([*12\@]+)$/x) 0 0 0
173 0 return ( $1, $2 );
174 }
175  
176 0 my $suffix = public_suffix($domain);
177 0 ▶ if( !$suffix ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($suffix) 0 0 0
178 0 croak 'Unable to find a suffix from the domain';
179 }
180  
181 # Finally, add in the neccesary API arguments:
182 0 my ( $sld ) = $domain =~ /^(.+)\.$suffix$/x;
183  
184 0 return ($sld, $suffix);
185 }
186 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
187 0 croak "Domain name, $domain, does not look like a valid domain.";
188 0 };
189 }
190  
191 0 ▶sub _serialize_xml_simple_response {
Subroutine _serialize_xml_simple_response: not called CC=7 SCAR=40.3
192 0 my $self = shift;
193 0 my ( $response ) = pos_validated_list( \@_, { isa => Str } );
194  
195 0 $response = XMLin($response);
196  
197 0 ▶ $response->{errors} &&= [ values %{ $response->{errors} } ];
Condition0%0/2
$response->{"errors"} &&= [values %{$$response{"errors"};}]
!ll
00
MC/DC0%0/1
$response->{"errors"} &&= [values %{$$response{"errors"};}]
$response->{"errors"}
Truth table0%0/2
A
A= $response->{"errors"}
Aresult
00
11
198 0 ▶ $response->{responses} &&= $response->{responses}{response};
Condition0%0/3
$response->{"responses"} &&= $response->{"responses"}{"response"}
!ll&&!rl&&r
000
MC/DC0%0/2
$response->{"responses"} &&= $response->{"responses"}{"response"}
$response->{"responses"} $response->{"responses"}{"response"}
Truth table0%0/3
A &&= B
A= $response->{"responses"}B= $response->{"responses"}{"response"}
ABresult
0X0
100
111
199 $response->{responses} = [ $response->{responses} ]
200 0 ▶ if $response->{ResponseCount} == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $response->{"ResponseCount"} == 1 0 0 0
201  
202 0 foreach my $key ( keys %{$response} ) {
203 0 ▶ next unless $key =~ /(.*?)(\d+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /(.*?)(\d+)$/ 0 0 0
204  
205 0 ▶ $response->{$1} = undef if ref $response->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if ref $response->{$key} 0 0 0
206 0 $response->{$1}[ $2 - 1 ] = delete $response->{$key};
207 }
208  
209 0 return $response;
210 }
211  
212 47 1;
213  
214 __END__
« WWW/eNom/Role/Command/Domain.pm ↑ Summary WWW/eNom/Role/Command/Service.pm »