WebService::HealthGraph - A thin wrapper around the Runkeeper (Health Graph) API
version 0.000004
my $runkeeper = WebService::HealthGraph->new(
debug => 1,
token => 'foo',
);
my $user = $runkeeper->user;
use Data::Printer;
p $user->content;
# Fetch a weight feed
use DateTime ();
use URI::FromHash qw( uri );
my $cutoff = DateTime->now->subtract( days => 7 );
my $uri = uri(
path => '/weight',
query => { noEarlierThan => $cutoff->ymd },
);
my $feed = $runkeeper->get($uri, { feed => 1 });
p $feed->content;
BETA BETA BETA. The interface is subject to change.
This is a very thin wrapper around the Runkeeper (Health Graph) API. At this point it assumes that you already have an OAuth token to connect with. You can use Mojolicious::Plugin::Web::Auth::Site::Runkeeper to create a token. If that doesn't suit you, patches to add OAuth token retrieval to this module will be happily accepted.
Boolean. If enabled, response objects will continue to fetch new result pages as the iterator requires them. Defaults to true.
The URL of the API. Defaults to https://api.runkeeper.com. This is settable in case you'd need this for mocking.
Turns on debugging via LWP::ConsoleLogger. Off by default.
OAuth token. Optional, but you'll need to to get any URLs.
A user agent object of the LWP::UserAgent family. If you provide your own, be sure you set the correct default headers required for authentication.
Returns a map of keys to URLs, as provided by the user
endpoint. Runkeeper
wants you to use these URLs rather than constructing your own.
Gives you the corresponding url (in the form of an URI object) for any key
which exists in url_map
. You can optionally pass a HashRef of query params
to this method.
my $team_uri = $runkeeper->uri_for( 'team', { pageSize => 10 } );
my $friends = $runkeeper->get(
$runkeeper->uri_for( 'team', { pageSize => 10 } ),
{ feed => 1 }
);
Convenience method which points to url_for
. Will be removed in a later
release.
The WebService::HealthGraph::Response object for the user
endpoint.
The id of the user as provided by the user
endpoint.
This module will try to do the right thing with the minimum amount of information:
my $weight_response = $runkeeper->get( 'weight', { feed => 1 } );
if ( $weight_response->success ) {
...
}
Optionally, you can provide your own Accept (or other) headers:
my $record_response = $runkeeper->get(
'records',
{
headers =>
{ Accept => 'application/vnd.com.runkeeper.Records+json' }
);
Returns a WebService::HealthGraph::Response object.
Most response content will contain a HashRef
, but the records
endpoint
returns a response with an ArrayRef
in the content.
Olaf Alders olaf@wundercounter.com
This software is copyright (c) 2016 by Olaf Alders.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.