File Coverage

blib/lib/Net/OpenSocial/Client/HTTPRequestBuilder/ST.pm
Criterion Covered Total %
statement 15 32 46.8
branch 0 2 0.0
condition 0 5 0.0
subroutine 5 6 83.3
pod 1 1 100.0
total 21 46 45.6


line stmt bran cond sub pod time code
1             package Net::OpenSocial::Client::HTTPRequestBuilder::ST;
2              
3 1     1   5 use Any::Moose;
  1         2  
  1         7  
4             with 'Net::OpenSocial::Client::HTTPRequestBuilder';
5              
6 1     1   561 use HTTP::Request;
  1         3  
  1         10  
7 1     1   24 use URI;
  1         2  
  1         8  
8 1     1   36 use bytes();
  1         8  
  1         285  
9              
10             has 'st' => (
11             is => 'ro',
12             isa => 'Str',
13             required => 1,
14             );
15              
16             sub build_request {
17 0     0 1   my ( $self, %args ) = @_;
18              
19 0           my $method = $args{method};
20 0           my $url = $args{url};
21 0           my $params = $args{parmas};
22 0           my $content_type = $args{content_type};
23 0           my $content = $args{content};
24 0           my $container = $args{container};
25              
26 0           my $uri = URI->new($url);
27 0   0       $params ||= {};
28 0           $params->{st} = $self->st;
29 0           $uri->query_form(%$params);
30 0           my $http_req = HTTP::Request->new( $method => $uri->as_string );
31 0 0 0       if ( $method eq 'POST' || $method eq 'PUT' ) {
32 0           $http_req->header( 'Content-Type' => $content_type );
33 0           $http_req->header( 'Content-Length' => bytes::length($content) );
34 0           $http_req->content($content);
35             }
36 0           return $http_req;
37             }
38              
39 1     1   6 no Any::Moose;
  1         2  
  1         43  
40             __PACKAGE__->meta->make_immutable;
41             1;
42              
43             =head1 NAME
44              
45             Net::OpenSocial::Client::HTTPRequestBuilder::ST - Security token request builder
46              
47             =head1 SYNOPSIS
48              
49             my $builder = Net::OpenSocial::Client::HTTPRequestBuilder::ST->new(
50             st => q{securitytokenvalue},
51             );
52              
53             my $http_req = $builder->build_request(...);
54              
55             =head1 DESCRIPTION
56              
57             HTTP Request builder with security-token authentication
58              
59             =head1 METHODS
60              
61             =head2 build_request
62              
63             =head1 AUTHOR
64              
65             Lyo Kato, Elyo.kato@gmail.comE
66              
67             =head1 COPYRIGHT AND LICENSE
68              
69             Copyright (C) 2009 by Lyo Kato
70              
71             This library is free software; you can redistribute it and/or modify
72             it under the same terms as Perl itself, either Perl version 5.8.8 or,
73             at your option, any later version of Perl 5 you may have available.
74              
75             =cut
76