Skip to content

Missing issue timeline api #653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ v3 APIs:
* [Comments](issue/comments.md)
* [Labels](issue/labels.md)
* [Milestones](issue/milestones.md)
* [Timeline](issue/timeline.md)
* [Meta](meta.md)
* Miscellaneous
* [Emojis](miscellaneous/emojis.md)
Expand Down
17 changes: 17 additions & 0 deletions doc/issue/timeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Issues / Timeline API
[Back to the "Issues API"](../issues.md) | [Back to the navigation](../README.md)

Wraps [GitHub Issue Timeline API](http://developer.github.com/v3/issues/timeline/).

This api is currently only available to developers in Early Access. To access the API during the Early Access period,
you must provide a custom media type in the Accept header.

```php
$client->api('ìssue')->timeline()->configure();
```

### List events for an issue

```php
$events = $client->api('issue')->timeline()->all('KnpLabs', 'php-github-api', 123);
```
13 changes: 13 additions & 0 deletions lib/Github/Api/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Github\Api\Issue\Events;
use Github\Api\Issue\Labels;
use Github\Api\Issue\Milestones;
use Github\Api\Issue\Timeline;
use Github\Exception\MissingArgumentException;

/**
Expand Down Expand Up @@ -245,4 +246,16 @@ public function assignees()
{
return new Assignees($this->client);
}

/**
* List all events.
*
* @link https://developer.github.com/v3/issues/timeline/
*
* @return Timeline
*/
public function timeline()
{
return new Timeline($this->client);
}
}
33 changes: 33 additions & 0 deletions lib/Github/Api/Issue/Timeline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Github\Api\Issue;

use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;

class Timeline extends AbstractApi
{
use AcceptHeaderTrait;

public function configure()
{
$this->acceptHeaderValue = 'application/vnd.github.mockingbird-preview';

return $this;
}

/**
* Get all events for a specific issue.
*
* @link https://developer.github.com/v3/issues/timeline/#list-events-for-an-issue
* @param string $username
* @param string $repository
* @param int $issue
*
* @return array
*/
public function all($username, $repository, $issue)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/timeline');
}
}
36 changes: 36 additions & 0 deletions test/Github/Tests/Api/Issue/TimelineTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Github\Tests\Api\Issue;

use Github\Tests\Api\TestCase;

class TimelineTest extends TestCase
{
/**
* @test
*/
public function shouldGetIssueEvents()
{
$expectedValue = array(
'event1',
'event2',
);

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/repos/KnpLabs/php-github-api/issues/123/timeline', array())
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123));
}


/**
* @return string
*/
protected function getApiClass()
{
return \Github\Api\Issue\Timeline::class;
}
}
10 changes: 10 additions & 0 deletions test/Github/Tests/Api/IssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ public function shouldGetMilestonesApiObject()
$this->assertInstanceOf(\Github\Api\Issue\Milestones::class, $api->milestones());
}

/**
* @test
*/
public function shouldGetTimelineApiObject()
{
$api = $this->getApiMock();

$this->assertInstanceOf(\Github\Api\Issue\Timeline::class, $api->timeline());
}

/**
* @test
*/
Expand Down