Skip to content

Conversation

@jsamos
Copy link

@jsamos jsamos commented Dec 17, 2013

Hi, I created a set of Time Series Gateways for your repo, take a look and let me know if u wanna merge.

@popthestack
Copy link
Owner

Thanks for submitting this. I'll take a closer look at it this weekend.

@popthestack
Copy link
Owner

I've been thinking for a while that the time series functionality would be better suited as part of the existing gateways instead of in separate gateways. For example, instead of ActivityTimeSeriesGateway or the existing TimeGateway, ActivityGateway itself should implement the methods needed for the series data.

Something like this:

$activities = $factory->getActivityGateway();
$activities->getTimeSeries('distance', 'today', '7d');

public function getTimeSeries($type, $base_date = null, $end_date = null)
{
    $url = '/activities/log/' . $type;
    return $this->makeTimeSeriesApiRequest($url, $base_date, $end_date);
}

What do you think? EndpointGateway would end up with a bit more functionality than every gateway needs, but the benefit would be fewer gateways.

I'd also get rid of the magic methods, favoring explicitly defined methods like this instead:

$activities->getMinutesVeryActive();

public function getMinutesVeryActive($base_date = null, $end_date = null)
{
    return $this->getTimeSeries('minutesVeryActive', $base_date, $end_date);
}
public function getTrackerCalories($base_date = null, $end_date = null)
{
    return $this->getTimeSeries('tracker/calories', $base_date, $end_date);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants