Skip to content

Commit

Permalink
Merge pull request #7 from rdeanar/master
Browse files Browse the repository at this point in the history
FIxed heartbeats "Missing date" error. Added implementation of "durations" method.
  • Loading branch information
Mario Bašić committed Aug 6, 2016
2 parents ddf1359 + 5d04f9a commit ed16572
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/WakaTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
19 changes: 18 additions & 1 deletion tests/WakaTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit ed16572

Please sign in to comment.