Skip to content

Commit c9c742f

Browse files
antoniotajueloacrobat
authored andcommitted
Added support for getting star creation timestamps in activity/starring endpoint (KnpLabs#729)
* Added support for getting star creation timestamps https://developer.github.com/v3/activity/starring/#list-stargazers * Fixed style * Updated docs for including starred creation date
1 parent 3763f88 commit c9c742f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

doc/activity.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ $activity = $client->api('current_user')->starring()->all();
3131
```
3232
Returns an array of starred repos.
3333

34+
### Get repos that a authenticated user has starred with creation date
35+
36+
Support for getting the star creation timestamp in the response, using the custom `Accept: application/vnd.github.v3.star+json` header.
37+
38+
```php
39+
$activity = $client->api('current_user')->starring()->configure('star')->all();
40+
```
41+
Returns an array of starred repos, including the `created_at` attribute for every star.
42+
3443
### Check if authenticated user has starred a specific repo
3544

3645
```php

lib/Github/Api/CurrentUser/Starring.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Github\Api\CurrentUser;
44

55
use Github\Api\AbstractApi;
6+
use Github\Api\AcceptHeaderTrait;
67

78
/**
89
* @link https://developer.github.com/v3/activity/starring/
@@ -11,6 +12,26 @@
1112
*/
1213
class Starring extends AbstractApi
1314
{
15+
use AcceptHeaderTrait;
16+
17+
/**
18+
* Configure the body type.
19+
*
20+
* @see https://developer.github.com/v3/activity/starring/#list-stargazers
21+
*
22+
* @param string $bodyType
23+
*
24+
* @return self
25+
*/
26+
public function configure($bodyType = null)
27+
{
28+
if ('star' === $bodyType) {
29+
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->client->getApiVersion());
30+
}
31+
32+
return $this;
33+
}
34+
1435
/**
1536
* List repositories starred by the authenticated user.
1637
*

0 commit comments

Comments
 (0)