WWW::FreshMeat::API::Pub - FreshMeats published / public (take your pick!) API methods


WWW-FreshMeat-API documentation Contained in the WWW-FreshMeat-API distribution.

Index


Code Index:

NAME

Top

WWW::FreshMeat::API::Pub - FreshMeats published / public (take your pick!) API methods

VERSION

Top

Version 0.01

SYNOPSIS

Top

    use Moose;

    with 'WWW::FreshMeat::API::Pub';




DESCRIPTION

Top

This is a Moose role which builds the public/published FreshMeat API from WWW::FreshMeat::API::Pub::V1_03 metadata.

EXPORT

Top

None.

METHODS

Top

See FreshMeat API docs. Methods use same names. Where docs say returns "Array" then a ArrayRef is return. Where docs says returns "Struct" then HashRef is returned. So if docs say "Array of structs" then ArrayRef of HashRefs is returned by said method.

fetch_available_licenses

fetch_available_release_foci

fetch_branch_list

fetch_project_list

fetch_release

publish_release

withdraw_release

login

logout

To satisfy pod-coverage!

get_api_info

BUILD

AUTHOR

Top

Barry Walsh, <draegtun at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-www-freshmeat-api at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-FreshMeat-API. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc WWW::FreshMeat::API::Pub




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-FreshMeat-API

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/WWW-FreshMeat-API

* CPAN Ratings

http://cpanratings.perl.org/d/WWW-FreshMeat-API

* Search CPAN

http://search.cpan.org/dist/WWW-FreshMeat-API/

ACKNOWLEDGEMENTS

Top

SEE ALSO

Top

Freshmeat API FAQ

http://freshmeat.net/faq/view/49/

Freshmeat XML-RPC API announcement

http://freshmeat.net/articles/view/1048/

Other WWW::FreshMeat::API modules

WWW::FreshMeat::API

COPYRIGHT & LICENSE

Top


WWW-FreshMeat-API documentation Contained in the WWW-FreshMeat-API distribution.

package WWW::FreshMeat::API::Pub;
use Moose::Role;
use WWW::FreshMeat::API::Pub::V1_03 qw/get_api_info/;

our $VERSION = '0.01';

#requires 'sid';

sub BUILD {
    my $self = shift;
    my $api  = get_api_info();
    
    for my $name ( keys %{ $api } ) {
        
        # if mock then setup some dummy methods
        if ( $self->mock ) {
            $self->meta->add_method( $name => sub {
                my ( $self, %params ) = @_;
                return $api->{ $name }->{ returns };
            });
            next;
        }
         
        # else public methods... however next two require setting up session
        next  if $name eq 'login';
        next  if $name eq 'logout';
        
        # now all remaining public methods - v1.03
        if ( @{ $api->{ $name }->{ params } } ) {
            
            # build methods with params
            $self->meta->add_method( $name => sub {
                my ( $self, %params ) = @_;
                
                # add SID if it needs it (must be first in array)
                %params = ( SID => $self->session->{ SID }, %params )
                    if  $api->{ $name }->{ params }->[0] eq 'SID';
                    
                $self->agent->call( $name, \%params );
            });
        }
        
        else {
            # build method with no params
            $self->meta->add_method( $name => sub {
                my $self = shift;
                $self->agent->call( $name );
            });
        }
    }   
}

# session methods
sub login {
    my ( $self, %params ) = @_;
    $self->session( $self->agent->call( 'login', \%params ) );
}

sub logout {
    my $self = shift;
    $self->agent->call( 'logout', { SID => $self->session->{ SID } } );
    $self->clear_session;
}

no Moose::Role;

1;


__END__