API/Request.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 46 CC 3 SCAR 17.5
CC
3
Cov
0%
new
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.8
1 package Switchvox::API::Request;
2  
3 use strict;
4 use warnings;
5 use HTTP::Request;
6 use XML::Simple;
7  
8 use base 'HTTP::Request';
9  
10 our $VERSION = '1.02';
11  
12 sub new
13 {
14 my ($class,%in) = @_;
15 warn "Missing hostname in call to constructor" unless defined $in{hostname};
16 warn "Missing method in call to constructor" unless defined $in{method};
17  
18 #- Create new object
19 my $self = new HTTP::Request;
20  
21 #- Add my variables to object
22 $self->{_sv_hostname} = $in{hostname};
23 $self->{_sv_method} = $in{method};
24 $self->{_sv_parameters} = $in{parameters} || [];
25 bless $self, $class;
26  
27 $self->method('POST');
28 $self->uri('https://' . $self->{_sv_hostname} . '/xml');
29 $self->content_type('application/xml');
30  
31 #- Create the XML from a data structure
32 my $xml_data = {
33 request => {
34 method => $self->{_sv_method},
35 parameters => $self->{_sv_parameters},
36 }
37 };
38 my $xml = XML::Simple::XMLout($xml_data,KeyAttr => [], ContentKey => '_content', KeepRoot => 1);
39 $self->content($xml);
40 return $self;
41 }
42  
43 1; #- Switchvox Rules!
44  
45 __END__