AnyEvent-WebService-Tracks

 view release on metacpan or  search on metacpan

lib/AnyEvent/WebService/Tracks.pm  view on Meta::CPAN

use AnyEvent::WebService::Tracks::Todo;

our $VERSION = '0.02';

sub new {
    my ( $class, %params ) = @_;

    return bless {
        url      => URI->new($params{url}),
        username => $params{username},
        password => $params{password},
    }, $class;
}

sub parse_datetime {
    my ( $self, $str ) = @_;

    return DateTime::Format::ISO8601->parse_datetime($str);
}

sub format_datetime {

lib/AnyEvent/WebService/Tracks.pm  view on Meta::CPAN


sub status_successful {
    my ( $self, $status ) = @_;

    return ($status >= 200 && $status < 300);
}

sub do_request {
    my ( $self, $http_method, $uri, $params, $method, $cb ) = @_;

    my ( $username, $password ) = @{$self}{qw/username password/};

    my $auth_token = encode_base64(join(':', $username, $password), '');
    $params->{'headers'} = {
        Authorization => "Basic $auth_token",
        Accept        => 'application/xml',
        Referer       => undef,
    };
    if($params->{'body'}) {
        $params->{'headers'}{'Content-Type'} = 'text/xml';
    }

    my $handle_result = sub {

lib/AnyEvent/WebService/Tracks.pm  view on Meta::CPAN


0.02

=head1 SYNOPSIS

  use AnyEvent::WebService::Tracks;

  my $tracks = AnyEvent::WebService::Tracks->new(
    url      => 'http://my.tracks.instance/',
    username => 'user',
    password => 'pa55w0rd',
  );

  $tracks->projects(sub {
    my ( $projects ) = @_;

    say foreach @$projects;
  });

  AnyEvent->condvar->recv;

lib/AnyEvent/WebService/Tracks.pm  view on Meta::CPAN

against the Tracks version you'll be using; I developed this module against Tracks
1.7.2, so I can't really guarantee it'll work with any other version.  If you find
a bug when running against another version, please let me know and I'll try to fix
it as long as it doesn't break other versions.

=head1 METHODS

=head2 AnyEvent::WebService::Tracks->new(%params)

Creates a new AnyEvent::WebService::Tracks object.  C<%params> must contain
the url, username, and password parameters.

=head2 $tracks->projects($callback)

Retrieves the list of projects in the given Tracks installation and provides
them to the given callback.  If the call fails, then a falsy value and the
error message are provided to the callback.

=head2 $tracks->create_project($name, $callback)
=head2 $tracks->create_project(%params, $callback)

t/lib/Test/AnyEvent/WebService/Tracks.pm  view on Meta::CPAN

    *{$pkg . '::get_tracks'}          = \&get_tracks;
    *{$pkg . '::clear_tracks'}        = \&clear_tracks;
    *{$pkg . '::run_tests_in_loop'}   = \&run_tests_in_loop;

    if($ENV{'TRACKS_URL'}  &&
           $ENV{'TRACKS_USER'} &&
           $ENV{'TRACKS_PASS'}) {
        $tracks = AnyEvent::WebService::Tracks->new(
            url      => $ENV{'TRACKS_URL'},
            username => $ENV{'TRACKS_USER'},
            password => $ENV{'TRACKS_PASS'},
        );

        Test::More::plan @args if @args;
    } else {
        Test::More::plan skip_all => 'Please define TRACKS_URL, TRACKS_USER, and TRACKS_PASS and point them to an *empty* Tracks installation.  THESE TESTS WILL ERASE ALL YOUR DATA!';
    }
}

1;



( run in 1.048 second using v1.01-cache-2.11-cpan-49f99fa48dc )