Gandi/Role/XMLRPC.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 43 CC 3 SCAR 16.7
CC
3
Cov
0%
api_call
12.0
_build_proxy
2.0
cast_value
2.0
CRAP 5.3
1 #
2 # This file is part of Net-Gandi
3 #
4 # This software is copyright (c) 2012 by Natal Ngétal.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 package Net::Gandi::Role::XMLRPC;
10 {
11 $Net::Gandi::Role::XMLRPC::VERSION = '1.122180';
12 }
13  
14 # ABSTRACT: A Perl interface for gandi api
15  
16 use XMLRPC::Lite;
17 use Moose::Role;
18 use MooseX::Types::Moose 'Str';
19  
20 use Carp;
21  
22 has '_proxy' => (
23 is => 'ro',
24 isa => 'XMLRPC::Lite',
25 builder => '_build_proxy',
26 init_arg => undef,
27 lazy => 1,
28 );
29  
30 sub _build_proxy {
31 my ( $self ) = @_;
32  
33 my $proxy = XMLRPC::Lite->proxy($self->apiurl, timeout => $self->timeout );
34 $proxy->transport->agent($self->useragent);
35  
36 $proxy;
37 }
38  
39 sub api_call {
40 my ( $self, $method, @args ) = @_;
41  
42 my $api_response = $self->_proxy->call($method, $self->apikey, @args);
43  
44 if ( $api_response->faultstring() ) {
45 $self->err($api_response->faultcode());
46 $self->errstr($api_response->faultstring());
47 croak 'Error: ' . $self->err . ' ' . $self->errstr;
48 }
49  
50 return $self->date_to_datetime
51 ? $self->_date_to_datetime($api_response->result())
52 : $api_response->result();
53 }
54  
55  
56 sub cast_value {
57 my ( $self, $type, $value ) = @_;
58  
59 return XMLRPC::Data->type($type)->value($value);
60 }
61  
62 1;
63  
64 __END__