WebService::Toggl - Wrapper for the toggl.com task logging API
use WebService::Toggl;
my $toggl = WebService::Toggl->new({api_key => $ENV{API_KEY}});
my $me = $toggl->me();
say "Me: " . $me->fullname . " <" . $me->email . ">:";
say "My Workspaces:";
for my $ws ($me->workspaces->all) {
say " " . $ws->name . " (" . $ws->id . ")";
say " Projects:";
say " " . $_->name . " (" . $_->id . ") " for ($ws->projects->all);
}
NB: This is a new module, and the API is still under development. While I'm pretty happy with the current interface, expect the internals to be heavily refactored before v1.0. This version currently only supports read access to the API, but I plan to add write access in the near future.
WebService::Toggl is a perl interface to the
Toggl API, as described at
https://github.com/toggl/toggl_api_docs. When a new
WebService::Toggl
object is created, it is associated with a
particulars user's credentials via their API token. The API token can
be found at the bottom of your 'My Profile' on Toggl. Any new objects
created by the WebService::Toggl
object will inherit its credentials.
All Webservice::Toggl::API::
and WebService::Toggl::Report::
objects are created lazily. If you ask for a particular
::API::Workspace
object by id, no GET request against the Toggl API
will be issued until you request an attribute that has not yet been set. E.g.
my $workspace = $toggl->workspace(1234);
say $workspace->id; # prints 1234, no GET yet issued
say $workspace->name; # name is not yet set, will issue GET request
Each API::
and Report::
object stores the raw response received
from Toggl in an attribute called raw
. If you want to force the
object to fill itself in with data from the API, calling
$object->raw()
will do so.
Each API::
class has a corresponding class that represents a set of
the objects. These set objects store the raw response query and will
return a list of the objects it comprises via the ->all()
method.
You can make other requests against the Toggle API via the
api_{get,post,put,delete}()
methods provided by
WebService::Toggl::Role::Base. For instance, if you had a
WebService::Toggl::API::Tag object that you wanted to delete, you
could write:
$tag->api_delete( $tag->my_url );
Returns the WebService::Toggl::API::Me object representing the authorized user.
Returns the WebService::Toggl::API::Workspace object with the given id.
Returns the WebService::Toggl::API::WorkspaceUser object with the given id.
Returns the WebService::Toggl::API::Client object with the given id.
Returns the WebService::Toggl::API::Project object with the given id.
Returns the WebService::Toggl::API::ProjectUser object with the given id.
Returns the WebService::Toggl::API::Tag object with the given id.
Returns the WebService::Toggl::API::Task object with the given id.
Returns the WebService::Toggl::API::TimeEntry object with the given id.
Returns the WebService::Toggl::API::User object with the given id.
Returns the WebService::Toggl::Report::Details object with the given arguments.
Returns the WebService::Toggl::Report::Summary object with the given arguments.
Returns the WebService::Toggl::Report::Weekly object with the given arguments.
Copyright (C) Fitz Elliott.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Fitz Elliott felliott@fiskur.org