NAME
WebService::HealthGraph - A thin wrapper around the Runkeeper (Health Graph) API
VERSION
version 0.000002
SYNOPSIS
my $graph = WebService::HealthGraph->new(
debug => 1,
token => 'foo',
);
my $user = $graph->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 = $graph->get($uri, { feed => 1 });
p $feed->content;
DESCRIPTION
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.
CONSTRUCTOR ARGUMENTS
base_url
The URL of the API. Defaults to https://api.runkeeper.com. This is settable in case you'd need this for mocking.
debug( $bool )
Turns on debugging via LWP::ConsoleLogger. Off by default.
token
OAuth token. Optional, but you'll need to to get any URLs.
ua
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.
url_map
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.
user
The content of the user
endpoint.
user_id
The id of the user as provided by the user
endpoint.
METHODS
get( $url, $optional_args )
This module will try to do the right thing with the minimum amount of information:
my $weight_response = $graph->get( 'weight', { feed => 1 } );
if ( $weight_response->success ) {
...
}
Optionally, you can provide your own Accept (or other) headers:
my $record_response = $graph->get(
'records',
{
headers =>
{ Accept => 'application/vnd.com.runkeeper.Records+json' }
);
Returns a WebService::HealthGraph::Response object.
CAVEATS
Most response content will contain a HashRef
, but the records
endpoint returns a response with an ArrayRef
in the content.
AUTHOR
Olaf Alders <olaf@wundercounter.com>
COPYRIGHT AND LICENSE
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.