File Coverage

blib/lib/WebService/30Boxes/API/Request.pm
Criterion Covered Total %
statement 9 26 34.6
branch 0 6 0.0
condition n/a
subroutine 3 5 60.0
pod 1 2 50.0
total 13 39 33.3


line stmt bran cond sub pod time code
1             package WebService::30Boxes::API::Request;
2              
3 1     1   9 use strict;
  1         2  
  1         29  
4 1     1   865 use HTTP::Request;
  1         40032  
  1         35  
5 1     1   9 use URI;
  1         2  
  1         311  
6              
7             our $VERSION = '1.05';
8             our @ISA = qw/HTTP::Request/;
9              
10             sub new {
11 0     0 1   my ($class, $meth, $args) = @_;
12              
13 0           my $self = new HTTP::Request;
14 0 0         $self->{'_api_meth'} = $meth if($meth);
15 0 0         $self->{'_api_args'} = $args if($args);
16              
17 0           bless $self, $class;
18              
19 0           $self->method('POST');
20 0           $self->uri('http://30boxes.com/api/api.php');
21              
22 0           return $self;
23             }
24              
25             sub encode_args {
26 0     0 0   my $self = shift;
27              
28 0           my $url = URI->new('http:');
29 0           $url->query_form(
30             method => $self->{'_api_meth'},
31 0           %{$self->{'_api_args'}});
32 0           my $content = $url->query;
33              
34 0           $self->header('Content-Type' => 'application/x-www-form-urlencoded');
35 0 0         if (defined($content)) {
36 0           $self->header('Content-Length' => length($content));
37 0           $self->content($content);
38             }
39             }
40              
41             1;