Skip to content

Commit

Permalink
Durations api implemented with test
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeanar committed Aug 4, 2016
1 parent 2768309 commit 5d04f9a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/WakaTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,25 @@ public function heartbeats($date, $show = null)
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);
}

}
16 changes: 16 additions & 0 deletions tests/WakaTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,20 @@ public function it_returns_heartbeats_for_given_day()

$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);
}
}

0 comments on commit 5d04f9a

Please sign in to comment.