This commit is contained in:
Chris
2018-10-18 15:59:38 +01:00
parent 4f6a0cb7c6
commit 380a0e8623
352 changed files with 32929 additions and 3604 deletions

View File

@@ -0,0 +1,94 @@
<?php
namespace Github\Api\CurrentUser;
use Github\Api\AbstractApi;
use Github\Exception\InvalidArgumentException;
/**
* @link http://developer.github.com/v3/users/emails/
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class Emails extends AbstractApi
{
/**
* List emails for the authenticated user.
*
* @link http://developer.github.com/v3/users/emails/
*
* @return array
*/
public function all()
{
return $this->get('/user/emails');
}
/**
* List public email addresses for a user.
*
* @link https://developer.github.com/v3/users/emails/#list-public-email-addresses-for-a-user
*
* @return array
*/
public function allPublic()
{
return $this->get('/user/public_emails');
}
/**
* Adds one or more email for the authenticated user.
*
* @link http://developer.github.com/v3/users/emails/
*
* @param string|array $emails
*
* @throws \Github\Exception\InvalidArgumentException
*
* @return array
*/
public function add($emails)
{
if (is_string($emails)) {
$emails = [$emails];
} elseif (0 === count($emails)) {
throw new InvalidArgumentException();
}
return $this->post('/user/emails', $emails);
}
/**
* Removes one or more email for the authenticated user.
*
* @link http://developer.github.com/v3/users/emails/
*
* @param string|array $emails
*
* @throws \Github\Exception\InvalidArgumentException
*
* @return array
*/
public function remove($emails)
{
if (is_string($emails)) {
$emails = [$emails];
} elseif (0 === count($emails)) {
throw new InvalidArgumentException();
}
return $this->delete('/user/emails', $emails);
}
/**
* Toggle primary email visibility.
*
* @link https://developer.github.com/v3/users/emails/#toggle-primary-email-visibility
*
* @return array
*/
public function toggleVisibility()
{
return $this->patch('/user/email/visibility');
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace Github\Api\CurrentUser;
use Github\Api\AbstractApi;
/**
* @link http://developer.github.com/v3/users/followers/
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class Followers extends AbstractApi
{
/**
* List followed users by the authenticated user.
*
* @link http://developer.github.com/v3/repos/followers/
*
* @param int $page
*
* @return array
*/
public function all($page = 1)
{
return $this->get('/user/following', [
'page' => $page,
]);
}
/**
* Check that the authenticated user follows a user.
*
* @link http://developer.github.com/v3/repos/followers/
*
* @param string $username the username to follow
*
* @return array
*/
public function check($username)
{
return $this->get('/user/following/'.rawurlencode($username));
}
/**
* Make the authenticated user follow a user.
*
* @link http://developer.github.com/v3/repos/followers/
*
* @param string $username the username to follow
*
* @return array
*/
public function follow($username)
{
return $this->put('/user/following/'.rawurlencode($username));
}
/**
* Make the authenticated user un-follow a user.
*
* @link http://developer.github.com/v3/repos/followers/
*
* @param string $username the username to un-follow
*
* @return array
*/
public function unfollow($username)
{
return $this->delete('/user/following/'.rawurlencode($username));
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace Github\Api\CurrentUser;
use Github\Api\AbstractApi;
class Memberships extends AbstractApi
{
/**
* List your organization memberships.
*
* @link https://developer.github.com/v3/orgs/members/#get-your-organization-membership
*
* @return array
*/
public function all()
{
return $this->get('/user/memberships/orgs');
}
/**
* Get your organization membership.
*
* @link https://developer.github.com/v3/orgs/members/#get-your-organization-membership
*
* @param string $organization
*
* @return array
*/
public function organization($organization)
{
return $this->get('/user/memberships/orgs/'.rawurlencode($organization));
}
/**
* Edit your organization membership.
*
* @link https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
*
* @param string $organization
*
* @return array
*/
public function edit($organization)
{
return $this->patch('/user/memberships/orgs/'.rawurlencode($organization), ['state' => 'active']);
}
}

View File

@@ -0,0 +1,145 @@
<?php
namespace Github\Api\CurrentUser;
use Github\Api\AbstractApi;
/**
* @link http://developer.github.com/v3/activity/notifications/
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class Notifications extends AbstractApi
{
/**
* List all notifications for the authenticated user.
*
* @link http://developer.github.com/v3/activity/notifications/#list-your-notifications
*
* @param array $params
*
* @return array
*/
public function all(array $params = [])
{
return $this->get('/notifications', $params);
}
/**
* List all notifications for the authenticated user in selected repository.
*
* @link http://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
* @param array $params
*
* @return array
*/
public function allInRepository($username, $repository, array $params = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/notifications', $params);
}
/**
* Mark all notifications as read.
*
* @link http://developer.github.com/v3/activity/notifications/#mark-as-read
*
* @param array $params
*
* @return array
*/
public function markAsReadAll(array $params = [])
{
return $this->put('/notifications', $params);
}
/**
* Mark all notifications for a repository as read.
*
* @link http://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
* @param array $params
*
* @return array
*/
public function markAsReadInRepository($username, $repository, array $params = [])
{
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/notifications', $params);
}
/**
* Mark a notification as read.
*
* @link http://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
*
* @param int $id the notification number
* @param array $params
*
* @return array
*/
public function markAsRead($id, array $params)
{
return $this->patch('/notifications/threads/'.rawurlencode($id), $params);
}
/**
* Show a notification.
*
* @link http://developer.github.com/v3/activity/notifications/#view-a-single-thread
*
* @param int $id the notification number
*
* @return array
*/
public function show($id)
{
return $this->get('/notifications/threads/'.rawurlencode($id));
}
/**
* Show a subscription.
*
* @link http://developer.github.com/v3/activity/notifications/#get-a-thread-subscription
*
* @param int $id the notification number
*
* @return array
*/
public function showSubscription($id)
{
return $this->get('/notifications/threads/'.rawurlencode($id).'/subscription');
}
/**
* Create a subscription.
*
* @link http://developer.github.com/v3/activity/notifications/#set-a-thread-subscription
*
* @param int $id the notification number
* @param array $params
*
* @return array
*/
public function createSubscription($id, array $params)
{
return $this->put('/notifications/threads/'.rawurlencode($id).'/subscription', $params);
}
/**
* Delete a subscription.
*
* @link http://developer.github.com/v3/activity/notifications/#delete-a-thread-subscription
*
* @param int $id the notification number
*
* @return array
*/
public function removeSubscription($id)
{
return $this->delete('/notifications/threads/'.rawurlencode($id).'/subscription');
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace Github\Api\CurrentUser;
use Github\Api\AbstractApi;
use Github\Exception\MissingArgumentException;
/**
* @link http://developer.github.com/v3/users/keys/
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class PublicKeys extends AbstractApi
{
/**
* List deploy keys for the authenticated user.
*
* @link https://developer.github.com/v3/users/keys/
*
* @return array
*/
public function all()
{
return $this->get('/user/keys');
}
/**
* Shows deploy key for the authenticated user.
*
* @link https://developer.github.com/v3/users/keys/
*
* @param int $id
*
* @return array
*/
public function show($id)
{
return $this->get('/user/keys/'.rawurlencode($id));
}
/**
* Adds deploy key for the authenticated user.
*
* @link https://developer.github.com/v3/users/keys/
*
* @param array $params
*
* @throws \Github\Exception\MissingArgumentException
*
* @return array
*/
public function create(array $params)
{
if (!isset($params['title'], $params['key'])) {
throw new MissingArgumentException(['title', 'key']);
}
return $this->post('/user/keys', $params);
}
/**
* Removes deploy key for the authenticated user.
*
* @link https://developer.github.com/v3/users/keys/
*
* @param int $id
*
* @return array
*/
public function remove($id)
{
return $this->delete('/user/keys/'.rawurlencode($id));
}
}

View File

@@ -0,0 +1,76 @@
<?php
namespace Github\Api\CurrentUser;
use Github\Api\AbstractApi;
/**
* @link https://developer.github.com/v3/activity/starring/
*
* @author Felipe Valtl de Mello <eu@felipe.im>
*/
class Starring extends AbstractApi
{
/**
* List repositories starred by the authenticated user.
*
* @link https://developer.github.com/v3/activity/starring/
*
* @param int $page
* @param int $perPage
*
* @return array
*/
public function all($page = 1, $perPage = 30)
{
return $this->get('/user/starred', [
'page' => $page,
'per_page' => $perPage,
]);
}
/**
* Check that the authenticated user starres a repository.
*
* @link https://developer.github.com/v3/activity/starring/
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
*
* @return array
*/
public function check($username, $repository)
{
return $this->get('/user/starred/'.rawurlencode($username).'/'.rawurlencode($repository));
}
/**
* Make the authenticated user star a repository.
*
* @link https://developer.github.com/v3/activity/starring/
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
*
* @return array
*/
public function star($username, $repository)
{
return $this->put('/user/starred/'.rawurlencode($username).'/'.rawurlencode($repository));
}
/**
* Make the authenticated user unstar a repository.
*
* @link https://developer.github.com/v3/activity/starring
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
*
* @return array
*/
public function unstar($username, $repository)
{
return $this->delete('/user/starred/'.rawurlencode($username).'/'.rawurlencode($repository));
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace Github\Api\CurrentUser;
use Github\Api\AbstractApi;
/**
* @link https://developer.github.com/v3/activity/watching/
*
* @author Joseph Bielawski <stloyd@gmail.com>
* @revised Felipe Valtl de Mello <eu@felipe.im>
*/
class Watchers extends AbstractApi
{
/**
* List repositories watched by the authenticated user.
*
* @link https://developer.github.com/v3/activity/watching/
*
* @param int $page
*
* @return array
*/
public function all($page = 1)
{
return $this->get('/user/subscriptions', [
'page' => $page,
]);
}
/**
* Check that the authenticated user watches a repository.
*
* @link https://developer.github.com/v3/activity/watching/
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
*
* @return array
*/
public function check($username, $repository)
{
return $this->get('/user/subscriptions/'.rawurlencode($username).'/'.rawurlencode($repository));
}
/**
* Make the authenticated user watch a repository.
*
* @link https://developer.github.com/v3/activity/watching/
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
*
* @return array
*/
public function watch($username, $repository)
{
return $this->put('/user/subscriptions/'.rawurlencode($username).'/'.rawurlencode($repository));
}
/**
* Make the authenticated user unwatch a repository.
*
* @link https://developer.github.com/v3/activity/watching/
*
* @param string $username the user who owns the repo
* @param string $repository the name of the repo
*
* @return array
*/
public function unwatch($username, $repository)
{
return $this->delete('/user/subscriptions/'.rawurlencode($username).'/'.rawurlencode($repository));
}
}