forked from elicwhite/fitbitphp
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathActivityTimeSeriesGateway.php
More file actions
55 lines (47 loc) · 1.43 KB
/
ActivityTimeSeriesGateway.php
File metadata and controls
55 lines (47 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Fitbit;
class ActivityTimeSeriesGateway extends TimeSeriesEndpointGateway {
/**
* base fragment for this resources uri
*
* @var sting
*/
protected static $format = 'activities/%s/date';
/**
* convert to trcker only fragment
*
* @param string $fragment
* @return string
*/
protected function trackerOnlyFragment($fragment)
{
return str_replace('activities', 'activities/tracker', $fragment);
}
/**
* extended get to all for tracker only resource calls
*
* @throws Exception
* @param string $fragment
* @param bool $tracker
* @param \DateTime|string $baseDate
* @param string $period
* @param \DateTime|string $endDate
* @return mixed SimpleXMLElement or the value encoded in json as an object
*/
public function get($fragment, $tracker = false, $baseDate = null, $period = null, $endDate = null)
{
$fragment = ($tracker) ? $this->trackerOnlyFragment($fragment) : $fragment;
return parent::get($fragment, $baseDate, $period, $endDate);
}
/**
* extended call, to ensure methods without tracker
* have tracker set to false
*
* {@inheritdoc}
*/
public function __call($method, $parameters)
{
if (in_array($method, array('getCaloriesBMR'))) $parameters[0] = false;
return parent::__call($method, $parameters);
}
}