diff --git a/src/WakaTime.php b/src/WakaTime.php index c4a7091..64db045 100644 --- a/src/WakaTime.php +++ b/src/WakaTime.php @@ -111,10 +111,31 @@ public function stats($range, $project = null) public function heartbeats($date, $show = null) { if ($show !== null) { - $show = "?show={$show}"; + $show = "&show={$show}"; } return $this->makeRequest("users/current/heartbeats?date={$date}" . $show); } + /** + * See https://wakatime.com/developers#durations for details. + * + * @param [type] $date + * @param string $project + * @param string $branches + * @return [type] + */ + public function durations($date, $project = null, $branches = NULL) + { + if ($project !== null) { + $project = "&project={$project}"; + } + + if ($branches !== null) { + $branches = "&branches={$branches}"; + } + + return $this->makeRequest("users/current/durations?date={$date}" . $project . $branches); + } + } diff --git a/tests/WakaTimeTest.php b/tests/WakaTimeTest.php index e7c8a77..c4c3175 100644 --- a/tests/WakaTimeTest.php +++ b/tests/WakaTimeTest.php @@ -223,8 +223,25 @@ public function it_returns_summaries_for_period_and_project() public function it_returns_heartbeats_for_given_day() { $date = '01/22/2016'; + $show = 'time,entity,type,project,language,branch,is_write,is_debugging'; - $response = $this->wakatime->heartbeats($date); + $response = $this->wakatime->heartbeats($date, $show); + + $this->assertInternalType('array', $response); + } + + /** + * Durations + */ + + /** @test */ + public function it_returns_durations_for_given_day() + { + $date = '01/22/2016'; + $project = $this->project; + $branches = null; + + $response = $this->wakatime->durations($date, $project, $branches); $this->assertInternalType('array', $response); }