API-Assembla

 view release on metacpan or  search on metacpan

lib/API/Assembla.pm  view on Meta::CPAN



sub get_tickets {
    my ($self, $id) = @_;

    my $req = $self->make_req('/spaces/'.$id.'/tickets');
    my $resp = $self->_client->request($req);

    # print STDERR $resp->decoded_content;

    my $xp = XML::XPath->new(xml => $resp->decoded_content);

    my $tickets = $xp->find('/tickets/ticket');

    my %objects = ();
    foreach my $ticket ($tickets->get_nodelist) {

        my $id = $ticket->findvalue('id').'';

        $objects{$id} = API::Assembla::Ticket->new(
            id => $id,
            created_on => DateTime::Format::ISO8601->parse_datetime($ticket->findvalue('created-on').''),
            description => $ticket->findvalue('description').'',
            number => $ticket->findvalue('number').'',
            priority => $ticket->findvalue('priority').'',
            status_name => $ticket->findvalue('status-name').'',
            summary => $ticket->findvalue('summary').''
        );
    }

    return \%objects;
}

sub make_req {
    my ($self, $path) = @_;

    my $req = HTTP::Request->new(GET => $self->url.$path);
    $req->header(Accept => 'application/xml');
    $req->authorization_basic($self->username, $self->password);
    return $req;
}

__PACKAGE__->meta->make_immutable;

1;



=pod

=head1 NAME

API::Assembla - Access to Assembla API via Perl.

=head1 VERSION

version 0.03

=head1 UNDER CONSTRUCTION

API::Assembla is not feature-complete.  It's a starting point.  The Assembla
API has LOTS of stuff that this module does not yet contain.  These features
will be added as needed by the author or as gifted by thoughtful folks who
write patches! ;)

=head1 SYNOPSIS

    use API::Assembla;

    my $api = API::Asembla->new(
        username => $username,
        password => $password
    );

    my $href_of_spaces = $api->get_spaces;
    # Got an href of API::Assembla::Space objects keyed by space id
    my $space = $api->get_space($space_id);
    # Got an API::Assembla::Space object

    my $href_of_tickets = $api->get_tickets;
    # Got an href of API::Assembla::Space objects keyed by ticket id
    my $ticket = $api->get_ticket($space_id, $ticket_number);
    # Got an API::Assembla::Ticket object

=head1 DESCRIPTION

API::Assembla is a Perl interface to L<Assembla|http://www.assembla.com/>, a
ticketing, code hosting collaboration tool.

=head1 ATTRIBUTES

=head2 password

The password to use when logging in.

=head2 url

The URL to use when working with the api.  Defaults to

  http://www.assembla.com

=head2 username

The username to use when logging in.

=head1 METHODS

=head2 get_space ($id)

Get Space information.

=head2 get_spaces

Get Space information.  Returns a hashref of L<API::Assembla::Space> objects
keyed by the space's name.

=head2 get_tickets ($space_id, $number)

Get Tickets for a space information.

=head2 get_tickets ($space_id)

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.011 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )