| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WebService::BuzzurlAPI::Request; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | =pod | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =head1 NAME | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | WebService::BuzzurlAPI::Request - Buzzurl WebService API request package | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 VERSION | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | 0.02 | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | Buzzurl WebService API request package | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | =head1 METHOD | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | =cut | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 3 |  |  | 3 |  | 19 | use strict; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 117 |  | 
| 22 | 3 |  |  | 3 |  | 17 | use base qw(Class::Accessor); | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 270 |  | 
| 23 | 3 |  |  | 3 |  | 18 | use Carp; | 
|  | 3 |  |  |  |  | 5 |  | 
|  | 3 |  |  |  |  | 279 |  | 
| 24 | 3 |  |  | 3 |  | 18 | use HTTP::Request; | 
|  | 3 |  |  |  |  | 8 |  | 
|  | 3 |  |  |  |  | 40 |  | 
| 25 | 3 |  |  | 3 |  | 77 | use Readonly; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 165 |  | 
| 26 | 3 |  |  | 3 |  | 1865 | use WebService::BuzzurlAPI::Util qw(drop_utf8flag urlencode); | 
|  | 3 |  |  |  |  | 9 |  | 
|  | 3 |  |  |  |  | 399 |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | __PACKAGE__->mk_ro_accessors(qw(buzz uri)); | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | our $VERSION = 0.02; | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | Readonly my @OVERRIDE_METHOD => qw( | 
| 33 |  |  |  |  |  |  | filter_param | 
| 34 |  |  |  |  |  |  | make_request_url | 
| 35 |  |  |  |  |  |  | make_request_content | 
| 36 |  |  |  |  |  |  | is_post_request | 
| 37 |  |  |  |  |  |  | ); | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub import { | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 0 |  |  | 0 |  | 0 | my $class = shift; | 
| 42 |  |  |  |  |  |  | { | 
| 43 | 3 |  |  | 3 |  | 31 | no strict "refs"; | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 829 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 44 | 0 |  |  | 0 |  | 0 | map { *{$_} = sub { croak("\"$_\" abstract method!") } } @OVERRIDE_METHOD; | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | =pod | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | =head2 new | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | Create instance | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | =cut | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | sub new { | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 3 |  |  | 3 | 1 | 38421 | my($class, %args) = @_; | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 3 | 50 |  |  |  | 34 | if(ref($args{buzz}) ne "WebService::BuzzurlAPI"){ | 
| 61 | 0 |  |  |  |  | 0 | croak("buzz is not \"WebService::BuzzurlAPI\" object"); | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 | 3 |  | 33 |  |  | 25 | return bless \%args, $class || ref $class; | 
| 65 |  |  |  |  |  |  | } | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | =head2 request | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | Access API. return HTTP::Response instance | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | =cut | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | sub request { | 
| 74 |  |  |  |  |  |  |  | 
| 75 | 3 |  |  | 3 | 1 | 14 | my($self, %param) = @_; | 
| 76 |  |  |  |  |  |  |  | 
| 77 | 3 |  |  |  |  | 21 | $self->filter_param(\%param); | 
| 78 | 3 |  |  |  |  | 17 | $self->make_request_url(\%param); | 
| 79 |  |  |  |  |  |  |  | 
| 80 | 3 | 50 |  |  |  | 495 | my @option = ($self->is_post_request) ? | 
| 81 |  |  |  |  |  |  | ( "POST", $self->uri->as_string, [ "Content-Type", "application/x-www-form-urlencoded" ], $self->make_request_content(\%param) ) : | 
| 82 |  |  |  |  |  |  | ( "GET", $self->uri->as_string ); | 
| 83 | 3 |  |  |  |  | 83 | return $self->buzz->ua->request(HTTP::Request->new(@option)); | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | 1; | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | __END__ |