Skip to content

Chainable/fluent configure methods #544

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 2 commits into from
Mar 26, 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
4 changes: 4 additions & 0 deletions lib/Github/Api/GitData/Blobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ class Blobs extends AbstractApi
* Configure the Accept header depending on the blob type.
*
* @param string|null $bodyType
*
* @return self
*/
public function configure($bodyType = null)
{
if ('raw' === $bodyType) {
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.raw', $this->client->getApiVersion());
}

return $this;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/Github/Api/Issue/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Comments extends AbstractApi
*
* @link https://developer.github.com/v3/issues/comments/#custom-media-types
* @param string|null $bodyType
*
* @return self
*/
public function configure($bodyType = null)
{
Expand All @@ -28,6 +30,8 @@ public function configure($bodyType = null)
}

$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->client->getApiVersion(), $bodyType);

return $this;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/Github/Api/Project/AbstractProjectApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ abstract class AbstractProjectApi extends AbstractApi
* Configure the accept header for Early Access to the projects api
*
* @see https://developer.github.com/v3/repos/projects/#projects
*
* @return self
*/
public function configure()
{
$this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json';

return $this;
}

public function show($id, array $params = array())
Expand Down
4 changes: 4 additions & 0 deletions lib/Github/Api/Project/Cards.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ class Cards extends AbstractApi
* Configure the accept header for Early Access to the projects api
*
* @see https://developer.github.com/v3/repos/projects/#projects
*
* @return self
*/
public function configure()
{
$this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json';

return $this;
}

public function all($columnId, array $params = array())
Expand Down
4 changes: 4 additions & 0 deletions lib/Github/Api/Project/Columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ class Columns extends AbstractApi
* Configure the accept header for Early Access to the projects api
*
* @see https://developer.github.com/v3/repos/projects/#projects
*
* return self
*/
public function configure()
{
$this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json';

return $this;
}

public function all($projectId, array $params = array())
Expand Down
7 changes: 7 additions & 0 deletions lib/Github/Api/Repository/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class Comments extends AbstractApi
{
use AcceptHeaderTrait;

/**
* @param string|null $bodyType
*
* @return self
*/
public function configure($bodyType = null)
{
switch ($bodyType) {
Expand All @@ -35,6 +40,8 @@ public function configure($bodyType = null)
}

$this->acceptHeaderValue = $header;

return $this;
}

public function all($username, $repository, $sha = null)
Expand Down
4 changes: 4 additions & 0 deletions lib/Github/Api/Repository/Stargazers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ class Stargazers extends AbstractApi
* @see https://developer.github.com/v3/activity/starring/#alternative-response-with-star-creation-timestamps
*
* @param string $bodyType
*
* @return self
*/
public function configure($bodyType = null)
{
if ('star' === $bodyType) {
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->client->getApiVersion());
}

return $this;
}

public function all($username, $repository)
Expand Down