From d66a559824e567e3f4f946a8616d99cdb59a11a9 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Thu, 3 Jun 2010 09:25:21 +0200 Subject: update POD --- lib/MooseX/Net/API.pm | 106 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 24 deletions(-) (limited to 'lib/MooseX/Net') diff --git a/lib/MooseX/Net/API.pm b/lib/MooseX/Net/API.pm index ff0494d..b6f0f28 100644 --- a/lib/MooseX/Net/API.pm +++ b/lib/MooseX/Net/API.pm @@ -110,10 +110,53 @@ MooseX::Net::API - Easily create client for net API =head1 DESCRIPTION MooseX::Net::API is a module to help to easily create a client for a web API. + This module is heavily inspired by what L does. B +The following roles are added to your class: + +=over 4 + +=item B + +=item B + +=item B + +=item B + +=item B + +=back + +The following attributes are added to your class: + +=over 4 + +=item B + +=item B + +=item B + +=item B + +=item B + +=item B + +=back + +The following methods are added to your class: + +=over 4 + +=item B + +=back + =head2 METHODS =over 4 @@ -130,17 +173,37 @@ B =item B -The base url for all the API's calls. This will add an B attribut to your class. Can be set at the object creation or before calling an API method. If no api_base_url is defined, the method will die. +The base url for all the API's calls. This will set the B attribut in your class. Can be set at the object creation or before calling an API method. + +=item B + +The format for the API's calls. This will set the B attribut to your class. Value can be: + +=over 2 + +=item B -=item B (required, must be either xml, json or yaml) +=item B -The format for the API's calls. This will add an B attribut to your class. +=item B -=item B (required, must be 'append' or 'content-type') +=back + +=item B + +How the format is handled. B will add B<.$format> to the query, B will set the content-type information to the header of the request. Should be one the following value: -How the format is handled. B will add B<.json> to the query, B will add the content-type information to the header of the request. +=over 2 + +=item B -=item B (optional, by default it's a LWP::UserAgent object) +=item B + +=back + +=item B + +A L object. useragent => sub { my $ua = LWP::UserAgent->new; @@ -148,11 +211,11 @@ How the format is handled. B will add B<.json> to the query, B (optional) +=item B This is a boolean to tell if we must authenticate to use this API. -=item B (optional) +=item B The default authentication method only set an authorization header using the Basic Authentication Scheme. You can write your own authentication method: @@ -165,7 +228,6 @@ The default authentication method only set an authorization header using the Bas sub my_auth_method { my ($self, $req) = @_; #$req is an HTTP::Request object ... - return $req; } =back @@ -174,15 +236,15 @@ The default authentication method only set an authorization header using the Bas =over 2 -=item B [string] +=item B -description of the method (this is a documentation) +A string to describe the method (this is a documentation) -=item B [string] +=item B HTTP method (GET, POST, PUT, DELETE) -=item B [string] +=item B path of the query. @@ -190,7 +252,7 @@ If you defined your path and params like this net_api_method user_comments => ( ... - path => '/user/$user/list/$date/', + path => '/user/:user/list/:date', params => [qw/user date foo bar/], ... ); @@ -199,23 +261,19 @@ and you call $obj->user_comments(user => 'franck', date => 'today', foo => 1, bar => 2); -the url generetad will look like +the url generated will look like /user/franck/list/today/?foo=1&bar=2 -=item B [arrayref] - -list of params. - -=item B [arrayref] +=item B -list of required params. +Arrayref of params. -=item B (optional) +=item B -should we do an authenticated call +Arrayref of required params. -=item B (optional) +=item B When you do a post, the content may have to be sent as arguments in the url, and not as content in the header. -- cgit 1.4.1