File Coverage

blib/lib/Net/DRI/Protocol/EPP/Extensions/VeriSign/Balance.pm
Criterion Covered Total %
statement 9 33 27.2
branch 0 8 0.0
condition n/a
subroutine 3 7 42.8
pod 0 4 0.0
total 12 52 23.0


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, VeriSign Balance object mapping EPP extension
2             ##
3             ## Copyright (c) 2013 Patrick Mevzek . 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::VeriSign::Balance;
16              
17 1     1   933 use strict;
  1         1  
  1         27  
18 1     1   3 use warnings;
  1         2  
  1         21  
19              
20 1     1   3 use Net::DRI::Util;
  1         2  
  1         338  
21              
22             ####################################################################################################
23              
24             sub register_commands
25             {
26 0     0 0   my ($class,$version)=@_;
27 0           return { 'balance' => { info => [ \&balance_info_build, \&balance_info_parse ],
28             },
29             };
30             }
31              
32             sub setup
33             {
34 0     0 0   my ($class,$po,$version)=@_;
35 0           $po->ns({ 'balance' => [ 'http://www.verisign.com/epp/balance-1.0','balance-1.0.xsd' ],
36             });
37 0           return;
38             }
39              
40             ####################################################################################################
41              
42             sub balance_info_build
43             {
44 0     0 0   my ($epp)=@_;
45 0           my $mes=$epp->message();
46              
47 0           $mes->command(['info','balance:info', sprintf('xmlns:balance="%s" xsi:schemaLocation="%s %s"',$mes->nsattrs('balance'))]);
48 0           return;
49             }
50              
51             sub balance_info_parse
52             {
53 0     0 0   my ($po,$otype,$oaction,$oname,$rinfo)=@_;
54 0           my $mes=$po->message();
55 0 0         return unless $mes->is_success();
56              
57 0           my $data=$mes->get_response('balance','infData');
58 0 0         return unless defined $data;
59              
60 0           my %w=(action => 'balance_info');
61 0           foreach my $el (Net::DRI::Util::xml_list_children($data))
62             {
63 0           my ($name,$c)=@$el;
64 0 0         if ($name=~m/^(?:creditLimit|balance|availableCredit)$/)
    0          
65             {
66 0           $w{Net::DRI::Util::remcam($name)}=0+$c->textContent();
67             } elsif ($name eq 'creditThreshold')
68             {
69 0           my ($ct)=Net::DRI::Util::xml_list_children($c);
70 0           $w{'credit_threshold'}=0+$ct->[1]->textContent();
71 0           $w{'credit_threshold_type'}=uc $ct->[0]; ## to be compatible with lowBalance poll
72             }
73             }
74              
75 0           $rinfo->{session}->{balance}=\%w;
76 0           return;
77             }
78              
79             ####################################################################################################
80             1;
81              
82             __END__