Spade

Mini Shell

Directory:~$ /home/lmsyaran/public_html/joomla4/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/public_html/joomla4/package.tar

activity/events.php000064400000011024151156262620010421 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Activity Events class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/activity/events/
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageActivityEvents extends JGithubPackage
{
	/**
	 * List public events.
	 *
	 * @since   3.1.4
	 * @return  object
	 */
	public function getPublic()
	{
		// Build the request path.
		$path = '/events';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List repository events.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since   3.1.4
	 *
	 * @return  object
	 */
	public function getRepository($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/events';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List issue events for a repository.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since   3.1.4
	 * @return  object
	 */
	public function getIssue($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/events';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List public events for a network of repositories.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since   3.1.4
	 * @return  object
	 */
	public function getNetwork($owner, $repo)
	{
		// Build the request path.
		$path = '/networks/' . $owner . '/' . $repo .
'/events';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List public events for an organization.
	 *
	 * @param   string  $org  Organisation.
	 *
	 * @since   3.1.4
	 * @return  object
	 */
	public function getOrg($org)
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/events';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List events that a user has received.
	 *
	 * These are events that you’ve received by watching repos and following
users.
	 * If you are authenticated as the given user, you will see private
events.
	 * Otherwise, you’ll only see public events.
	 *
	 * @param   string  $user  User name.
	 *
	 * @since   3.1.4
	 * @return  object
	 */
	public function getUser($user)
	{
		// Build the request path.
		$path = '/users/' . $user . '/received_events';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List public events that a user has received.
	 *
	 * @param   string  $user  User name.
	 *
	 * @since   3.1.4
	 * @return  object
	 */
	public function getUserPublic($user)
	{
		// Build the request path.
		$path = '/users/' . $user .
'/received_events/public';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List events performed by a user.
	 *
	 * If you are authenticated as the given user, you will see your private
events.
	 * Otherwise, you’ll only see public events.
	 *
	 * @param   string  $user  User name.
	 *
	 * @since   3.1.4
	 * @return  object
	 */
	public function getByUser($user)
	{
		// Build the request path.
		$path = '/users/' . $user . '/events';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List public events performed by a user.
	 *
	 * @param   string  $user  User name.
	 *
	 * @since   3.1.4
	 * @return  object
	 */
	public function getByUserPublic($user)
	{
		// Build the request path.
		$path = '/users/' . $user . '/events/public';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List events for an organization.
	 *
	 * This is the user’s organization dashboard.
	 * You must be authenticated as the user to view this.
	 *
	 * @param   string  $user  User name.
	 * @param   string  $org   Organisation.
	 *
	 * @since   3.1.4
	 * @return  object
	 */
	public function getUserOrg($user, $org)
	{
		// Build the request path.
		$path = '/users/' . $user . '/events/orgs/' . $org;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}
}
activity/notifications.php000064400000016613151156262620011777
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Activity Events class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/activity/notifications/
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageActivityNotifications extends JGithubPackage
{
	/**
	 * List your notifications.
	 *
	 * List all notifications for the current user, grouped by repository.
	 *
	 * @param   boolean  $all            True to show notifications marked as
read.
	 * @param   boolean  $participating  True to show only notifications in
which the user is directly participating or
	 *                                   mentioned.
	 * @param   JDate    $since          filters out any notifications updated
before the given time. The time should be passed in
	 *                                   as UTC in the ISO 8601 format.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getList($all = true, $participating = true, JDate $since =
null)
	{
		// Build the request path.
		$path = '/notifications?';

		$path .= ($all) ? '&all=1' : '';
		$path .= ($participating) ? '&participating=1' :
'';
		$path .= ($since) ? '&since=' . $since->toISO8601() :
'';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List your notifications in a repository.
	 *
	 * List all notifications for the current user.
	 *
	 * @param   string   $owner          Repository owner.
	 * @param   string   $repo           Repository name.
	 * @param   boolean  $all            True to show notifications marked as
read.
	 * @param   boolean  $participating  True to show only notifications in
which the user is directly participating or
	 *                                   mentioned.
	 * @param   JDate    $since          filters out any notifications updated
before the given time. The time should be passed in
	 *                                   as UTC in the ISO 8601 format.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getListRepository($owner, $repo, $all = true,
$participating = true, JDate $since = null)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/notifications?';

		$path .= ($all) ? '&all=1' : '';
		$path .= ($participating) ? '&participating=1' :
'';
		$path .= ($since) ? '&since=' . $since->toISO8601() :
'';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Mark as read.
	 *
	 * Marking a notification as “read” removes it from the default view
on GitHub.com.
	 *
	 * @param   boolean  $unread      Changes the unread status of the
threads.
	 * @param   boolean  $read        Inverse of “unread”.
	 * @param   JDate    $lastReadAt  Describes the last point that
notifications were checked.
	 *                                Anything updated since this time will
not be updated. Default: Now. Expected in ISO 8601 format.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function markRead($unread = true, $read = true, JDate $lastReadAt =
null)
	{
		// Build the request path.
		$path = '/notifications';

		$data = array(
			'unread' => $unread,
			'read'   => $read,
		);

		if ($lastReadAt)
		{
			$data['last_read_at'] = $lastReadAt->toISO8601();
		}

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), json_encode($data)),
			205
		);
	}

	/**
	 * Mark notifications as read in a repository.
	 *
	 * Marking all notifications in a repository as “read” removes them
from the default view on GitHub.com.
	 *
	 * @param   string   $owner       Repository owner.
	 * @param   string   $repo        Repository name.
	 * @param   boolean  $unread      Changes the unread status of the
threads.
	 * @param   boolean  $read        Inverse of “unread”.
	 * @param   JDate    $lastReadAt  Describes the last point that
notifications were checked.
	 *                                Anything updated since this time will
not be updated. Default: Now. Expected in ISO 8601 format.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function markReadRepository($owner, $repo, $unread, $read, JDate
$lastReadAt = null)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/notifications';

		$data = array(
			'unread' => $unread,
			'read'   => $read,
		);

		if ($lastReadAt)
		{
			$data['last_read_at'] = $lastReadAt->toISO8601();
		}

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), json_encode($data)),
			205
		);
	}

	/**
	 * View a single thread.
	 *
	 * @param   integer  $id  The thread id.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function viewThread($id)
	{
		// Build the request path.
		$path = '/notifications/threads/' . $id;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Mark a thread as read.
	 *
	 * @param   integer  $id      The thread id.
	 * @param   boolean  $unread  Changes the unread status of the threads.
	 * @param   boolean  $read    Inverse of “unread”.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function markReadThread($id, $unread = true, $read = true)
	{
		// Build the request path.
		$path = '/notifications/threads/' . $id;

		$data = array(
			'unread' => $unread,
			'read'   => $read,
		);

		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path),
json_encode($data)),
			205
		);
	}

	/**
	 * Get a Thread Subscription.
	 *
	 * This checks to see if the current user is subscribed to a thread.
	 * You can also get a Repository subscription.
	 *
	 * @param   integer  $id  The thread id.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getThreadSubscription($id)
	{
		// Build the request path.
		$path = '/notifications/threads/' . $id .
'/subscription';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Set a Thread Subscription.
	 *
	 * This lets you subscribe to a thread, or ignore it. Subscribing to a
thread is unnecessary
	 * if the user is already subscribed to the repository. Ignoring a thread
will mute all
	 * future notifications (until you comment or get @mentioned).
	 *
	 * @param   integer  $id          The thread id.
	 * @param   boolean  $subscribed  Determines if notifications should be
received from this thread.
	 * @param   boolean  $ignored     Determines if all notifications should
be blocked from this thread.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function setThreadSubscription($id, $subscribed, $ignored)
	{
		// Build the request path.
		$path = '/notifications/threads/' . $id .
'/subscription';

		$data = array(
			'subscribed' => $subscribed,
			'ignored'    => $ignored,
		);

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), json_encode($data))
		);
	}

	/**
	 * Delete a Thread Subscription.
	 *
	 * @param   integer  $id  The thread id.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function deleteThreadSubscription($id)
	{
		// Build the request path.
		$path = '/notifications/threads/' . $id .
'/subscription';

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
activity/starring.php000064400000006010151156262620010745 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Activity Events class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/activity/starring/
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageActivityStarring extends JGithubPackage
{
	/**
	 * List Stargazers.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return mixed
	 */
	public function getList($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/stargazers';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List repositories being starred.
	 *
	 * List repositories being starred by a user.
	 *
	 * @param   string  $user  User name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getRepositories($user = '')
	{
		// Build the request path.
		$path = ($user)
			? '/users' . $user . '/starred'
			: '/user/starred';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Check if you are starring a repository.
	 *
	 * Requires for the user to be authenticated.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @throws UnexpectedValueException
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function check($owner, $repo)
	{
		// Build the request path.
		$path = '/user/starred/' . $owner . '/' . $repo;

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case '204' :
				// This repository is watched by you.
				return true;
				break;

			case '404' :
				// This repository is not watched by you.
				return false;
				break;
		}

		throw new UnexpectedValueException('Unexpected response code: '
. $response->code);
	}

	/**
	 * Star a repository.
	 *
	 * Requires for the user to be authenticated.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function star($owner, $repo)
	{
		// Build the request path.
		$path = '/user/starred/' . $owner . '/' . $repo;

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), ''),
			204
		);
	}

	/**
	 * Unstar a repository.
	 *
	 * Requires for the user to be authenticated.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function unstar($owner, $repo)
	{
		// Build the request path.
		$path = '/user/starred/' . $owner . '/' . $repo;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
activity/watching.php000064400000011247151156262620010730 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Activity Watching Events class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/activity/watching/
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageActivityWatching extends JGithubPackage
{
	/**
	 * List watchers
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return mixed
	 */
	public function getList($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/subscribers';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List repositories being watched.
	 *
	 * List repositories being watched by a user.
	 *
	 * @param   string  $user  User name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return mixed
	 */
	public function getRepositories($user = '')
	{
		// Build the request path.
		$path = ($user)
			? '/users/' . $user . '/subscriptions'
			: '/user/subscriptions';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get a Repository Subscription.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return mixed
	 */
	public function getSubscription($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/subscription';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Set a Repository Subscription.
	 *
	 * @param   string   $owner       Repository owner.
	 * @param   string   $repo        Repository name.
	 * @param   boolean  $subscribed  Determines if notifications should be
received from this thread.
	 * @param   boolean  $ignored     Determines if all notifications should
be blocked from this thread.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function setSubscription($owner, $repo, $subscribed, $ignored)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/subscription';

		$data = array(
			'subscribed' => $subscribed,
			'ignored'    => $ignored,
		);

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), json_encode($data))
		);
	}

	/**
	 * Delete a Repository Subscription.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function deleteSubscription($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/subscription';

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}

	/**
	 * Check if you are watching a repository (LEGACY).
	 *
	 * Requires for the user to be authenticated.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @throws UnexpectedValueException
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function check($owner, $repo)
	{
		// Build the request path.
		$path = '/user/subscriptions/' . $owner . '/' .
$repo;

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case '204' :
				// This repository is watched by you.
				return true;
				break;

			case '404' :
				// This repository is not watched by you.
				return false;
				break;
		}

		throw new UnexpectedValueException('Unexpected response code: '
. $response->code);
	}

	/**
	 * Watch a repository (LEGACY).
	 *
	 * Requires for the user to be authenticated.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function watch($owner, $repo)
	{
		// Build the request path.
		$path = '/user/subscriptions/' . $owner . '/' .
$repo;

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), ''),
			204
		);
	}

	/**
	 * Stop watching a repository (LEGACY).
	 *
	 * Requires for the user to be authenticated.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function unwatch($owner, $repo)
	{
		// Build the request path.
		$path = '/user/subscriptions/' . $owner . '/' .
$repo;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
activity.php000064400000001373151156262620007123 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Activity class for the Joomla Platform.
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 *
 * @documentation  https://developer.github.com/v3/activity/
 *
 * @property-read  JGithubPackageActivityEvents  $events  GitHub API object
for markdown.
 */
class JGithubPackageActivity extends JGithubPackage
{
	protected $name = 'Activity';

	protected $packages = array('events', 'notifications',
'starring', 'watching');
}
authorization.php000064400000020373151156262620010170 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Authorization class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/oauth/
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageAuthorization extends JGithubPackage
{
	/**
	 * Method to create an authorization.
	 *
	 * @param   array   $scopes  A list of scopes that this authorization is
in.
	 * @param   string  $note    A note to remind you what the OAuth token is
for.
	 * @param   string  $url     A URL to remind you what app the OAuth token
is for.
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 *
	 * @return  object
	 */
	public function create(array $scopes = array(), $note = '', $url
= '')
	{
		// Build the request path.
		$path = '/authorizations';

		$data = json_encode(
			array('scopes' => $scopes, 'note' => $note,
'note_url' => $url)
		);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to delete an authorization
	 *
	 * @param   integer  $id  ID of the authorization to delete
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 *
	 * @return  object
	 */
	public function delete($id)
	{
		// Build the request path.
		$path = '/authorizations/' . $id;

		// Send the request.
		$response = $this->client->delete($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 204)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to edit an authorization.
	 *
	 * @param   integer  $id            ID of the authorization to edit
	 * @param   array    $scopes        Replaces the authorization scopes with
these.
	 * @param   array    $addScopes     A list of scopes to add to this
authorization.
	 * @param   array    $removeScopes  A list of scopes to remove from this
authorization.
	 * @param   string   $note          A note to remind you what the OAuth
token is for.
	 * @param   string   $url           A URL to remind you what app the OAuth
token is for.
	 *
	 * @throws RuntimeException
	 * @throws DomainException
	 * @since   3.1.4
	 *
	 * @return  object
	 */
	public function edit($id, array $scopes = array(), array $addScopes =
array(), array $removeScopes = array(), $note = '', $url =
'')
	{
		// Check if more than one scopes array contains data
		$scopesCount = 0;

		if (!empty($scopes))
		{
			$scope     = 'scopes';
			$scopeData = $scopes;
			$scopesCount++;
		}

		if (!empty($addScopes))
		{
			$scope     = 'add_scopes';
			$scopeData = $addScopes;
			$scopesCount++;
		}

		if (!empty($removeScopes))
		{
			$scope     = 'remove_scopes';
			$scopeData = $removeScopes;
			$scopesCount++;
		}

		// Only allowed to send data for one scope parameter
		if ($scopesCount >= 2)
		{
			throw new RuntimeException('You can only send one scope key in this
request.');
		}

		// Build the request path.
		$path = '/authorizations/' . $id;

		$data = json_encode(
			array(
				$scope     => $scopeData,
				'note'     => $note,
				'note_url' => $url,
			)
		);

		// Send the request.
		$response = $this->client->patch($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get details about an authorised application for the
authenticated user.
	 *
	 * @param   integer  $id  ID of the authorization to retrieve
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 * @note    This method will only accept Basic Authentication
	 *
	 * @return  object
	 */
	public function get($id)
	{
		// Build the request path.
		$path = '/authorizations/' . $id;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get the authorised applications for the authenticated user.
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 * @note    This method will only accept Basic Authentication
	 *
	 * @return  object
	 */
	public function getList()
	{
		// Build the request path.
		$path = '/authorizations';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get the rate limit for the authenticated user.
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 *
	 * @return  object
	 */
	public function getRateLimit()
	{
		// Build the request path.
		$path = '/rate_limit';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * 1. Request authorization on GitHub.
	 *
	 * @param   string  $clientId     The client ID you received from GitHub
when you registered.
	 * @param   string  $redirectUri  URL in your app where users will be sent
after authorization.
	 * @param   string  $scope        Comma separated list of scopes.
	 * @param   string  $state        An unguessable random string. It is used
to protect against
	 *                                cross-site request forgery attacks.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return JUri
	 */
	public function getAuthorizationLink($clientId, $redirectUri =
'', $scope = '', $state = '')
	{
		$uri = new JUri('https://github.com/login/oauth/authorize');

		$uri->setVar('client_id', $clientId);

		if ($redirectUri)
		{
			$uri->setVar('redirect_uri', urlencode($redirectUri));
		}

		if ($scope)
		{
			$uri->setVar('scope', $scope);
		}

		if ($state)
		{
			$uri->setVar('state', $state);
		}

		return (string) $uri;
	}

	/**
	 * 2. Request the access token.
	 *
	 * @param   string  $clientId      The client ID you received from GitHub
when you registered.
	 * @param   string  $clientSecret  The client secret you received from
GitHub when you registered.
	 * @param   string  $code          The code you received as a response to
Step 1.
	 * @param   string  $redirectUri   URL in your app where users will be
sent after authorization.
	 * @param   string  $format        The response format (json, xml, ).
	 *
	 * @throws UnexpectedValueException
	 * @since 3.3 (CMS)
	 *
	 * @return string
	 */
	public function requestToken($clientId, $clientSecret, $code, $redirectUri
= '', $format = '')
	{
		$uri = 'https://github.com/login/oauth/access_token';

		$data = array(
			'client_id'     => $clientId,
			'client_secret' => $clientSecret,
			'code'          => $code,
		);

		if ($redirectUri)
		{
			$data['redirect_uri'] = $redirectUri;
		}

		$headers = array();

		switch ($format)
		{
			case 'json' :
				$headers['Accept'] = 'application/json';
				break;
			case 'xml' :
				$headers['Accept'] = 'application/xml';
				break;
			default :
				if ($format)
				{
					throw new UnexpectedValueException('Invalid format');
				}
				break;
		}

		// Send the request.
		return $this->processResponse(
			$this->client->post($uri, $data, $headers),
			200, false
		);
	}
}
data/blobs.php000064400000003465151156262620007305 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Data Blobs class for the Joomla Platform.
 *
 * Since blobs can be any arbitrary binary data, the input and responses
for the blob API
 * takes an encoding parameter that can be either utf-8 or base64. If your
data cannot be
 * losslessly sent as a UTF-8 string, you can base64 encode it.
 *
 * @documentation https://developer.github.com/v3/git/blobs/
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageDataBlobs extends JGithubPackage
{
	/**
	 * Get a Blob.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 * @param   string  $sha    The commit SHA.
	 *
	 * @return object
	 */
	public function get($owner, $repo, $sha)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/blobs/' . $sha;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Create a Blob.
	 *
	 * @param   string  $owner     Repository owner.
	 * @param   string  $repo      Repository name.
	 * @param   string  $content   The content of the blob.
	 * @param   string  $encoding  The encoding to use.
	 *
	 * @return object
	 */
	public function create($owner, $repo, $content, $encoding =
'utf-8')
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/blobs';

		$data = array(
			'content'  => $content,
			'encoding' => $encoding,
		);

		return $this->processResponse(
			$this->client->post($this->fetchUrl($path),
json_encode($data)),
			201
		);
	}
}
data/commits.php000064400000004276151156262620007660 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Data Commits class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/git/commits/
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageDataCommits extends JGithubPackage
{
	/**
	 * Get a single commit.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $sha    The commit SHA.
	 *
	 * @return object
	 */
	public function get($owner, $repo, $sha)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/commits/' . $sha;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Method to create a commit.
	 *
	 * @param   string  $owner    The name of the owner of the GitHub
repository.
	 * @param   string  $repo     The name of the GitHub repository.
	 * @param   string  $message  The commit message.
	 * @param   string  $tree     SHA of the tree object this commit points
to.
	 * @param   array   $parents  Array of the SHAs of the commits that were
the parents of this commit.
	 *                            If omitted or empty, the commit will be
written as a root commit.
	 *                            For a single parent, an array of one SHA
should be provided.
	 *                            For a merge commit, an array of more than
one should be provided.
	 *
	 * @throws DomainException
	 * @since   3.0.0
	 *
	 * @return  object
	 */
	public function create($owner, $repo, $message, $tree, array $parents =
array())
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/commits';

		$data = json_encode(
			array('message' => $message, 'tree' => $tree,
'parents' => $parents)
		);

		// Send the request.
		return $this->processResponse(
			$response = $this->client->post($this->fetchUrl($path), $data),
			201
		);
	}
}
data/refs.php000064400000012016151156262620007133 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API References class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/git/refs/
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageDataRefs extends JGithubPackage
{
	/**
	 * Method to get a reference.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 * @param   string  $ref   The reference to get.
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function get($user, $repo, $ref)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/git/refs/' . $ref;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to list references for a repository.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   string   $namespace  Optional sub-namespace to limit the
returned references.
	 * @param   integer  $page       Page to request
	 * @param   integer  $limit      Number of results to return per page
	 *
	 * @return  array
	 *
	 * @since   1.7.3
	 */
	public function getList($user, $repo, $namespace = '', $page =
0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/git/refs' . $namespace;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to create a ref.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 * @param   string  $ref   The name of the fully qualified reference.
	 * @param   string  $sha   The SHA1 value to set this reference to.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function create($user, $repo, $ref, $sha)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/git/refs';

		// Build the request data.
		$data = json_encode(
			array(
				'ref' => $ref,
				'sha' => $sha,
			)
		);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to update a reference.
	 *
	 * @param   string   $user   The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   string   $ref    The reference to update.
	 * @param   string   $sha    The SHA1 value to set the reference to.
	 * @param   boolean  $force  Whether the update should be forced. Default
to false.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function edit($user, $repo, $ref, $sha, $force = false)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/git/refs/' . $ref;

		// Craete the data object.
		$data = new stdClass;

		// If a title is set add it to the data object.
		if ($force)
		{
			$data->force = true;
		}

		$data->sha = $sha;

		// Encode the request data.
		$data = json_encode($data);

		// Send the request.
		$response = $this->client->patch($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Delete a Reference
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $ref    The reference to update.
	 *
	 * @since   3.3 (CMS)
	 * @return object
	 */
	public function delete($owner, $repo, $ref)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/refs/' . $ref;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
data/tags.php000064400000005533151156262620007140 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Data Tags class for the Joomla Platform.
 *
 * This tags API only deals with tag objects - so only annotated tags, not
lightweight tags.
 *
 * @documentation https://developer.github.com/v3/git/tags/
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageDataTags extends JGithubPackage
{
	/**
	 * Get a Tag.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $sha    The SHA1 value to set the reference to.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return object
	 */
	public function get($owner, $repo, $sha)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/tags/' . $sha;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Create a Tag Object
	 *
	 * Note that creating a tag object does not create the reference that
makes a tag in Git.
	 * If you want to create an annotated tag in Git, you have to do this call
to create the tag object,
	 * and then create the refs/tags/[tag] reference. If you want to create a
lightweight tag,
	 * you simply have to create the reference - this call would be
unnecessary.
	 *
	 * @param   string  $owner        The name of the owner of the GitHub
repository.
	 * @param   string  $repo         The name of the GitHub repository.
	 * @param   string  $tag          The tag string.
	 * @param   string  $message      The tag message.
	 * @param   string  $object       The SHA of the git object this is
tagging.
	 * @param   string  $type         The type of the object we’re tagging.
Normally this is a commit
	 *                                but it can also be a tree or a blob.
	 * @param   string  $taggerName   The name of the author of the tag.
	 * @param   string  $taggerEmail  The email of the author of the tag.
	 * @param   string  $taggerDate   Timestamp of when this object was
tagged.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return object
	 */
	public function create($owner, $repo, $tag, $message, $object, $type,
$taggerName, $taggerEmail, $taggerDate)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/tags';

		$data = array(
			'tag'          => $tag,
			'message'      => $message,
			'object'       => $object,
			'type'         => $type,
			'tagger_name'  => $taggerName,
			'tagger_email' => $taggerEmail,
			'tagger_date'  => $taggerDate,
		);

		return $this->processResponse(
			$this->client->post($this->fetchUrl($path),
json_encode($data)),
			201
		);
	}
}
data/trees.php000064400000006431151156262620007322 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Data Trees class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/git/trees/
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageDataTrees extends JGithubPackage
{
	/**
	 * Get a Tree
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $sha    The SHA1 value to set the reference to.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return object
	 */
	public function get($owner, $repo, $sha)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/trees/' . $sha;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get a Tree Recursively
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $sha    The SHA1 value to set the reference to.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return object
	 */
	public function getRecursively($owner, $repo, $sha)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/trees/' . $sha . '?recursive=1';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Create a Tree.
	 *
	 * The tree creation API will take nested entries as well. If both a tree
and a nested path
	 * modifying that tree are specified, it will overwrite the contents of
that tree with the
	 * new path contents and write a new tree out.
	 *
	 * Parameters fir the tree:
	 *
	 * tree.path
	 *     String of the file referenced in the tree
	 * tree.mode
	 *     String of the file mode - one of 100644 for file (blob), 100755 for
executable (blob),
	 *     040000 for subdirectory (tree), 160000 for submodule (commit) or
120000 for a blob
	 *     that specifies the path of a symlink
	 * tree.type
	 *     String of blob, tree, commit
	 * tree.sha
	 *     String of SHA1 checksum ID of the object in the tree
	 * tree.content
	 *     String of content you want this file to have - GitHub will write
this blob out and use
	 *     that SHA for this entry. Use either this or tree.sha
	 *
	 * @param   string  $owner     The name of the owner of the GitHub
repository.
	 * @param   string  $repo      The name of the GitHub repository.
	 * @param   array   $tree      Array of Hash objects (of path, mode, type
and sha) specifying
	 *                             a tree structure
	 * @param   string  $baseTree  The SHA1 of the tree you want to update
with new data.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return object
	 */
	public function create($owner, $repo, $tree, $baseTree = '')
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/git/trees';

		$data = array();

		$data['tree'] = $tree;

		if ($baseTree)
		{
			$data['base_tree'] = $baseTree;
		}

		return $this->processResponse(
			$this->client->post($this->fetchUrl($path),
json_encode($data)),
			201
		);
	}
}
data.php000064400000004437151156262620006204 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API DB class for the Joomla Platform.
 *
 * https://developer.github.com/v3/git/
 * Git DB API
 *
 * The Git Database API gives you access to read and write raw Git objects
to your Git database on GitHub and to list
 *  * and update your references (branch heads and tags).
 *
 * This basically allows you to reimplement a lot of Git functionality over
our API - by creating raw objects
 *  * directly into the database and updating branch references you could
technically do just about anything that
 *  * Git can do without having Git installed.
 *
 * Git DB API functions will return a 409 if the git repo for a Repository
is empty or unavailable.
 *  * This typically means it is being created still. Contact Support if
this response status persists.
 *
 * git db
 *
 * For more information on the Git object database, please read the Git
Internals chapter of the Pro Git book.
 *
 * As an example, if you wanted to commit a change to a file in your
repository, you would:
 *
 *     get the current commit object
 *     retrieve the tree it points to
 *     retrieve the content of the blob object that tree has for that
particular file path
 *     change the content somehow and post a new blob object with that new
content, getting a blob SHA back
 *     post a new tree object with that file path pointer replaced with
your new blob SHA getting a tree SHA back
 *     create a new commit object with the current commit SHA as the parent
and the new tree SHA, getting a commit SHA back
 *     update the reference of your branch to point to the new commit SHA
 *
 * It might seem complex, but it’s actually pretty simple when you
understand the model and it opens up a ton of
 * things you could potentially do with the API.
 *
 * @documentation https://developer.github.com/v3/git/
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageData extends JGithubPackage
{
	protected $name = 'Data';

	protected $packages = array('blobs', 'commits',
'refs', 'tags', 'trees');
}
gists/comments.php000064400000010435151156262620010244 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Gists Comments class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/gists/comments/
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageGistsComments extends JGithubPackage
{
	/**
	 * Method to create a comment on a gist.
	 *
	 * @param   integer  $gistId  The gist number.
	 * @param   string   $body    The comment body text.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function create($gistId, $body)
	{
		// Build the request path.
		$path = '/gists/' . (int) $gistId . '/comments';

		// Build the request data.
		$data = json_encode(
			array(
				'body' => $body,
			)
		);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to delete a comment on a gist.
	 *
	 * @param   integer  $commentId  The id of the comment to delete.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  void
	 */
	public function delete($commentId)
	{
		// Build the request path.
		$path = '/gists/comments/' . (int) $commentId;

		// Send the request.
		$response = $this->client->delete($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 204)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}
	}

	/**
	 * Method to update a comment on a gist.
	 *
	 * @param   integer  $commentId  The id of the comment to update.
	 * @param   string   $body       The new body text for the comment.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function edit($commentId, $body)
	{
		// Build the request path.
		$path = '/gists/comments/' . (int) $commentId;

		// Build the request data.
		$data = json_encode(
			array(
				'body' => $body,
			)
		);

		// Send the request.
		$response = $this->client->patch($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a specific comment on a gist.
	 *
	 * @param   integer  $commentId  The comment id to get.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function get($commentId)
	{
		// Build the request path.
		$path = '/gists/comments/' . (int) $commentId;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get the list of comments on a gist.
	 *
	 * @param   integer  $gistId  The gist number.
	 * @param   integer  $page    The page number from which to get items.
	 * @param   integer  $limit   The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getList($gistId, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/gists/' . (int) $gistId . '/comments';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}
}
gists.php000064400000031443151156262620006421 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Gists class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/gists
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 *
 * @property-read  JGithubPackageGistsComments  $comments  GitHub API
object for gist comments.
 */
class JGithubPackageGists extends JGithubPackage
{
	protected $name = 'Gists';

	protected $packages = array(
		'comments',
	);

	/**
	 * Method to create a gist.
	 *
	 * @param   mixed    $files        Either an array of file paths or a
single file path as a string.
	 * @param   boolean  $public       True if the gist should be public.
	 * @param   string   $description  The optional description of the gist.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function create($files, $public = false, $description = null)
	{
		// Build the request path.
		$path = '/gists';

		// Build the request data.
		$data = json_encode(
			array(
				'files' => $this->buildFileData((array) $files),
				'public' => (bool) $public,
				'description' => $description,
			)
		);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to delete a gist.
	 *
	 * @param   integer  $gistId  The gist number.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  void
	 */
	public function delete($gistId)
	{
		// Build the request path.
		$path = '/gists/' . (int) $gistId;

		// Send the request.
		$response = $this->client->delete($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 204)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}
	}

	/**
	 * Method to update a gist.
	 *
	 * @param   integer  $gistId       The gist number.
	 * @param   mixed    $files        Either an array of file paths or a
single file path as a string.
	 * @param   boolean  $public       True if the gist should be public.
	 * @param   string   $description  The description of the gist.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function edit($gistId, $files = null, $public = null, $description
= null)
	{
		// Build the request path.
		$path = '/gists/' . (int) $gistId;

		// Create the data object.
		$data = new stdClass;

		// If a description is set add it to the data object.
		if (isset($description))
		{
			$data->description = $description;
		}

		// If the public flag is set add it to the data object.
		if (isset($public))
		{
			$data->public = $public;
		}

		// If a state is set add it to the data object.
		if (isset($files))
		{
			$data->files = $this->buildFileData((array) $files);
		}

		// Encode the request data.
		$data = json_encode($data);

		// Send the request.
		$response = $this->client->patch($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to fork a gist.
	 *
	 * @param   integer  $gistId  The gist number.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function fork($gistId)
	{
		// Build the request path.
		$path = '/gists/' . (int) $gistId . '/fork';

		// Send the request.
		// TODO: Verify change
		$response = $this->client->post($this->fetchUrl($path),
'');

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a single gist.
	 *
	 * @param   integer  $gistId  The gist number.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function get($gistId)
	{
		// Build the request path.
		$path = '/gists/' . (int) $gistId;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to list gists.  If a user is authenticated it will return the
user's gists, otherwise
	 * it will return all public gists.
	 *
	 * @param   integer  $page   The page number from which to get items.
	 * @param   integer  $limit  The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getList($page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/gists';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a list of gists belonging to a given user.
	 *
	 * @param   string   $user   The name of the GitHub user from which to
list gists.
	 * @param   integer  $page   The page number from which to get items.
	 * @param   integer  $limit  The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getListByUser($user, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/users/' . $user . '/gists';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a list of all public gists.
	 *
	 * @param   integer  $page   The page number from which to get items.
	 * @param   integer  $limit  The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getListPublic($page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/gists/public';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a list of the authenticated users' starred gists.
	 *
	 * @param   integer  $page   The page number from which to get items.
	 * @param   integer  $limit  The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getListStarred($page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/gists/starred';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to check if a gist has been starred.
	 *
	 * @param   integer  $gistId  The gist number.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  boolean  True if the gist is starred.
	 */
	public function isStarred($gistId)
	{
		// Build the request path.
		$path = '/gists/' . (int) $gistId . '/star';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code == 204)
		{
			return true;
		}
		elseif ($response->code == 404)
		{
			return false;
		}
		else
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}
	}

	/**
	 * Method to star a gist.
	 *
	 * @param   integer  $gistId  The gist number.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  void
	 */
	public function star($gistId)
	{
		// Build the request path.
		$path = '/gists/' . (int) $gistId . '/star';

		// Send the request.
		$response = $this->client->put($this->fetchUrl($path),
'');

		// Validate the response code.
		if ($response->code != 204)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}
	}

	/**
	 * Method to star a gist.
	 *
	 * @param   integer  $gistId  The gist number.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  void
	 */
	public function unstar($gistId)
	{
		// Build the request path.
		$path = '/gists/' . (int) $gistId . '/star';

		// Send the request.
		$response = $this->client->delete($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 204)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}
	}

	/**
	 * Method to fetch a data array for transmitting to the GitHub API for a
list of files based on
	 * an input array of file paths or filename and content pairs.
	 *
	 * @param   array  $files  The list of file paths or filenames and
content.
	 *
	 * @throws InvalidArgumentException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	protected function buildFileData(array $files)
	{
		$data = array();

		foreach ($files as $key => $file)
		{
			// If the key isn't numeric, then we are dealing with a file whose
content has been supplied
			if (!is_numeric($key))
			{
				$data[$key] = array('content' => $file);
			}

			// Otherwise, we have been given a path and we have to load the content
			// Verify that the each file exists.
			elseif (!file_exists($file))
			{
				throw new InvalidArgumentException('The file ' . $file .
' does not exist.');
			}
			else
			{
				$data[basename($file)] = array('content' =>
file_get_contents($file));
			}
		}

		return $data;
	}

	/*
	 * Deprecated methods
	 */

	/**
	 * Method to create a comment on a gist.
	 *
	 * @param   integer  $gistId  The gist number.
	 * @param   string   $body    The comment body text.
	 *
	 * @deprecated use gists->comments->create()
	 *
	 * @return  object
	 *
	 * @since      1.7.3
	 */
	public function createComment($gistId, $body)
	{
		return $this->comments->create($gistId, $body);
	}

	/**
	 * Method to delete a comment on a gist.
	 *
	 * @param   integer  $commentId  The id of the comment to delete.
	 *
	 * @deprecated use gists->comments->delete()
	 *
	 * @return  void
	 *
	 * @since   1.7.3
	 */
	public function deleteComment($commentId)
	{
		$this->comments->delete($commentId);
	}

	/**
	 * Method to update a comment on a gist.
	 *
	 * @param   integer  $commentId  The id of the comment to update.
	 * @param   string   $body       The new body text for the comment.
	 *
	 * @deprecated use gists->comments->edit()
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function editComment($commentId, $body)
	{
		return $this->comments->edit($commentId, $body);
	}

	/**
	 * Method to get a specific comment on a gist.
	 *
	 * @param   integer  $commentId  The comment id to get.
	 *
	 * @deprecated use gists->comments->get()
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function getComment($commentId)
	{
		return $this->comments->get($commentId);
	}

	/**
	 * Method to get the list of comments on a gist.
	 *
	 * @param   integer  $gistId  The gist number.
	 * @param   integer  $page    The page number from which to get items.
	 * @param   integer  $limit   The number of items on a page.
	 *
	 * @deprecated use gists->comments->getList()
	 *
	 * @return  array
	 *
	 * @since   1.7.3
	 */
	public function getComments($gistId, $page = 0, $limit = 0)
	{
		return $this->comments->getList($gistId, $page, $limit);
	}
}
gitignore.php000064400000003642151156262620007257 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Gitignore class for the Joomla Platform.
 *
 * The .gitignore Templates API lists and fetches templates from the GitHub
.gitignore repository.
 *
 * @documentation https://developer.github.com/v3/gitignore/
 * @documentation https://github.com/github/gitignore
 *
 * @since       3.3.0
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageGitignore extends JGithubPackage
{
	/**
	 * Listing available templates
	 *
	 * List all templates available to pass as an option when creating a
repository.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getList()
	{
		// Build the request path.
		$path = '/gitignore/templates';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get a single template
	 *
	 * @param   string   $name  The name of the template
	 * @param   boolean  $raw   Raw output
	 *
	 * @throws DomainException
	 * @since  3.3 (CMS)
	 *
	 * @return mixed|string
	 */
	public function get($name, $raw = false)
	{
		// Build the request path.
		$path = '/gitignore/templates/' . $name;

		$headers = array();

		if ($raw)
		{
			$headers['Accept'] =
'application/vnd.github.raw+json';
		}

		$response = $this->client->get($this->fetchUrl($path),
$headers);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error   = json_decode($response->body);
			$message = (isset($error->message)) ? $error->message :
'Invalid response';

			throw new DomainException($message, $response->code);
		}

		return ($raw) ? $response->body : json_decode($response->body);
	}
}
issues/assignees.php000064400000004135151156262620010562 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Assignees class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/issues/assignees/
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageIssuesAssignees extends JGithubPackage
{
	/**
	 * List assignees.
	 *
	 * This call lists all the available assignees (owner + collaborators) to
which issues may be assigned.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 *
	 * @return object
	 */
	public function getList($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/assignees';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Check assignee.
	 *
	 * You may check to see if a particular user is an assignee for a
repository.
	 * If the given assignee login belongs to an assignee for the repository,
a 204 header
	 * with no content is returned.
	 * Otherwise a 404 status code is returned.
	 *
	 * @param   string  $owner     The name of the owner of the GitHub
repository.
	 * @param   string  $repo      The name of the GitHub repository.
	 * @param   string  $assignee  The assignees login name.
	 *
	 * @throws DomainException|Exception
	 * @return boolean
	 */
	public function check($owner, $repo, $assignee)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/assignees/' . $assignee;

		try
		{
			$response = $this->client->get($this->fetchUrl($path));

			if (204 == $response->code)
			{
				return true;
			}

			throw new DomainException('Invalid response: ' .
$response->code);
		}
		catch (DomainException $e)
		{
			if (isset($response->code) && 404 == $response->code)
			{
				return false;
			}

			throw $e;
		}
	}
}
issues/comments.php000064400000013015151156262620010423 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Comments class for the Joomla Platform.
 *
 * The Issue Comments API supports listing, viewing, editing, and creating
comments
 * on issues and pull requests.
 *
 * @documentation https://developer.github.com/v3/issues/comments/
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageIssuesComments extends JGithubPackage
{
	/**
	 * Method to get the list of comments on an issue.
	 *
	 * @param   string   $owner    The name of the owner of the GitHub
repository.
	 * @param   string   $repo     The name of the GitHub repository.
	 * @param   integer  $issueId  The issue number.
	 * @param   integer  $page     The page number from which to get items.
	 * @param   integer  $limit    The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getList($owner, $repo, $issueId, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . (int) $issueId . '/comments';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path, $page, $limit))
		);
	}

	/**
	 * Method to get the list of comments in a repository.
	 *
	 * @param   string  $owner      The name of the owner of the GitHub
repository.
	 * @param   string  $repo       The name of the GitHub repository.
	 * @param   string  $sort       The sort field - created or updated.
	 * @param   string  $direction  The sort order- asc or desc. Ignored
without sort parameter.
	 * @param   JDate   $since      A timestamp in ISO 8601 format.
	 *
	 * @throws UnexpectedValueException
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getRepositoryList($owner, $repo, $sort =
'created', $direction = 'asc', JDate $since = null)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/comments';

		if (false == in_array($sort, array('created',
'updated')))
		{
			throw new UnexpectedValueException(
				sprintf(
					'%1$s - sort field must be "created" or
"updated"', __METHOD__
				)
			);
		}

		if (false == in_array($direction, array('asc',
'desc')))
		{
			throw new UnexpectedValueException(
				sprintf(
					'%1$s - direction field must be "asc" or
"desc"', __METHOD__
				)
			);
		}

		$path .= '?sort=' . $sort;
		$path .= '&direction=' . $direction;

		if ($since)
		{
			$path .= '&since=' . $since->toISO8601();
		}

		// Send the request.
		return
$this->processResponse($this->client->get($this->fetchUrl($path)));
	}

	/**
	 * Method to get a single comment.
	 *
	 * @param   string   $owner  The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   integer  $id     The comment id.
	 *
	 * @return mixed
	 */
	public function get($owner, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/comments/' . (int) $id;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Method to update a comment on an issue.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The id of the comment to update.
	 * @param   string   $body       The new body text for the comment.
	 *
	 * @since   1.7.3
	 * @throws DomainException
	 *
	 * @return  object
	 */
	public function edit($user, $repo, $commentId, $body)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/issues/comments/' . (int) $commentId;

		// Build the request data.
		$data = json_encode(
			array(
				'body' => $body,
			)
		);

		// Send the request.
		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path), $data)
		);
	}

	/**
	 * Method to create a comment on an issue.
	 *
	 * @param   string   $user     The name of the owner of the GitHub
repository.
	 * @param   string   $repo     The name of the GitHub repository.
	 * @param   integer  $issueId  The issue number.
	 * @param   string   $body     The comment body text.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function create($user, $repo, $issueId, $body)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/issues/' . (int) $issueId . '/comments';

		// Build the request data.
		$data = json_encode(
			array(
				'body' => $body,
			)
		);

		// Send the request.
		return $this->processResponse(
			$this->client->post($this->fetchUrl($path), $data),
			201
		);
	}

	/**
	 * Method to delete a comment on an issue.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The id of the comment to delete.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  boolean
	 */
	public function delete($user, $repo, $commentId)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/issues/comments/' . (int) $commentId;

		// Send the request.
		$this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);

		return true;
	}
}
issues/events.php000064400000005317151156262620010110 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Issues Events class for the Joomla Platform.
 *
 * Records various events that occur around an Issue or Pull Request.
 * This is useful both for display on issue/pull request information pages
and also
 * to determine who should be notified of comments.
 *
 * @documentation https://developer.github.com/v3/issues/events/
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageIssuesEvents extends JGithubPackage
{
	/**
	 * List events for an issue.
	 *
	 * @param   string   $owner        The name of the owner of the GitHub
repository.
	 * @param   string   $repo         The name of the GitHub repository.
	 * @param   integer  $issueNumber  The issue number.
	 * @param   integer  $page         The page number from which to get
items.
	 * @param   integer  $limit        The number of items on a page.
	 *
	 * @return object
	 */
	public function getList($owner, $repo, $issueNumber, $page = 0, $limit =
0)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . (int) $issueNumber . '/events';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path, $page, $limit))
		);
	}

	/**
	 * List events for a repository.
	 *
	 * @param   string   $owner    The name of the owner of the GitHub
repository.
	 * @param   string   $repo     The name of the GitHub repository.
	 * @param   integer  $issueId  The issue number.
	 * @param   integer  $page     The page number from which to get items.
	 * @param   integer  $limit    The number of items on a page.
	 *
	 * @return object
	 */
	public function getListRepository($owner, $repo, $issueId, $page = 0,
$limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . (int) $issueId . '/comments';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path, $page, $limit))
		);
	}

	/**
	 * Get a single event.
	 *
	 * @param   string   $owner  The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   integer  $id     The event number.
	 *
	 * @return object
	 */
	public function get($owner, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/events/' . (int) $id;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}
}
issues/labels.php000064400000017214151156262620010045 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Milestones class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/issues/labels/
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageIssuesLabels extends JGithubPackage
{
	/**
	 * Method to get the list of labels on a repo.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 *
	 * @return  array
	 */
	public function getList($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/labels';

		// Send the request.
		return $this->processResponse(
			$response = $this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Method to get a specific label on a repo.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 * @param   string  $name  The label name to get.
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 *
	 * @return  object
	 */
	public function get($user, $repo, $name)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/labels/' . $name;

		// Send the request.
		return $this->processResponse(
			$response = $this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Method to create a label on a repo.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $name   The label name.
	 * @param   string  $color  The label color.
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 *
	 * @return  object
	 */
	public function create($owner, $repo, $name, $color)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/labels';

		// Build the request data.
		$data = json_encode(
			array(
				'name'  => $name,
				'color' => $color,
			)
		);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to update a label on a repo.
	 *
	 * @param   string  $user   The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $label  The label name.
	 * @param   string  $name   The new label name.
	 * @param   string  $color  The new label color.
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 *
	 * @return  object
	 */
	public function update($user, $repo, $label, $name, $color)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/labels/' . $label;

		// Build the request data.
		$data = json_encode(
			array(
				'name'  => $name,
				'color' => $color,
			)
		);

		// Send the request.
		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path), $data)
		);
	}

	/**
	 * Method to delete a label on a repo.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $name   The label name.
	 *
	 * @throws DomainException
	 * @return  object
	 *
	 * @since   3.1.4
	 */
	public function delete($owner, $repo, $name)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/labels/' . $name;

		// Send the request.
		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}

	/**
	 * List labels on an issue.
	 *
	 * @param   string   $owner   The name of the owner of the GitHub
repository.
	 * @param   string   $repo    The name of the GitHub repository.
	 * @param   integer  $number  The issue number.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return  object
	 */
	public function getListByIssue($owner, $repo, $number)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Add labels to an issue.
	 *
	 * @param   string  $owner   The name of the owner of the GitHub
repository.
	 * @param   string  $repo    The name of the GitHub repository.
	 * @param   string  $number  The issue number.
	 * @param   array   $labels  An array of labels to add.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return  object
	 */
	public function add($owner, $repo, $number, array $labels)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels';

		// Send the request.
		return $this->processResponse(
			$this->client->post($this->fetchUrl($path),
json_encode($labels))
		);
	}

	/**
	 * Remove a label from an issue.
	 *
	 * @param   string  $owner   The name of the owner of the GitHub
repository.
	 * @param   string  $repo    The name of the GitHub repository.
	 * @param   string  $number  The issue number.
	 * @param   string  $name    The name of the label to remove.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return  object
	 */
	public function removeFromIssue($owner, $repo, $number, $name)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels/' . $name;

		// Send the request.
		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path))
		);
	}

	/**
	 * Replace all labels for an issue.
	 *
	 * Sending an empty array ([]) will remove all Labels from the Issue.
	 *
	 * @param   string  $owner   The name of the owner of the GitHub
repository.
	 * @param   string  $repo    The name of the GitHub repository.
	 * @param   string  $number  The issue number.
	 * @param   array   $labels  New labels
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return  object
	 */
	public function replace($owner, $repo, $number, array $labels)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels';

		// Send the request.
		return $this->processResponse(
			$this->client->put($this->fetchUrl($path),
json_encode($labels))
		);
	}

	/**
	.* Remove all labels from an issue.
	 *
	 * @param   string  $owner   The name of the owner of the GitHub
repository.
	 * @param   string  $repo    The name of the GitHub repository.
	 * @param   string  $number  The issue number.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return  object
	 */
	public function removeAllFromIssue($owner, $repo, $number)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/issues/' . $number . '/labels';

		// Send the request.
		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}

	/**
	 * Get labels for every issue in a milestone.
	 *
	 * @param   string  $owner   The name of the owner of the GitHub
repository.
	 * @param   string  $repo    The name of the GitHub repository.
	 * @param   string  $number  The issue number.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return  object
	 */
	public function getListByMilestone($owner, $repo, $number)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/milestones/' . $number . '/labels';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}
}
issues/milestones.php000064400000014732151156262620010767 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Milestones class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/issues/milestones/
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageIssuesMilestones extends JGithubPackage
{
	/**
	 * Method to get the list of milestones for a repo.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   string   $state      The milestone state to retrieved.  Open
(default) or closed.
	 * @param   string   $sort       Sort can be due_date (default) or
completeness.
	 * @param   string   $direction  Direction is asc or desc (default).
	 * @param   integer  $page       The page number from which to get items.
	 * @param   integer  $limit      The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   3.1.4
	 *
	 * @return  array
	 */
	public function getList($user, $repo, $state = 'open', $sort =
'due_date', $direction = 'desc', $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/milestones?';

		$path .= 'state=' . $state;
		$path .= '&sort=' . $sort;
		$path .= '&direction=' . $direction;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a specific milestone.
	 *
	 * @param   string   $user         The name of the owner of the GitHub
repository.
	 * @param   string   $repo         The name of the GitHub repository.
	 * @param   integer  $milestoneId  The milestone id to get.
	 *
	 * @throws DomainException
	 * @return  object
	 *
	 * @since   3.1.4
	 */
	public function get($user, $repo, $milestoneId)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/milestones/' . (int) $milestoneId;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to create a milestone for a repository.
	 *
	 * @param   string   $user         The name of the owner of the GitHub
repository.
	 * @param   string   $repo         The name of the GitHub repository.
	 * @param   integer  $title        The title of the milestone.
	 * @param   string   $state        Can be open (default) or closed.
	 * @param   string   $description  Optional description for milestone.
	 * @param   string   $dueOn        Optional ISO 8601 time.
	 *
	 * @throws DomainException
	 * @return  object
	 *
	 * @since   3.1.4
	 */
	public function create($user, $repo, $title, $state = null, $description =
null, $dueOn = null)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/milestones';

		// Build the request data.
		$data = array(
			'title' => $title,
		);

		if (!is_null($state))
		{
			$data['state'] = $state;
		}

		if (!is_null($description))
		{
			$data['description'] = $description;
		}

		if (!is_null($dueOn))
		{
			$data['due_on'] = $dueOn;
		}

		$data = json_encode($data);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to update a milestone.
	 *
	 * @param   string   $user         The name of the owner of the GitHub
repository.
	 * @param   string   $repo         The name of the GitHub repository.
	 * @param   integer  $milestoneId  The id of the comment to update.
	 * @param   integer  $title        Optional title of the milestone.
	 * @param   string   $state        Can be open (default) or closed.
	 * @param   string   $description  Optional description for milestone.
	 * @param   string   $dueOn        Optional ISO 8601 time.
	 *
	 * @throws DomainException
	 * @return  object
	 *
	 * @since   3.1.4
	 */
	public function edit($user, $repo, $milestoneId, $title = null, $state =
null, $description = null, $dueOn = null)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/milestones/' . (int) $milestoneId;

		// Build the request data.
		$data = array();

		if (!is_null($title))
		{
			$data['title'] = $title;
		}

		if (!is_null($state))
		{
			$data['state'] = $state;
		}

		if (!is_null($description))
		{
			$data['description'] = $description;
		}

		if (!is_null($dueOn))
		{
			$data['due_on'] = $dueOn;
		}

		$data = json_encode($data);

		// Send the request.
		$response = $this->client->patch($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to delete a milestone.
	 *
	 * @param   string   $user         The name of the owner of the GitHub
repository.
	 * @param   string   $repo         The name of the GitHub repository.
	 * @param   integer  $milestoneId  The id of the milestone to delete.
	 *
	 * @throws DomainException
	 * @return  void
	 *
	 * @since   3.1.4
	 */
	public function delete($user, $repo, $milestoneId)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/milestones/' . (int) $milestoneId;

		// Send the request.
		$response = $this->client->delete($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 204)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}
	}
}
issues.php000064400000034607151156262630006611 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Issues class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/issues
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 *
 * @property-read  JGithubPackageIssuesAssignees   $assignees   GitHub API
object for assignees.
 * @property-read  JGithubPackageIssuesComments    $comments    GitHub API
object for comments.
 * @property-read  JGithubPackageIssuesEvents      $events      GitHub API
object for events.
 * @property-read  JGithubPackageIssuesLabels      $labels      GitHub API
object for labels.
 * @property-read  JGithubPackageIssuesMilestones  $milestones  GitHub API
object for milestones.
 */
class JGithubPackageIssues extends JGithubPackage
{
	protected $name = 'Issues';

	protected $packages = array('assignees', 'comments',
'events', 'labels', 'milestones');

	/**
	 * Method to create an issue.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   string   $title      The title of the new issue.
	 * @param   string   $body       The body text for the new issue.
	 * @param   string   $assignee   The login for the GitHub user that this
issue should be assigned to.
	 * @param   integer  $milestone  The milestone to associate this issue
with.
	 * @param   array    $labels     The labels to associate with this issue.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function create($user, $repo, $title, $body = null, $assignee =
null, $milestone = null, array $labels = null)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/issues';

		// Ensure that we have a non-associative array.
		if (isset($labels))
		{
			$labels = array_values($labels);
		}

		// Build the request data.
		$data = json_encode(
			array(
				'title'     => $title,
				'assignee'  => $assignee,
				'milestone' => $milestone,
				'labels'    => $labels,
				'body'      => $body,
			)
		);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to update an issue.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $issueId    The issue number.
	 * @param   string   $state      The optional new state for the issue.
[open, closed]
	 * @param   string   $title      The title of the new issue.
	 * @param   string   $body       The body text for the new issue.
	 * @param   string   $assignee   The login for the GitHub user that this
issue should be assigned to.
	 * @param   integer  $milestone  The milestone to associate this issue
with.
	 * @param   array    $labels     The labels to associate with this issue.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function edit($user, $repo, $issueId, $state = null, $title = null,
$body = null, $assignee = null, $milestone = null, array $labels = null)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/issues/' . (int) $issueId;

		// Create the data object.
		$data = new stdClass;

		// If a title is set add it to the data object.
		if (isset($title))
		{
			$data->title = $title;
		}

		// If a body is set add it to the data object.
		if (isset($body))
		{
			$data->body = $body;
		}

		// If a state is set add it to the data object.
		if (isset($state))
		{
			$data->state = $state;
		}

		// If an assignee is set add it to the data object.
		if (isset($assignee))
		{
			$data->assignee = $assignee;
		}

		// If a milestone is set add it to the data object.
		if (isset($milestone))
		{
			$data->milestone = $milestone;
		}

		// If labels are set add them to the data object.
		if (isset($labels))
		{
			// Ensure that we have a non-associative array.
			if (isset($labels))
			{
				$labels = array_values($labels);
			}

			$data->labels = $labels;
		}

		// Encode the request data.
		$data = json_encode($data);

		// Send the request.
		$response = $this->client->patch($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a single issue.
	 *
	 * @param   string   $user     The name of the owner of the GitHub
repository.
	 * @param   string   $repo     The name of the GitHub repository.
	 * @param   integer  $issueId  The issue number.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function get($user, $repo, $issueId)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/issues/' . (int) $issueId;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to list an authenticated user's issues.
	 *
	 * @param   string   $filter     The filter type: assigned, created,
mentioned, subscribed.
	 * @param   string   $state      The optional state to filter requests by.
[open, closed]
	 * @param   string   $labels     The list of comma separated Label names.
Example: bug,ui,@high.
	 * @param   string   $sort       The sort order: created, updated,
comments, default: created.
	 * @param   string   $direction  The list direction: asc or desc, default:
desc.
	 * @param   JDate    $since      The date/time since when issues should be
returned.
	 * @param   integer  $page       The page number from which to get items.
	 * @param   integer  $limit      The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getList($filter = null, $state = null, $labels = null,
$sort = null,
		$direction = null, JDate $since = null, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/issues';

		// TODO Implement the filtering options.

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to list issues.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   string   $milestone  The milestone number, 'none',
or *.
	 * @param   string   $state      The optional state to filter requests by.
[open, closed]
	 * @param   string   $assignee   The assignee name, 'none', or
*.
	 * @param   string   $mentioned  The GitHub user name.
	 * @param   string   $labels     The list of comma separated Label names.
Example: bug,ui,@high.
	 * @param   string   $sort       The sort order: created, updated,
comments, default: created.
	 * @param   string   $direction  The list direction: asc or desc, default:
desc.
	 * @param   JDate    $since      The date/time since when issues should be
returned.
	 * @param   integer  $page       The page number from which to get items.
	 * @param   integer  $limit      The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getListByRepository($user, $repo, $milestone = null,
$state = null, $assignee = null, $mentioned = null, $labels = null,
		$sort = null, $direction = null, JDate $since = null, $page = 0, $limit =
0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/issues';

		$uri = new JUri($this->fetchUrl($path, $page, $limit));

		if ($milestone)
		{
			$uri->setVar('milestone', $milestone);
		}

		if ($state)
		{
			$uri->setVar('state', $state);
		}

		if ($assignee)
		{
			$uri->setVar('assignee', $assignee);
		}

		if ($mentioned)
		{
			$uri->setVar('mentioned', $mentioned);
		}

		if ($labels)
		{
			$uri->setVar('labels', $labels);
		}

		if ($sort)
		{
			$uri->setVar('sort', $sort);
		}

		if ($direction)
		{
			$uri->setVar('direction', $direction);
		}

		if ($since)
		{
			$uri->setVar('since', $since->toISO8601());
		}

		// Send the request.
		$response = $this->client->get((string) $uri);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/*
	 * Deprecated methods
	 */

	/**
	 * Method to create a comment on an issue.
	 *
	 * @param   string   $user     The name of the owner of the GitHub
repository.
	 * @param   string   $repo     The name of the GitHub repository.
	 * @param   integer  $issueId  The issue number.
	 * @param   string   $body     The comment body text.
	 *
	 * @deprecated use issues->comments->create()
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function createComment($user, $repo, $issueId, $body)
	{
		return $this->comments->create($user, $repo, $issueId, $body);
	}

	/**
	 * Method to create a label on a repo.
	 *
	 * @param   string  $user   The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $name   The label name.
	 * @param   string  $color  The label color.
	 *
	 * @deprecated use issues->labels->create()
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 */
	public function createLabel($user, $repo, $name, $color)
	{
		return $this->labels->create($user, $repo, $name, $color);
	}

	/**
	 * Method to delete a comment on an issue.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The id of the comment to delete.
	 *
	 * @deprecated use issues->comments->delete()
	 *
	 * @return  void
	 *
	 * @since   1.7.3
	 */
	public function deleteComment($user, $repo, $commentId)
	{
		$this->comments->delete($user, $repo, $commentId);
	}

	/**
	 * Method to delete a label on a repo.
	 *
	 * @param   string  $user   The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $label  The label name.
	 *
	 * @deprecated use issues->labels->delete()
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 */
	public function deleteLabel($user, $repo, $label)
	{
		return $this->labels->delete($user, $repo, $label);
	}

	/**
	 * Method to update a comment on an issue.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The id of the comment to update.
	 * @param   string   $body       The new body text for the comment.
	 *
	 * @deprecated use issues->comments->edit()
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function editComment($user, $repo, $commentId, $body)
	{
		return $this->comments->edit($user, $repo, $commentId, $body);
	}

	/**
	 * Method to update a label on a repo.
	 *
	 * @param   string  $user   The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $label  The label name.
	 * @param   string  $name   The label name.
	 * @param   string  $color  The label color.
	 *
	 * @deprecated use issues->labels->update()
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 */
	public function editLabel($user, $repo, $label, $name, $color)
	{
		return $this->labels->update($user, $repo, $label, $name, $color);
	}

	/**
	 * Method to get a specific comment on an issue.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The comment id to get.
	 *
	 * @deprecated use issues->comments->get()
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function getComment($user, $repo, $commentId)
	{
		return $this->comments->get($user, $repo, $commentId);
	}

	/**
	 * Method to get the list of comments on an issue.
	 *
	 * @param   string   $user     The name of the owner of the GitHub
repository.
	 * @param   string   $repo     The name of the GitHub repository.
	 * @param   integer  $issueId  The issue number.
	 * @param   integer  $page     The page number from which to get items.
	 * @param   integer  $limit    The number of items on a page.
	 *
	 * @deprecated use issues->comments->getList()
	 *
	 * @return  array
	 *
	 * @since   1.7.3
	 */
	public function getComments($user, $repo, $issueId, $page = 0, $limit = 0)
	{
		return $this->comments->getList($user, $repo, $issueId, $page,
$limit);
	}

	/**
	 * Method to get a specific label on a repo.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 * @param   string  $name  The label name to get.
	 *
	 * @deprecated use issues->labels->get()
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 */
	public function getLabel($user, $repo, $name)
	{
		return $this->labels->get($user, $repo, $name);
	}

	/**
	 * Method to get the list of labels on a repo.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 *
	 * @deprecated use issues->labels->getList()
	 *
	 * @return  array
	 *
	 * @since   3.1.4
	 */
	public function getLabels($user, $repo)
	{
		return $this->labels->getList($user, $repo);
	}
}
markdown.php000064400000003652151156262630007114 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2012 - 2016 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see
LICENSE.txt
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Markdown class.
 *
 * @documentation https://developer.github.com/v3/markdown
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageMarkdown extends JGithubPackage
{
	/**
	 * Method to render a markdown document.
	 *
	 * @param   string  $text     The text object being parsed.
	 * @param   string  $mode     The parsing mode; valid options are
'markdown' or 'gfm'.
	 * @param   string  $context  An optional repository context, only used in
'gfm' mode.
	 *
	 * @since   3.3 (CMS)
	 * @throws  DomainException
	 * @throws  InvalidArgumentException
	 *
	 * @return  string  Formatted HTML
	 */
	public function render($text, $mode = 'gfm', $context = null)
	{
		// The valid modes
		$validModes = array('gfm', 'markdown');

		// Make sure the scope is valid
		if (!in_array($mode, $validModes))
		{
			throw new InvalidArgumentException(sprintf('The %s mode is not
valid. Valid modes are "gfm" or "markdown".',
$mode));
		}

		// Build the request path.
		$path = '/markdown';

		// Build the request data.
		$data = str_replace('\\/', '/', json_encode(
				array(
					'text'    => $text,
					'mode'    => $mode,
					'context' => $context,
				)
			)
		);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			$message = (isset($error->message)) ? $error->message :
'Error: ' . $response->code;
			throw new DomainException($message, $response->code);
		}

		return $response->body;
	}
}
orgs/members.php000064400000012405151156262630007672 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Orgs Members class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/orgs/members/
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageOrgsMembers extends JGithubPackage
{
	/**
	 * Members list.
	 *
	 * List all users who are members of an organization.
	 * A member is a user that belongs to at least 1 team in the organization.
	 * If the authenticated user is also a member of this organization then
	 * both concealed and public members will be returned.
	 * If the requester is not a member of the organization the query will be
	 * redirected to the public members list.
	 *
	 * @param   string  $org  The name of the organization.
	 *
	 * @throws UnexpectedValueException
	 * @since    3.3 (CMS)
	 *
	 * @return boolean|mixed
	 */
	public function getList($org)
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/members';

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case 302 :
				// Requester is not an organization member.
				return false;
				break;

			case 200 :
				return json_decode($response->body);
				break;

			default :
				throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
				break;
		}
	}

	/**
	 * Check membership.
	 *
	 * Check if a user is, publicly or privately, a member of the
organization.
	 *
	 * @param   string  $org   The name of the organization.
	 * @param   string  $user  The name of the user.
	 *
	 * @throws UnexpectedValueException
	 * @since    3.3 (CMS)
	 *
	 * @return boolean
	 */
	public function check($org, $user)
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/members/' . $user;

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case 204 :
				// Requester is an organization member and user is a member.
				return true;
				break;

			case 404 :
				// Requester is an organization member and user is not a member.
				// Requester is not an organization member and is inquiring about
themselves.
				return false;
				break;

			case 302 :
				// Requester is not an organization member.
				return false;
				break;

			default :
				throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
				break;
		}
	}

	/**
	 * Add a member.
	 *
	 * To add someone as a member to an org, you must add them to a team.
	 */

	/**
	 * Remove a member.
	 *
	 * Removing a user from this list will remove them from all teams and they
will no longer have
	 * any access to the organization’s repositories.
	 *
	 * @param   string  $org   The name of the organization.
	 * @param   string  $user  The name of the user.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function remove($org, $user)
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/members/' . $user;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}

	/**
	 * Public members list.
	 *
	 * Members of an organization can choose to have their membership
publicized or not.
	 *
	 * @param   string  $org  The name of the organization.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function getListPublic($org)
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/public_members';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Check public membership.
	 *
	 * @param   string  $org   The name of the organization.
	 * @param   string  $user  The name of the user.
	 *
	 * @throws UnexpectedValueException
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function checkPublic($org, $user)
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/public_members/' . $user;

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case 204 :
				// Response if user is a public member.
				return true;
				break;

			case 404 :
				// Response if user is not a public member.
				return false;
				break;

			default :
				throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
				break;
		}
	}

	/**
	 * Publicize a user’s membership.
	 *
	 * @param   string  $org   The name of the organization.
	 * @param   string  $user  The name of the user.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function publicize($org, $user)
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/public_members/' . $user;

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), ''),
			204
		);
	}

	/**
	 * Conceal a user’s membership.
	 *
	 * @param   string  $org   The name of the organization.
	 * @param   string  $user  The name of the user.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function conceal($org, $user)
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/public_members/' . $user;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
orgs/teams.php000064400000022624151156262630007355 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Orgs Teams class for the Joomla Platform.
 *
 * All actions against teams require at a minimum an authenticated user who
is a member
 * of the owner’s team in the :org being managed. Additionally, OAuth
users require “user” scope.
 *
 * @documentation https://developer.github.com/v3/orgs/teams/
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageOrgsTeams extends JGithubPackage
{
	/**
	 * List teams.
	 *
	 * @param   string  $org  The name of the organization.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function getList($org)
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/teams';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get team.
	 *
	 * @param   integer  $id  The team id.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function get($id)
	{
		// Build the request path.
		$path = '/teams/' . (int) $id;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Create team.
	 *
	 * In order to create a team, the authenticated user must be an owner of
the organization.
	 *
	 * @param   string  $org         The name of the organization.
	 * @param   string  $name        The name of the team.
	 * @param   array   $repoNames   Repository names.
	 * @param   string  $permission  The permission.
	 *                               pull - team members can pull, but not
push to or administer these repositories. Default
	 *                               push - team members can pull and push,
but not administer these repositories.
	 *                               admin - team members can pull, push and
administer these repositories.
	 *
	 * @throws UnexpectedValueException
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function create($org, $name, array $repoNames = array(),
$permission = '')
	{
		// Build the request path.
		$path = '/orgs/' . $org . '/teams';

		$data = array(
			'name' => $name,
		);

		if ($repoNames)
		{
			$data['repo_names'] = $repoNames;
		}

		if ($permission)
		{
			if (false == in_array($permission, array('pull',
'push', 'admin')))
			{
				throw new UnexpectedValueException('Permissions must be either
"pull", "push", or "admin".');
			}

			$data['permission'] = $permission;
		}

		return $this->processResponse(
			$this->client->post($this->fetchUrl($path), $data),
			201
		);
	}

	/**
	 * Edit team.
	 *
	 * In order to edit a team, the authenticated user must be an owner of the
org that the team is associated with.
	 *
	 * @param   integer  $id          The team id.
	 * @param   string   $name        The name of the team.
	 * @param   string   $permission  The permission.
	 *                                pull - team members can pull, but not
push to or administer these repositories. Default
	 *                                push - team members can pull and push,
but not administer these repositories.
	 *                                admin - team members can pull, push and
administer these repositories.
	 *
	 * @throws UnexpectedValueException
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function edit($id, $name, $permission = '')
	{
		// Build the request path.
		$path = '/teams/' . (int) $id;

		$data = array(
			'name' => $name,
		);

		if ($permission)
		{
			if (false == in_array($permission, array('pull',
'push', 'admin')))
			{
				throw new UnexpectedValueException('Permissions must be either
"pull", "push", or "admin".');
			}

			$data['permission'] = $permission;
		}

		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path), $data)
		);
	}

	/**
	 * Delete team.
	 *
	 * In order to delete a team, the authenticated user must be an owner of
the org that the team is associated with.
	 *
	 * @param   integer  $id  The team id.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function delete($id)
	{
		// Build the request path.
		$path = '/teams/' . $id;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}

	/**
	 * List team members.
	 *
	 * In order to list members in a team, the authenticated user must be a
member of the team.
	 *
	 * @param   integer  $id  The team id.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function getListMembers($id)
	{
		// Build the request path.
		$path = '/teams/' . $id . '/members';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get team member.
	 *
	 * In order to get if a user is a member of a team, the authenticated user
must be a member of the team.
	 *
	 * @param   integer  $id    The team id.
	 * @param   string   $user  The name of the user.
	 *
	 * @throws UnexpectedValueException
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function isMember($id, $user)
	{
		// Build the request path.
		$path = '/teams/' . $id . '/members/' . $user;

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case 204 :
				// Response if user is a member
				return true;
				break;

			case 404 :
				// Response if user is not a member
				return false;
				break;

			default :
				throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
				break;
		}
	}

	/**
	 * Add team member.
	 *
	 * In order to add a user to a team, the authenticated user must have
‘admin’ permissions
	 * to the team or be an owner of the org that the team is associated with.
	 *
	 * @param   integer  $id    The team id.
	 * @param   string   $user  The name of the user.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function addMember($id, $user)
	{
		// Build the request path.
		$path = '/teams/' . $id . '/members/' . $user;

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), ''),
			204
		);
	}

	/**
	 * Remove team member.
	 *
	 * In order to remove a user from a team, the authenticated user must have
‘admin’ permissions
	 * to the team or be an owner of the org that the team is associated with.
	 * NOTE: This does not delete the user, it just remove them from the team.
	 *
	 * @param   integer  $id    The team id.
	 * @param   string   $user  The name of the user.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function removeMember($id, $user)
	{
		// Build the request path.
		$path = '/teams/' . $id . '/members/' . $user;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}

	/**
	 * List team repos.
	 *
	 * @param   integer  $id  The team id.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function getListRepos($id)
	{
		// Build the request path.
		$path = '/teams/' . $id . '/repos';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Check if the repo is managed by this team.
	 *
	 * @param   integer  $id    The team id.
	 * @param   string   $repo  The name of the GitHub repository.
	 *
	 * @throws UnexpectedValueException
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function checkRepo($id, $repo)
	{
		// Build the request path.
		$path = '/teams/' . $id . '/repos/' . $repo;

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case 204 :
				// Response if repo is managed by this team.
				return true;
				break;

			case 404 :
				// Response if repo is not managed by this team.
				return false;
				break;

			default :
				throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
				break;
		}
	}

	/**
	 * Add team repo.
	 *
	 * In order to add a repo to a team, the authenticated user must be an
owner of the
	 * org that the team is associated with. Also, the repo must be owned by
the organization,
	 * or a direct form of a repo owned by the organization.
	 *
	 * If you attempt to add a repo to a team that is not owned by the
organization, you get:
	 * Status: 422 Unprocessable Entity
	 *
	 * @param   integer  $id     The team id.
	 * @param   string   $owner  The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function addRepo($id, $owner, $repo)
	{
		// Build the request path.
		$path = '/teams/' . $id . '/repos/' . $owner .
'/' . $repo;

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), ''),
			204
		);
	}

	/**
	 * Remove team repo.
	 *
	 * In order to remove a repo from a team, the authenticated user must be
an owner
	 * of the org that the team is associated with. NOTE: This does not delete
the
	 * repo, it just removes it from the team.
	 *
	 * @param   integer  $id     The team id.
	 * @param   string   $owner  The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function removeRepo($id, $owner, $repo)
	{
		// Build the request path.
		$path = '/teams/' . (int) $id . '/repos/' . $owner .
'/' . $repo;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
orgs.php000064400000005120151156262630006234 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Activity class for the Joomla Platform.
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 *
 * @documentation  https://developer.github.com/v3/orgs/
 *
 * @property-read  JGithubPackageOrgsMembers  $members  GitHub API object
for members.
 * @property-read  JGithubPackageOrgsTeams    $teams    GitHub API object
for teams.
 */
class JGithubPackageOrgs extends JGithubPackage
{
	protected $name = 'Orgs';

	protected $packages = array('members', 'teams');

	/**
	 * List User Organizations.
	 *
	 * If a user name is given, public and private organizations for the
authenticated user will be listed.
	 *
	 * @param   string  $user  The user name.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return  object
	 */
	public function getList($user = '')
	{
		// Build the request path.
		$path = ($user)
			? '/users/' . $user . '/orgs'
			: '/user/orgs';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get an Organization.
	 *
	 * @param   string  $org  The organization name.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return  object
	 */
	public function get($org)
	{
		// Build the request path.
		$path = '/orgs/' . $org;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Edit an Organization.
	 *
	 * @param   string  $org           The organization name.
	 * @param   string  $billingEmail  Billing email address. This address is
not publicized.
	 * @param   string  $company       The company name.
	 * @param   string  $email         The email address.
	 * @param   string  $location      The location name.
	 * @param   string  $name          The name.
	 *
	 * @since   3.3 (CMS)
	 *
	 * @return  object
	 */
	public function edit($org, $billingEmail = '', $company =
'', $email = '', $location = '', $name =
'')
	{
		// Build the request path.
		$path = '/orgs/' . $org;

		$args = array('billing_email', 'company',
'email', 'location', 'name');

		$data = array();

		$fArgs = func_get_args();

		foreach ($args as $i => $arg)
		{
			if (array_key_exists($i + 1, $fArgs) && $fArgs[$i + 1])
			{
				$data[$arg] = $fArgs[$i + 1];
			}
		}

		// Send the request.
		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path), $data)
		);
	}
}
pulls/comments.php000064400000012615151156262630010255 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Pulls Comments class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/pulls/comments/
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackagePullsComments extends JGithubPackage
{
	/**
	 * Method to create a comment on a pull request.
	 *
	 * @param   string   $user      The name of the owner of the GitHub
repository.
	 * @param   string   $repo      The name of the GitHub repository.
	 * @param   integer  $pullId    The pull request number.
	 * @param   string   $body      The comment body text.
	 * @param   string   $commitId  The SHA1 hash of the commit to comment on.
	 * @param   string   $filePath  The Relative path of the file to comment
on.
	 * @param   string   $position  The line index in the diff to comment on.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function create($user, $repo, $pullId, $body, $commitId, $filePath,
$position)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/comments';

		// Build the request data.
		$data = json_encode(
			array(
				'body' => $body,
				'commit_id' => $commitId,
				'path' => $filePath,
				'position' => $position,
			)
		);

		// Send the request.
		return $this->processResponse(
			$this->client->post($this->fetchUrl($path), $data),
			201
		);
	}

	/**
	 * Method to create a comment in reply to another comment.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $pullId     The pull request number.
	 * @param   string   $body       The comment body text.
	 * @param   integer  $inReplyTo  The id of the comment to reply to.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function createReply($user, $repo, $pullId, $body, $inReplyTo)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/comments';

		// Build the request data.
		$data = json_encode(
			array(
				'body' => $body,
				'in_reply_to' => (int) $inReplyTo,
			)
		);

		// Send the request.
		return $this->processResponse(
			$this->client->post($this->fetchUrl($path), $data),
			201
		);
	}

	/**
	 * Method to delete a comment on a pull request.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The id of the comment to delete.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  void
	 */
	public function delete($user, $repo, $commentId)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/comments/' . (int) $commentId;

		// Send the request.
		$this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}

	/**
	 * Method to update a comment on a pull request.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The id of the comment to update.
	 * @param   string   $body       The new body text for the comment.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function edit($user, $repo, $commentId, $body)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/comments/' . (int) $commentId;

		// Build the request data.
		$data = json_encode(
			array(
				'body' => $body,
			)
		);

		// Send the request.
		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path), $data)
		);
	}

	/**
	 * Method to get a specific comment on a pull request.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The comment id to get.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function get($user, $repo, $commentId)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/comments/' . (int) $commentId;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Method to get the list of comments on a pull request.
	 *
	 * @param   string   $user    The name of the owner of the GitHub
repository.
	 * @param   string   $repo    The name of the GitHub repository.
	 * @param   integer  $pullId  The pull request number.
	 * @param   integer  $page    The page number from which to get items.
	 * @param   integer  $limit   The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getList($user, $repo, $pullId, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/comments';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path, $page, $limit))
		);
	}
}
pulls.php000064400000035506151156262630006434 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Pull Requests class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/pulls
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 *
 * @property-read  JGithubPackagePullsComments  $comments  GitHub API
object for comments.
 */
class JGithubPackagePulls extends JGithubPackage
{
	protected $name = 'Pulls';

	protected $packages = array(
		'comments',
	);

	/**
	 * Method to create a pull request.
	 *
	 * @param   string  $user   The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $title  The title of the new pull request.
	 * @param   string  $base   The branch (or git ref) you want your changes
pulled into. This
	 *                          should be an existing branch on the current
repository. You cannot
	 *                          submit a pull request to one repo that
requests a merge to a base
	 *                          of another repo.
	 * @param   string  $head   The branch (or git ref) where your changes are
implemented.
	 * @param   string  $body   The body text for the new pull request.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function create($user, $repo, $title, $base, $head, $body =
'')
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls';

		// Build the request data.
		$data = json_encode(
			array(
				'title' => $title,
				'base' => $base,
				'head' => $head,
				'body' => $body,
			)
		);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to create a pull request from an existing issue.
	 *
	 * @param   string   $user     The name of the owner of the GitHub
repository.
	 * @param   string   $repo     The name of the GitHub repository.
	 * @param   integer  $issueId  The issue number for which to attach the
new pull request.
	 * @param   string   $base     The branch (or git ref) you want your
changes pulled into. This
	 *                             should be an existing branch on the current
repository. You cannot
	 *                             submit a pull request to one repo that
requests a merge to a base
	 *                             of another repo.
	 * @param   string   $head     The branch (or git ref) where your changes
are implemented.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function createFromIssue($user, $repo, $issueId, $base, $head)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls';

		// Build the request data.
		$data = json_encode(
			array(
				'issue' => (int) $issueId,
				'base' => $base,
				'head' => $head,
			)
		);

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to update a pull request.
	 *
	 * @param   string   $user    The name of the owner of the GitHub
repository.
	 * @param   string   $repo    The name of the GitHub repository.
	 * @param   integer  $pullId  The pull request number.
	 * @param   string   $title   The optional new title for the pull request.
	 * @param   string   $body    The optional new body text for the pull
request.
	 * @param   string   $state   The optional new state for the pull request.
[open, closed]
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function edit($user, $repo, $pullId, $title = null, $body = null,
$state = null)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId;

		// Create the data object.
		$data = new stdClass;

		// If a title is set add it to the data object.
		if (isset($title))
		{
			$data->title = $title;
		}

		// If a body is set add it to the data object.
		if (isset($body))
		{
			$data->body = $body;
		}

		// If a state is set add it to the data object.
		if (isset($state))
		{
			$data->state = $state;
		}

		// Encode the request data.
		$data = json_encode($data);

		// Send the request.
		$response = $this->client->patch($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a single pull request.
	 *
	 * @param   string   $user    The name of the owner of the GitHub
repository.
	 * @param   string   $repo    The name of the GitHub repository.
	 * @param   integer  $pullId  The pull request number.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function get($user, $repo, $pullId)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a list of commits for a pull request.
	 *
	 * @param   string   $user    The name of the owner of the GitHub
repository.
	 * @param   string   $repo    The name of the GitHub repository.
	 * @param   integer  $pullId  The pull request number.
	 * @param   integer  $page    The page number from which to get items.
	 * @param   integer  $limit   The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getCommits($user, $repo, $pullId, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/commits';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a list of files for a pull request.
	 *
	 * @param   string   $user    The name of the owner of the GitHub
repository.
	 * @param   string   $repo    The name of the GitHub repository.
	 * @param   integer  $pullId  The pull request number.
	 * @param   integer  $page    The page number from which to get items.
	 * @param   integer  $limit   The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getFiles($user, $repo, $pullId, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/files';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to list pull requests.
	 *
	 * @param   string   $user   The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   string   $state  The optional state to filter requests by.
[open, closed]
	 * @param   integer  $page   The page number from which to get items.
	 * @param   integer  $limit  The number of items on a page.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  array
	 */
	public function getList($user, $repo, $state = 'open', $page =
0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls';

		// If a state exists append it as an option.
		if ($state != 'open')
		{
			$path .= '?state=' . $state;
		}

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to check if a pull request has been merged.
	 *
	 * @param   string   $user    The name of the owner of the GitHub
repository.
	 * @param   string   $repo    The name of the GitHub repository.
	 * @param   integer  $pullId  The pull request number.  The pull request
number.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  boolean  True if the pull request has been merged.
	 */
	public function isMerged($user, $repo, $pullId)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/merge';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code == 204)
		{
			return true;
		}
		elseif ($response->code == 404)
		{
			return false;
		}
		else
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}
	}

	/**
	 * Method to merge a pull request.
	 *
	 * @param   string   $user     The name of the owner of the GitHub
repository.
	 * @param   string   $repo     The name of the GitHub repository.
	 * @param   integer  $pullId   The pull request number.
	 * @param   string   $message  The message that will be used for the merge
commit.
	 *
	 * @throws DomainException
	 * @since   1.7.3
	 *
	 * @return  object
	 */
	public function merge($user, $repo, $pullId, $message = '')
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/pulls/' . (int) $pullId . '/merge';

		// Build the request data.
		$data = json_encode(
			array(
				'commit_message' => $message,
			)
		);

		// Send the request.
		$response = $this->client->put($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/*
	 * Legacy methods
	 */

	/**
	 * Method to create a comment on a pull request.
	 *
	 * @param   string   $user      The name of the owner of the GitHub
repository.
	 * @param   string   $repo      The name of the GitHub repository.
	 * @param   integer  $pullId    The pull request number.
	 * @param   string   $body      The comment body text.
	 * @param   string   $commitId  The SHA1 hash of the commit to comment on.
	 * @param   string   $filePath  The Relative path of the file to comment
on.
	 * @param   string   $position  The line index in the diff to comment on.
	 *
	 * @deprecated  use pulls->comments->create()
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function createComment($user, $repo, $pullId, $body, $commitId,
$filePath, $position)
	{
		return $this->comments->create($user, $repo, $pullId, $body,
$commitId, $filePath, $position);
	}

	/**
	 * Method to create a comment in reply to another comment.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $pullId     The pull request number.
	 * @param   string   $body       The comment body text.
	 * @param   integer  $inReplyTo  The id of the comment to reply to.
	 *
	 * @deprecated  use pulls->comments->createReply()
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function createCommentReply($user, $repo, $pullId, $body,
$inReplyTo)
	{
		return $this->comments->createReply($user, $repo, $pullId, $body,
$inReplyTo);
	}

	/**
	 * Method to delete a comment on a pull request.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The id of the comment to delete.
	 *
	 * @deprecated  use pulls->comments->delete()
	 *
	 * @return  void
	 *
	 * @since   1.7.3
	 */
	public function deleteComment($user, $repo, $commentId)
	{
		$this->comments->delete($user, $repo, $commentId);
	}

	/**
	 * Method to update a comment on a pull request.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The id of the comment to update.
	 * @param   string   $body       The new body text for the comment.
	 *
	 * @deprecated  use pulls->comments->edit()
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function editComment($user, $repo, $commentId, $body)
	{
		return $this->comments->edit($user, $repo, $commentId, $body);
	}

	/**
	 * Method to get a specific comment on a pull request.
	 *
	 * @param   string   $user       The name of the owner of the GitHub
repository.
	 * @param   string   $repo       The name of the GitHub repository.
	 * @param   integer  $commentId  The comment id to get.
	 *
	 * @deprecated  use pulls->comments->get()
	 *
	 * @return  object
	 *
	 * @since   1.7.3
	 */
	public function getComment($user, $repo, $commentId)
	{
		return $this->comments->get($user, $repo, $commentId);
	}

	/**
	 * Method to get the list of comments on a pull request.
	 *
	 * @param   string   $user    The name of the owner of the GitHub
repository.
	 * @param   string   $repo    The name of the GitHub repository.
	 * @param   integer  $pullId  The pull request number.
	 * @param   integer  $page    The page number from which to get items.
	 * @param   integer  $limit   The number of items on a page.
	 *
	 * @deprecated  use pulls->comments->getList()
	 *
	 * @return  array
	 *
	 * @since   1.7.3
	 */
	public function getComments($user, $repo, $pullId, $page = 0, $limit = 0)
	{
		return $this->comments->getList($user, $repo, $pullId, $page,
$limit);
	}
}
repositories/collaborators.php000064400000006073151156262630012667
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Repositories Collaborators class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/repos/collaborators
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesCollaborators extends JGithubPackage
{
	/**
	 * List.
	 *
	 * When authenticating as an organization owner of an organization-owned
repository, all organization
	 * owners are included in the list of collaborators. Otherwise, only users
with access to the repository
	 * are returned in the collaborators list.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getList($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/collaborators';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Test if a user is a collaborator.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $user   The name of the GitHub user.
	 *
	 * @throws UnexpectedValueException
	 * @since 3.3 (CMS)
	 *
	 * @return boolean
	 */
	public function get($owner, $repo, $user)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/collaborators/' . $user;

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case '204';

				return true;
				break;
			case '404';

				return false;
				break;
			default;
				throw new UnexpectedValueException('Unexpected code: ' .
$response->code);
				break;
		}
	}

	/**
	 * Add collaborator.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $user   The name of the GitHub user.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function add($owner, $repo, $user)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/collaborators/' . $user;

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), ''),
			204
		);
	}

	/**
	 * Remove collaborator.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $user   The name of the GitHub user.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function remove($owner, $repo, $user)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/collaborators/' . $user;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
repositories/comments.php000064400000011512151156262630011640
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Repositories Comments class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/repos/comments
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesComments extends JGithubPackage
{
	/**
	 * Method to get a list of commit comments for a repository.
	 *
	 * @param   string   $user   The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   integer  $page   Page to request
	 * @param   integer  $limit  Number of results to return per page
	 *
	 * @return  array
	 *
	 * @since   3.0.0
	 */
	public function getListRepository($user, $repo, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/comments';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path, $page, $limit))
		);
	}

	/**
	 * Method to get a list of comments for a single commit for a repository.
	 *
	 * @param   string   $user   The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   string   $sha    The SHA of the commit to retrieve.
	 * @param   integer  $page   Page to request
	 * @param   integer  $limit  Number of results to return per page
	 *
	 * @return  array
	 *
	 * @since   3.0.0
	 */
	public function getList($user, $repo, $sha, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha . '/comments';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path, $page, $limit))
		);
	}

	/**
	 * Method to get a single comment on a commit.
	 *
	 * @param   string   $user  The name of the owner of the GitHub
repository.
	 * @param   string   $repo  The name of the GitHub repository.
	 * @param   integer  $id    ID of the comment to retrieve
	 *
	 * @return  array
	 *
	 * @since   3.0.0
	 */
	public function get($user, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/comments/' . (int) $id;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Method to edit a comment on a commit.
	 *
	 * @param   string  $user     The name of the owner of the GitHub
repository.
	 * @param   string  $repo     The name of the GitHub repository.
	 * @param   string  $id       The ID of the comment to edit.
	 * @param   string  $comment  The text of the comment.
	 *
	 * @return  object
	 *
	 * @since   3.0.0
	 */
	public function edit($user, $repo, $id, $comment)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/comments/' . $id;

		$data = json_encode(
			array(
				'body' => $comment,
			)
		);

		// Send the request.
		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path), $data)
		);
	}

	/**
	 * Method to delete a comment on a commit.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 * @param   string  $id    The ID of the comment to edit.
	 *
	 * @return  object
	 *
	 * @since   3.0.0
	 */
	public function delete($user, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/comments/' . $id;

		// Send the request.
		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}

	/**
	 * Method to create a comment on a commit.
	 *
	 * @param   string   $user      The name of the owner of the GitHub
repository.
	 * @param   string   $repo      The name of the GitHub repository.
	 * @param   string   $sha       The SHA of the commit to comment on.
	 * @param   string   $comment   The text of the comment.
	 * @param   integer  $line      The line number of the commit to comment
on.
	 * @param   string   $filepath  A relative path to the file to comment on
within the commit.
	 * @param   integer  $position  Line index in the diff to comment on.
	 *
	 * @return  object
	 *
	 * @since   3.0.0
	 */
	public function create($user, $repo, $sha, $comment, $line, $filepath,
$position)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha . '/comments';

		$data = json_encode(
			array(
				'body' => $comment,
				'path' => $filepath,
				'position' => (int) $position,
				'line' => (int) $line,
			)
		);

		// Send the request.
		return $this->processResponse(
			$this->client->post($this->fetchUrl($path), $data),
			201
		);
	}
}
repositories/commits.php000064400000007474151156262630011502
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Repositories Commits class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/repos/commits
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesCommits extends JGithubPackage
{
	/**
	 * Method to list commits for a repository.
	 *
	 * A special note on pagination: Due to the way Git works, commits are
paginated based on SHA
	 * instead of page number.
	 * Please follow the link headers as outlined in the pagination overview
instead of constructing
	 * page links yourself.
	 *
	 * @param   string  $user    The name of the owner of the GitHub
repository.
	 * @param   string  $repo    The name of the GitHub repository.
	 * @param   string  $sha     Sha or branch to start listing commits from.
	 * @param   string  $path    Only commits containing this file path will
be returned.
	 * @param   string  $author  GitHub login, name, or email by which to
filter by commit author.
	 * @param   JDate   $since   ISO 8601 Date - Only commits after this date
will be returned.
	 * @param   JDate   $until   ISO 8601 Date - Only commits before this date
will be returned.
	 *
	 * @throws DomainException
	 * @since    3.0.0
	 *
	 * @return  array
	 */
	public function getList($user, $repo, $sha = '', $path =
'', $author = '', JDate $since = null, JDate $until =
null)
	{
		// Build the request path.
		$rPath = '/repos/' . $user . '/' . $repo .
'/commits?';

		$rPath .= ($sha) ? '&sha=' . $sha : '';
		$rPath .= ($path) ? '&path=' . $path : '';
		$rPath .= ($author) ? '&author=' . $author : '';
		$rPath .= ($since) ? '&since=' . $since->toISO8601() :
'';
		$rPath .= ($until) ? '&until=' . $until->toISO8601() :
'';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($rPath));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a single commit for a repository.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 * @param   string  $sha   The SHA of the commit to retrieve.
	 *
	 * @throws DomainException
	 * @since   3.0.0
	 *
	 * @return  array
	 */
	public function get($user, $repo, $sha)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/commits/' . $sha;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to get a diff for two commits.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 * @param   string  $base  The base of the diff, either a commit SHA or
branch.
	 * @param   string  $head  The head of the diff, either a commit SHA or
branch.
	 *
	 * @return  array
	 *
	 * @since   3.0.0
	 */
	public function compare($user, $repo, $base, $head)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/compare/' . $base . '...' . $head;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}
}
repositories/contents.php000064400000012760151156262630011656
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Repositories Contents class for the Joomla Platform.
 *
 * These API methods let you retrieve the contents of files within a
repository as Base64 encoded content.
 * See media types for requesting raw or other formats.
 *
 * @documentation https://developer.github.com/v3/repos/contents
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesContents extends JGithubPackage
{
	/**
	 * Get the README
	 *
	 * This method returns the preferred README for a repository.
	 *
	 * GET /repos/:owner/:repo/readme
	 *
	 * Parameters
	 *
	 * ref
	 * Optional string - The String name of the Commit/Branch/Tag. Defaults to
master.
	 *
	 * Response
	 *
	 * Status: 200 OK
	 * X-RateLimit-Limit: 5000
	 * X-RateLimit-Remaining: 4999
	 *
	 * {
	 * "type": "file",
	 * "encoding": "base64",
	 * "_links": {
	 * "git":
"https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
	 * "self":
"https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
	 * "html":
"https://github.com/octokit/octokit.rb/blob/master/README.md"
	 * },
	 * "size": 5362,
	 * "name": "README.md",
	 * "path": "README.md",
	 * "content": "encoded content ...",
	 * "sha": "3d21ec53a331a6f037a91c368710b99387d012c1"
	 * }
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $ref    The String name of the Commit/Branch/Tag.
Defaults to master.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getReadme($owner, $repo, $ref = '')
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/readme';

		if ($ref)
		{
			$path .= '?ref=' . $ref;
		}

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get contents
	 *
	 * This method returns the contents of any file or directory in a
repository.
	 *
	 * GET /repos/:owner/:repo/contents/:path
	 *
	 * Parameters
	 *
	 * path
	 * Optional string - The content path.
	 * ref
	 * Optional string - The String name of the Commit/Branch/Tag. Defaults to
master.
	 *
	 * Response
	 *
	 * Status: 200 OK
	 * X-RateLimit-Limit: 5000
	 * X-RateLimit-Remaining: 4999
	 *
	 * {
	 * "type": "file",
	 * "encoding": "base64",
	 * "_links": {
	 * "git":
"https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1",
	 * "self":
"https://api.github.com/repos/octokit/octokit.rb/contents/README.md",
	 * "html":
"https://github.com/octokit/octokit.rb/blob/master/README.md"
	 * },
	 * "size": 5362,
	 * "name": "README.md",
	 * "path": "README.md",
	 * "content": "encoded content ...",
	 * "sha": "3d21ec53a331a6f037a91c368710b99387d012c1"
	 * }
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $path   The content path.
	 * @param   string  $ref    The String name of the Commit/Branch/Tag.
Defaults to master.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function get($owner, $repo, $path, $ref = '')
	{
		// Build the request path.
		$rPath = '/repos/' . $owner . '/' . $repo .
'/contents/' . $path;

		if ($ref)
		{
			$rPath .= '?ref=' . $ref;
		}

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($rPath))
		);
	}

	/**
	 * Get archive link
	 *
	 * This method will return a 302 to a URL to download a tarball or zipball
archive for a repository.
	 * Please make sure your HTTP framework is configured to follow redirects
or you will need to use the Location header to make a second GET request.
	 *
	 * Note: For private repositories, these links are temporary and expire
quickly.
	 *
	 * GET /repos/:owner/:repo/:archive_format/:ref
	 *
	 * Parameters
	 *
	 * archive_format
	 * Either tarball or zipball
	 * ref
	 * Optional string - valid Git reference, defaults to master
	 *
	 * Response
	 *
	 * Status: 302 Found
	 * Location:
http://github.com/me/myprivate/tarball/master?SSO=thistokenexpires
	 * X-RateLimit-Limit: 5000
	 * X-RateLimit-Remaining: 4999
	 *
	 * To follow redirects with curl, use the -L switch:
	 *
	 * curl -L https://api.github.com/repos/octokit/octokit.rb/tarball >
octokit.tar.gz
	 *
	 * @param   string  $owner          The name of the owner of the GitHub
repository.
	 * @param   string  $repo           The name of the GitHub repository.
	 * @param   string  $archiveFormat  Either tarball or zipball.
	 * @param   string  $ref            The String name of the
Commit/Branch/Tag. Defaults to master.
	 *
	 * @throws UnexpectedValueException
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getArchiveLink($owner, $repo, $archiveFormat =
'zipball', $ref = '')
	{
		if (false == in_array($archiveFormat, array('tarball',
'zipball')))
		{
			throw new UnexpectedValueException('Archive format must be either
"tarball" or "zipball".');
		}

		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/' . $archiveFormat;

		if ($ref)
		{
			$path .= '?ref=' . $ref;
		}

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path)),
			302
		);
	}
}
repositories/downloads.php000064400000014204151156262630012006
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Repositories Downloads class for the Joomla Platform.
 *
 * The downloads API is for package downloads only.
 * If you want to get source tarballs you should use
 * https://developer.github.com/v3/repos/contents/#get-archive-link
instead.
 *
 * @documentation https://developer.github.com/v3/repos/downloads
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesDownloads extends JGithubPackage
{
	/**
	 * List downloads for a repository.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function getList($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/downloads';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get a single download.
	 *
	 * @param   string   $owner  The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   integer  $id     The id of the download.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function get($owner, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/downloads/' . $id;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Create a new download (Part 1: Create the resource).
	 *
	 * Creating a new download is a two step process. You must first create a
new download resource.
	 *
	 * @param   string  $owner        The name of the owner of the GitHub
repository.
	 * @param   string  $repo         The name of the GitHub repository.
	 * @param   string  $name         The name.
	 * @param   string  $size         Size of file in bytes.
	 * @param   string  $description  The description.
	 * @param   string  $contentType  The content type.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function create($owner, $repo, $name, $size, $description =
'', $contentType = '')
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/downloads';

		$data = array(
			'name' => $name,
			'size' => $size,
		);

		if ($description)
		{
			$data['description'] = $description;
		}

		if ($contentType)
		{
			$data['content_type'] = $contentType;
		}

		// Send the request.
		return $this->processResponse(
			$this->client->post($this->fetchUrl($path), $data),
			201
		);
	}

	/**
	 * Create a new download (Part 2: Upload file to s3).
	 *
	 * Now that you have created the download resource, you can use the
information
	 * in the response to upload your file to s3. This can be done with a POST
to
	 * the s3_url you got in the create response. Here is a brief example
using curl:
	 *
	 * curl \
	 *     -F "key=downloads/octocat/Hello-World/new_file.jpg" \
	 *     -F "acl=public-read" \
	 *     -F "success_action_status=201" \
	 *     -F "Filename=new_file.jpg" \
	 *     -F "AWSAccessKeyId=1ABCDEF..." \
	 *     -F "Policy=ewogIC..." \
	 *     -F "Signature=mwnF..." \
	 *     -F "Content-Type=image/jpeg" \
	 *     -F "file=@new_file.jpg" \
	 *           https://github.s3.amazonaws.com/
	 *
	 * NOTES
	 * The order in which you pass these fields matters! Follow the order
shown above exactly.
	 * All parameters shown are required and if you excluded or modify them
your upload will
	 * fail because the values are hashed and signed by the policy.
	 *
	 * More information about using the REST API to interact with s3 can be
found here:
	 * http://docs.amazonwebservices.com/AmazonS3/latest/API/
	 *
	 * @param   string  $key                  Value of path field in the
response.
	 * @param   string  $acl                  Value of acl field in the
response.
	 * @param   string  $successActionStatus  201, or whatever you want to get
back.
	 * @param   string  $filename             Value of name field in the
response.
	 * @param   string  $awsAccessKeyId       Value of accesskeyid field in
the response.
	 * @param   string  $policy               Value of policy field in the
response.
	 * @param   string  $signature            Value of signature field in the
response.
	 * @param   string  $contentType          Value of mime_type field in the
response.
	 * @param   string  $file                 Local file. Example assumes the
file existing in the directory
	 *                                        where you are running the curl
command. Yes, the @ matters.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return boolean
	 */
	public function upload($key, $acl, $successActionStatus, $filename,
$awsAccessKeyId, $policy, $signature, $contentType, $file)
	{
		// Build the request path.
		$url = 'https://github.s3.amazonaws.com/';

		$data = array(
			'key'                   => $key,
			'acl'                   => $acl,
			'success_action_status' => (int) $successActionStatus,
			'Filename'              => $filename,
			'AWSAccessKeyId'        => $awsAccessKeyId,
			'Policy'                => $policy,
			'Signature'             => $signature,
			'Content-Type'          => $contentType,
			'file'                  => $file,
		);

		// Send the request.
		$response = $this->client->post($url, $data);

		// @todo Process the response..

		return (201 == $response->code) ? true : false;
	}

	/**
	 * Delete a download.
	 *
	 * @param   string   $owner  The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   integer  $id     The id of the download.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function delete($owner, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/downloads/' . (int) $id;

		// Send the request.
		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
repositories/forks.php000064400000004664151156262630011151 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Forks class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/repos/forks
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesForks extends JGithubPackage
{
	/**
	 * Method to fork a repository.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 * @param   string  $org   The organization to fork the repo into. By
default it is forked to the current user.
	 *
	 * @return  object
	 *
	 * @since   2.5.0
	 * @throws  DomainException
	 */
	public function create($user, $repo, $org = '')
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/forks';

		if (strlen($org) > 0)
		{
			$data = json_encode(
				array('org' => $org)
			);
		}
		else
		{
			$data = json_encode(array());
		}

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path), $data);

		// Validate the response code.
		if ($response->code != 202)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to list forks for a repository.
	 *
	 * @param   string   $user   The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   integer  $page   Page to request
	 * @param   integer  $limit  Number of results to return per page
	 *
	 * @return  array
	 *
	 * @since   2.5.0
	 * @throws  DomainException
	 */
	public function getList($user, $repo, $page = 0, $limit = 0)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/forks';

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path, $page,
$limit));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}
}
repositories/hooks.php000064400000014347151156262630011147 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Hooks class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/repos/hooks
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesHooks extends JGithubPackage
{
	/**
	 * Array containing the allowed hook events
	 *
	 * @var    array
	 * @since  3.1.4
	 */
	protected $events = array(
		'push',
		'issues',
		'issue_comment',
		'commit_comment',
		'pull_request',
		'gollum',
		'watch',
		'download',
		'fork',
		'fork_apply',
		'member',
		'public',
		'status',
	);

	/**
	 * Method to create a hook on a repository.
	 *
	 * @param   string   $user    The name of the owner of the GitHub
repository.
	 * @param   string   $repo    The name of the GitHub repository.
	 * @param   string   $name    The name of the service being called.
	 * @param   array    $config  Array containing the config for the service.
	 * @param   array    $events  The events the hook will be triggered for.
	 * @param   boolean  $active  Flag to determine if the hook is active
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 * @throws  DomainException
	 * @throws  RuntimeException
	 */
	public function create($user, $repo, $name, $config, array $events =
array('push'), $active = true)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/hooks';

		// Check to ensure all events are in the allowed list
		foreach ($events as $event)
		{
			if (!in_array($event, $this->events))
			{
				throw new RuntimeException('Your events array contains an
unauthorized event.');
			}
		}

		$data = json_encode(
			array('name' => $name, 'config' => $config,
'events' => $events, 'active' => $active)
		);

		return $this->processResponse(
			$this->client->post($this->fetchUrl($path), $data),
			201
		);
	}

	/**
	 * Method to delete a hook
	 *
	 * @param   string   $user  The name of the owner of the GitHub
repository.
	 * @param   string   $repo  The name of the GitHub repository.
	 * @param   integer  $id    ID of the hook to delete.
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 * @throws  DomainException
	 */
	public function delete($user, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}

	/**
	 * Method to edit a hook.
	 *
	 * @param   string   $user          The name of the owner of the GitHub
repository.
	 * @param   string   $repo          The name of the GitHub repository.
	 * @param   integer  $id            ID of the hook to edit.
	 * @param   string   $name          The name of the service being called.
	 * @param   array    $config        Array containing the config for the
service.
	 * @param   array    $events        The events the hook will be triggered
for.  This resets the currently set list
	 * @param   array    $addEvents     Events to add to the hook.
	 * @param   array    $removeEvents  Events to remove from the hook.
	 * @param   boolean  $active        Flag to determine if the hook is
active
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 * @throws  DomainException
	 * @throws  RuntimeException
	 */
	public function edit($user, $repo, $id, $name, $config, array $events =
array('push'), array $addEvents = array(),
		array $removeEvents = array(), $active = true)
	{
		// Check to ensure all events are in the allowed list
		foreach ($events as $event)
		{
			if (!in_array($event, $this->events))
			{
				throw new RuntimeException('Your events array contains an
unauthorized event.');
			}
		}

		foreach ($addEvents as $event)
		{
			if (!in_array($event, $this->events))
			{
				throw new RuntimeException('Your active_events array contains an
unauthorized event.');
			}
		}

		foreach ($removeEvents as $event)
		{
			if (!in_array($event, $this->events))
			{
				throw new RuntimeException('Your remove_events array contains an
unauthorized event.');
			}
		}

		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;

		$data = json_encode(
			array(
				'name'          => $name,
				'config'        => $config,
				'events'        => $events,
				'add_events'    => $addEvents,
				'remove_events' => $removeEvents,
				'active'        => $active,
			)
		);

		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path), $data)
		);
	}

	/**
	 * Method to get details about a single hook for the repository.
	 *
	 * @param   string   $user  The name of the owner of the GitHub
repository.
	 * @param   string   $repo  The name of the GitHub repository.
	 * @param   integer  $id    ID of the hook to retrieve
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 * @throws  DomainException
	 */
	public function get($user, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Method to list hooks for a repository.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 * @throws  DomainException
	 */
	public function getList($user, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/hooks';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Method to test a hook against the latest repository commit
	 *
	 * @param   string   $user  The name of the owner of the GitHub
repository.
	 * @param   string   $repo  The name of the GitHub repository.
	 * @param   integer  $id    ID of the hook to delete
	 *
	 * @return  object
	 *
	 * @since   3.1.4
	 * @throws  DomainException
	 */
	public function test($user, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/hooks/' . $id . '/test';

		return $this->processResponse(
			$this->client->post($this->fetchUrl($path),
json_encode('')),
			204
		);
	}
}
repositories/keys.php000064400000006367151156262630011002 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Forks class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/repos/keys
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesKeys extends JGithubPackage
{
	/**
	 * List keys in a repository.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 *
	 * @since 3.3.0
	 *
	 * @return object
	 */
	public function getList($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/keys';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get a key.
	 *
	 * @param   string   $owner  The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   integer  $id     The id of the key.
	 *
	 * @since 3.3.0
	 *
	 * @return object
	 */
	public function get($owner, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/keys/' . (int) $id;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Create a key.
	 *
	 * @param   string  $owner  The name of the owner of the GitHub
repository.
	 * @param   string  $repo   The name of the GitHub repository.
	 * @param   string  $title  The key title.
	 * @param   string  $key    The key.
	 *
	 * @since 3.3.0
	 *
	 * @return object
	 */
	public function create($owner, $repo, $title, $key)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/keys';

		$data = array(
			'title' => $title,
			'key'   => $key,
		);

		return $this->processResponse(
			$this->client->post($this->fetchUrl($path),
json_encode($data)),
			201
		);
	}

	/**
	 * Edit a key.
	 *
	 * @param   string   $owner  The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   integer  $id     The id of the key.
	 * @param   string   $title  The key title.
	 * @param   string   $key    The key.
	 *
	 * @since 3.3.0
	 *
	 * @return object
	 */
	public function edit($owner, $repo, $id, $title, $key)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/keys/' . (int) $id;

		$data = array(
			'title' => $title,
			'key'   => $key,
		);

		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path),
json_encode($data))
		);
	}

	/**
	 * Delete a key.
	 *
	 * @param   string   $owner  The name of the owner of the GitHub
repository.
	 * @param   string   $repo   The name of the GitHub repository.
	 * @param   integer  $id     The id of the key.
	 *
	 * @since 3.3.0
	 *
	 * @return boolean
	 */
	public function delete($owner, $repo, $id)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/keys/' . (int) $id;

		$this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);

		return true;
	}
}
repositories/merging.php000064400000004761151156262630011453
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Repositories Merging class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/repos/merging
 *
 * @since       1.7.3
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesMerging extends JGithubPackage
{
	/**
	 * Perform a merge.
	 *
	 * @param   string  $owner          The name of the owner of the GitHub
repository.
	 * @param   string  $repo           The name of the GitHub repository.
	 * @param   string  $base           The name of the base branch that the
head will be merged into.
	 * @param   string  $head           The head to merge. This can be a
branch name or a commit SHA1.
	 * @param   string  $commitMessage  Commit message to use for the merge
commit.
	 *                                  If omitted, a default message will be
used.
	 *
	 * @throws UnexpectedValueException
	 * @since   3.3.0
	 *
	 * @return  boolean
	 */
	public function perform($owner, $repo, $base, $head, $commitMessage =
'')
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/merges';

		$data = new stdClass;

		$data->base = $base;
		$data->head = $head;

		if ($commitMessage)
		{
			$data->commit_message = $commitMessage;
		}

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path),
json_encode($data));

		switch ($response->code)
		{
			case '201':
				// Success
				return json_decode($response->body);
				break;

			case '204':
				// No-op response (base already contains the head, nothing to merge)
				throw new UnexpectedValueException('Nothing to merge');
				break;

			case '404':
				// Missing base or Missing head response
				$error = json_decode($response->body);

				$message = (isset($error->message)) ? $error->message :
'Missing base or head: ' . $response->code;

				throw new UnexpectedValueException($message);
				break;

			case '409':
				// Merge conflict response
				$error = json_decode($response->body);

				$message = (isset($error->message)) ? $error->message :
'Merge conflict ' . $response->code;

				throw new UnexpectedValueException($message);
				break;

			default :
				throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
				break;
		}
	}
}
repositories/statistics.php000064400000011526151156262630012212
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API class for the Joomla Platform.
 *
 * The Repository Statistics API allows you to fetch the data that GitHub
uses for
 * visualizing different types of repository activity.
 *
 * @documentation https://developer.github.com/v3/repos/statistics
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesStatistics  extends JGithubPackage
{
	/**
	 * Get contributors list with additions, deletions, and commit counts.
	 *
	 * Response include:
	 * total - The Total number of commits authored by the contributor.
	 *
	 * Weekly Hash
	 *
	 * w - Start of the week
	 * a - Number of additions
	 * d - Number of deletions
	 * c - Number of commits
	 *
	 * @param   string  $owner  The owner of the repository.
	 * @param   string  $repo   The repository name.
	 *
	 * @since   1.0
	 *
	 * @return  object
	 */
	public function getListContributors($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/stats/contributors';

		// Send the request.
		return
$this->processResponse($this->client->get($this->fetchUrl($path)));
	}

	/**
	 * Get the last year of commit activity data.
	 *
	 * Returns the last year of commit activity grouped by week.
	 * The days array is a group of commits per day, starting on Sunday.
	 *
	 * @param   string  $owner  The owner of the repository.
	 * @param   string  $repo   The repository name.
	 *
	 * @since   1.0
	 *
	 * @return  object
	 */
	public function getActivityData($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/stats/commit_activity';

		// Send the request.
		return
$this->processResponse($this->client->get($this->fetchUrl($path)));
	}

	/**
	 * Get the number of additions and deletions per week.
	 *
	 * Response returns a weekly aggregate of the number of additions and
deletions pushed to a repository.
	 *
	 * @param   string  $owner  The owner of the repository.
	 * @param   string  $repo   The repository name.
	 *
	 * @since   1.0
	 *
	 * @return  object
	 */
	public function getCodeFrequency($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/stats/code_frequency';

		// Send the request.
		return
$this->processResponse($this->client->get($this->fetchUrl($path)));
	}

	/**
	 * Get the weekly commit count for the repo owner and everyone else.
	 *
	 * Returns the total commit counts for the "owner" and total
commit counts in "all". "all" is everyone combined,
	 * including the owner in the last 52 weeks.
	 * If you’d like to get the commit counts for non-owners, you can
subtract all from owner.
	 *
	 * The array order is oldest week (index 0) to most recent week.
	 *
	 * @param   string  $owner  The owner of the repository.
	 * @param   string  $repo   The repository name.
	 *
	 * @since   1.0
	 *
	 * @return  object
	 */
	public function getParticipation($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/stats/participation';

		// Send the request.
		return
$this->processResponse($this->client->get($this->fetchUrl($path)));
	}

	/**
	 * Get the number of commits per hour in each day.
	 *
	 * Response
	 * Each array contains the day number, hour number, and number of commits:
	 *
	 * 0-6: Sunday - Saturday
	 * 0-23: Hour of day
	 * Number of commits
	 *
	 * For example, [2, 14, 25] indicates that there were 25 total commits,
during the 2:00pm hour on Tuesdays.
	 * All times are based on the time zone of individual commits.
	 *
	 * @param   string  $owner  The owner of the repository.
	 * @param   string  $repo   The repository name.
	 *
	 * @since   1.0
	 *
	 * @return  object
	 */
	public function getPunchCard($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/stats/punch_card';

		// Send the request.
		return
$this->processResponse($this->client->get($this->fetchUrl($path)));
	}

	/**
	 * Process the response and decode it.
	 *
	 * @param   JHttpResponse  $response      The response.
	 * @param   integer        $expectedCode  The expected "good"
code.
	 * @param   boolean        $decode        If the should be response be
JSON decoded.
	 *
	 * @return  mixed
	 *
	 * @since   1.0
	 * @throws  \DomainException
	 */
	protected function processResponse(JHttpResponse $response, $expectedCode
= 200, $decode = true)
	{
		if (202 == $response->code)
		{
			throw new \DomainException(
				'GitHub is building the statistics data. Please try again in a few
moments.',
				$response->code
			);
		}

		return parent::processResponse($response, $expectedCode, $decode);
	}
}
repositories/statuses.php000064400000005616151156262630011676
0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API References class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/repos/statuses
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageRepositoriesStatuses extends JGithubPackage
{
	/**
	 * Method to create a status.
	 *
	 * @param   string  $user         The name of the owner of the GitHub
repository.
	 * @param   string  $repo         The name of the GitHub repository.
	 * @param   string  $sha          The SHA1 value for which to set the
status.
	 * @param   string  $state        The state (pending, success, error or
failure).
	 * @param   string  $targetUrl    Optional target URL.
	 * @param   string  $description  Optional description for the status.
	 *
	 * @throws InvalidArgumentException
	 * @throws DomainException
	 *
	 * @since   3.1.4
	 *
	 * @return  object
	 */
	public function create($user, $repo, $sha, $state, $targetUrl = null,
$description = null)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/statuses/' . $sha;

		if (!in_array($state, array('pending', 'success',
'error', 'failure')))
		{
			throw new InvalidArgumentException('State must be one of pending,
success, error or failure.');
		}

		// Build the request data.
		$data = array(
			'state' => $state,
		);

		if (!is_null($targetUrl))
		{
			$data['target_url'] = $targetUrl;
		}

		if (!is_null($description))
		{
			$data['description'] = $description;
		}

		// Send the request.
		$response = $this->client->post($this->fetchUrl($path),
json_encode($data));

		// Validate the response code.
		if ($response->code != 201)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}

	/**
	 * Method to list statuses for an SHA.
	 *
	 * @param   string  $user  The name of the owner of the GitHub repository.
	 * @param   string  $repo  The name of the GitHub repository.
	 * @param   string  $sha   SHA1 for which to get the statuses.
	 *
	 * @return  array
	 *
	 * @since   3.1.4
	 */
	public function getList($user, $repo, $sha)
	{
		// Build the request path.
		$path = '/repos/' . $user . '/' . $repo .
'/statuses/' . $sha;

		// Send the request.
		$response = $this->client->get($this->fetchUrl($path));

		// Validate the response code.
		if ($response->code != 200)
		{
			// Decode the error response and throw an exception.
			$error = json_decode($response->body);
			throw new DomainException($error->message, $response->code);
		}

		return json_decode($response->body);
	}
}
repositories.php000064400000032373151156262630010023 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Activity class for the Joomla Platform.
 *
 * @since       3.3 (CMS)
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 *
 * @documentation  https://developer.github.com/v3/repos
 *
 * @property-read  JGithubPackageRepositoriesCollaborators  $collaborators 
GitHub API object for collaborators.
 * @property-read  JGithubPackageRepositoriesComments       $comments      
GitHub API object for comments.
 * @property-read  JGithubPackageRepositoriesCommits        $commits       
GitHub API object for commits.
 * @property-read  JGithubPackageRepositoriesContents       $contents      
GitHub API object for contents.
 * @property-read  JGithubPackageRepositoriesDownloads      $downloads     
GitHub API object for downloads.
 * @property-read  JGithubPackageRepositoriesForks          $forks         
GitHub API object for forks.
 * @property-read  JGithubPackageRepositoriesHooks          $hooks         
GitHub API object for hooks.
 * @property-read  JGithubPackageRepositoriesKeys           $keys          
GitHub API object for keys.
 * @property-read  JGithubPackageRepositoriesMerging        $merging       
GitHub API object for merging.
 * @property-read  JGithubPackageRepositoriesStatuses       $statuses      
GitHub API object for statuses.
 */
class JGithubPackageRepositories extends JGithubPackage
{
	protected $name = 'Repositories';

	protected $packages = array('collaborators',
'comments', 'commits', 'contents',
'downloads', 'forks', 'hooks',
'keys', 'merging', 'statuses');

	/**
	 * List your repositories.
	 *
	 * List repositories for the authenticated user.
	 *
	 * @param   string  $type       Sort type. all, owner, public, private,
member. Default: all.
	 * @param   string  $sort       Sort field. created, updated, pushed,
full_name, default: full_name.
	 * @param   string  $direction  Sort direction. asc or desc, default: when
using full_name: asc, otherwise desc.
	 *
	 * @throws RuntimeException
	 *
	 * @return object
	 */
	public function getListOwn($type = 'all', $sort =
'full_name', $direction = '')
	{
		if (false == in_array($type, array('all', 'owner',
'public', 'private', 'member')))
		{
			throw new RuntimeException('Invalid type');
		}

		if (false == in_array($sort, array('created',
'updated', 'pushed', 'full_name')))
		{
			throw new RuntimeException('Invalid sort field');
		}

		// Sort direction default: when using full_name: asc, otherwise desc.
		$direction = ($direction) ? : (('full_name' == $sort) ?
'asc' : 'desc');

		if (false == in_array($direction, array('asc',
'desc')))
		{
			throw new RuntimeException('Invalid sort order');
		}

		// Build the request path.
		$path = '/user/repos'
			. '?type=' . $type
			. '&sort=' . $sort
			. '&direction=' . $direction;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List user repositories.
	 *
	 * List public repositories for the specified user.
	 *
	 * @param   string  $user       The user name.
	 * @param   string  $type       Sort type. all, owner, member. Default:
all.
	 * @param   string  $sort       Sort field. created, updated, pushed,
full_name, default: full_name.
	 * @param   string  $direction  Sort direction. asc or desc, default: when
using full_name: asc, otherwise desc.
	 *
	 * @throws RuntimeException
	 *
	 * @return object
	 */
	public function getListUser($user, $type = 'all', $sort =
'full_name', $direction = '')
	{
		if (false == in_array($type, array('all', 'owner',
'member')))
		{
			throw new RuntimeException('Invalid type');
		}

		if (false == in_array($sort, array('created',
'updated', 'pushed', 'full_name')))
		{
			throw new RuntimeException('Invalid sort field');
		}

		// Sort direction default: when using full_name: asc, otherwise desc.
		$direction = ($direction) ? : (('full_name' == $sort) ?
'asc' : 'desc');

		if (false == in_array($direction, array('asc',
'desc')))
		{
			throw new RuntimeException('Invalid sort order');
		}

		// Build the request path.
		$path = '/users/' . $user . '/repos'
			. '?type=' . $type
			. '&sort=' . $sort
			. '&direction=' . $direction;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List organization repositories.
	 *
	 * List repositories for the specified org.
	 *
	 * @param   string  $org   The name of the organization.
	 * @param   string  $type  Sort type. all, public, private, forks,
sources, member. Default: all.
	 *
	 * @throws RuntimeException
	 *
	 * @return object
	 */
	public function getListOrg($org, $type = 'all')
	{
		if (false == in_array($type, array('all', 'public',
'private', 'forks', 'sources',
'member')))
		{
			throw new RuntimeException('Invalid type');
		}

		// Build the request path.
		$path = '/orgs/' . $org . '/repos'
			. '?type=' . $type;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List all repositories.
	 *
	 * This provides a dump of every repository, in the order that they were
created.
	 *
	 * @param   integer  $id  The integer ID of the last Repository that
you’ve seen.
	 *
	 * @throws RuntimeException
	 *
	 * @return object
	 */
	public function getList($id = 0)
	{
		// Build the request path.
		$path = '/repositories';
		$path .= ($id) ? '?since=' . (int) $id : '';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Create a new repository for the authenticated user or an organization.
	 * OAuth users must supply repo scope.
	 *
	 * @param   string   $name               The repository name.
	 * @param   string   $org                The organization name (if
needed).
	 * @param   string   $description        The repository description.
	 * @param   string   $homepage           The repository homepage.
	 * @param   boolean  $private            Set true to create a private
repository, false to create a public one.
	 *                                       Creating private repositories
requires a paid GitHub account.
	 * @param   boolean  $hasIssues          Set true to enable issues for
this repository, false to disable them.
	 * @param   boolean  $hasWiki            Set true to enable the wiki for
this repository, false to disable it.
	 * @param   boolean  $hasDownloads       Set true to enable downloads for
this repository, false to disable them.
	 * @param   integer  $teamId             The id of the team that will be
granted access to this repository.
	 *                                       This is only valid when creating
a repo in an organization.
	 * @param   boolean  $autoInit           true to create an initial commit
with empty README.
	 * @param   string   $gitignoreTemplate  Desired language or platform
.gitignore template to apply.
	 *                                       Use the name of the template
without the extension. For example,
	 *                                       “Haskell” Ignored if
auto_init parameter is not provided.
	 *
	 * @return object
	 */
	public function create($name, $org = '', $description =
'', $homepage = '', $private = false, $hasIssues =
false,
		$hasWiki = false, $hasDownloads = false, $teamId = 0, $autoInit = false,
$gitignoreTemplate = '')
	{
		$path = ($org)
			// Create a repository for an organization
			? '/orgs/' . $org . '/repos'
			// Create a repository for a user
			: '/user/repos';

		$data = array(
			'name'               => $name,
			'description'        => $description,
			'homepage'           => $homepage,
			'private'            => $private,
			'has_issues'         => $hasIssues,
			'has_wiki'           => $hasWiki,
			'has_downloads'      => $hasDownloads,
			'team_id'            => $teamId,
			'auto_init'          => $autoInit,
			'gitignore_template' => $gitignoreTemplate,
		);

		// Send the request.
		return $this->processResponse(
			$this->client->post($this->fetchUrl($path),
json_encode($data)),
			201
		);
	}

	/**
	 * Get a repository.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @return object
	 */
	public function get($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Edit a repository.
	 *
	 * @param   string   $owner          Repository owner.
	 * @param   string   $repo           Repository name.
	 * @param   string   $name           The repository name.
	 * @param   string   $description    The repository description.
	 * @param   string   $homepage       The repository homepage.
	 * @param   boolean  $private        Set true to create a private
repository, false to create a public one.
	 *                                   Creating private repositories
requires a paid GitHub account.
	 * @param   boolean  $hasIssues      Set true to enable issues for this
repository, false to disable them.
	 * @param   boolean  $hasWiki        Set true to enable the wiki for this
repository, false to disable it.
	 * @param   boolean  $hasDownloads   Set true to enable downloads for this
repository, false to disable them.
	 * @param   string   $defaultBranch  Update the default branch for this
repository
	 *
	 * @return object
	 */
	public function edit($owner, $repo, $name, $description = '',
$homepage = '', $private = false, $hasIssues = false,
		$hasWiki = false, $hasDownloads = false, $defaultBranch = '')
	{
		$path = '/repos/' . $owner . '/' . $repo;

		$data = array(
			'name'           => $name,
			'description'    => $description,
			'homepage'       => $homepage,
			'private'        => $private,
			'has_issues'     => $hasIssues,
			'has_wiki'       => $hasWiki,
			'has_downloads'  => $hasDownloads,
			'default_branch' => $defaultBranch,
		);

		// Send the request.
		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path),
json_encode($data))
		);
	}

	/**
	 * List contributors.
	 *
	 * @param   string   $owner  Repository owner.
	 * @param   string   $repo   Repository name.
	 * @param   boolean  $anon   Set to 1 or true to include anonymous
contributors in results.
	 *
	 * @return object
	 */
	public function getListContributors($owner, $repo, $anon = false)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/contributors';

		$path .= ($anon) ? '?anon=true' : '';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List languages.
	 *
	 * List languages for the specified repository. The value on the right of
a language is the number of bytes of code
	 * written in that language.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @return object
	 */
	public function getListLanguages($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/languages';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List Teams
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @return object
	 */
	public function getListTeams($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/teams';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List Tags.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @return object
	 */
	public function getListTags($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/tags';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List Branches.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @return object
	 */
	public function getListBranches($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/branches';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get a Branch.
	 *
	 * @param   string  $owner   Repository owner.
	 * @param   string  $repo    Repository name.
	 * @param   string  $branch  Branch name.
	 *
	 * @return object
	 */
	public function getBranch($owner, $repo, $branch)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo .
'/branches/' . $branch;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Delete a Repository.
	 *
	 * Deleting a repository requires admin access. If OAuth is used, the
delete_repo scope is required.
	 *
	 * @param   string  $owner  Repository owner.
	 * @param   string  $repo   Repository name.
	 *
	 * @return object
	 */
	public function delete($owner, $repo)
	{
		// Build the request path.
		$path = '/repos/' . $owner . '/' . $repo;

		// Send the request.
		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path))
		);
	}
}
search.php000064400000006520151156262630006534 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API Search class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/search
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageSearch extends JGithubPackage
{
	/**
	 * Search issues.
	 *
	 * @param   string  $owner    The name of the owner of the repository.
	 * @param   string  $repo     The name of the repository.
	 * @param   string  $state    The state - open or closed.
	 * @param   string  $keyword  The search term.
	 *
	 * @throws UnexpectedValueException
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function issues($owner, $repo, $state, $keyword)
	{
		if (false == in_array($state, array('open',
'close')))
		{
			throw new UnexpectedValueException('State must be either
"open" or "closed"');
		}

		// Build the request path.
		$path = '/legacy/issues/search/' . $owner . '/' .
$repo . '/' . $state . '/' . $keyword;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Search repositories.
	 *
	 * Find repositories by keyword. Note, this legacy method does not follow
	 * the v3 pagination pattern.
	 * This method returns up to 100 results per page and pages can be fetched
	 * using the start_page parameter.
	 *
	 * @param   string   $keyword    The search term.
	 * @param   string   $language   Filter results by language
https://github.com/languages
	 * @param   integer  $startPage  Page number to fetch
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function repositories($keyword, $language = '',
$startPage = 0)
	{
		// Build the request path.
		$path = '/legacy/repos/search/' . $keyword . '?';

		$path .= ($language) ? '&language=' . $language :
'';
		$path .= ($startPage) ? '&start_page=' . $startPage :
'';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Search users.
	 *
	 * Find users by keyword.
	 *
	 * @param   string   $keyword    The search term.
	 * @param   integer  $startPage  Page number to fetch
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function users($keyword, $startPage = 0)
	{
		// Build the request path.
		$path = '/legacy/user/search/' . $keyword . '?';

		$path .= ($startPage) ? '&start_page=' . $startPage :
'';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Email search.
	 *
	 * This API call is added for compatibility reasons only. There’s no
guarantee
	 * that full email searches will always be available. The @ character in
the
	 * address must be left unencoded. Searches only against public email
addresses
	 * (as configured on the user’s GitHub profile).
	 *
	 * @param   string  $email  The email address(es).
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function email($email)
	{
		// Build the request path.
		$path = '/legacy/user/email/' . $email;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}
}
users/emails.php000064400000004057151156262630007705 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API References class for the Joomla Platform.
 *
 * Management of email addresses via the API requires that you are
authenticated
 * through basic auth or OAuth with the user scope.
 *
 * @documentation https://developer.github.com/v3/users/emails
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageUsersEmails extends JGithubPackage
{
	/**
	 * List email addresses for a user.
	 *
	 * Future response:
	 * In the final version of the API, this method will return an array of
hashes
	 * with extended information for each email address indicating if the
address
	 * has been verified and if it’s the user’s primary email address for
GitHub.
	 *
	 * Until API v3 is finalized, use the application/vnd.github.v3 media type
	 * to get this response format.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getList()
	{
		// Build the request path.
		$path = '/user/emails';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Add email address(es).
	 *
	 * @param   string|array  $email  The email address(es).
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function add($email)
	{
		// Build the request path.
		$path = '/user/emails';

		return $this->processResponse(
			$this->client->post($this->fetchUrl($path),
json_encode($email)),
			201
		);
	}

	/**
	 * Delete email address(es).
	 *
	 * @param   string|array  $email  The email address(es).
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function delete($email)
	{
		// Build the request path.
		$path = '/user/emails';

		$this->client->setOption('body', json_encode($email));

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
users/followers.php000064400000005766151156262630010457 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API References class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/users/followers
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageUsersFollowers extends JGithubPackage
{
	/**
	 * List followers of a user.
	 *
	 * @param   string  $user  The name of the user. If not set the current
authenticated user will be used.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getList($user = '')
	{
		// Build the request path.
		$path = ($user)
			? '/users/' . $user . '/followers'
			: '/user/followers';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List users followed by another user.
	 *
	 * @param   string  $user  The name of the user. If not set the current
authenticated user will be used.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getListFollowedBy($user = '')
	{
		// Build the request path.
		$path = ($user)
			? '/users/' . $user . '/following'
			: '/user/following';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Check if you are following a user.
	 *
	 * @param   string  $user  The name of the user.
	 *
	 * @throws UnexpectedValueException
	 * @since 3.3 (CMS)
	 *
	 * @return boolean
	 */
	public function check($user)
	{
		// Build the request path.
		$path = '/user/following/' . $user;

		$response = $this->client->get($this->fetchUrl($path));

		switch ($response->code)
		{
			case '204' :
				// You are following this user
				return true;
				break;

			case '404' :
				// You are not following this user
				return false;
				break;

			default :
				throw new UnexpectedValueException('Unexpected response code:
' . $response->code);
				break;
		}
	}

	/**
	 * Follow a user.
	 *
	 * Following a user requires the user to be logged in and authenticated
with
	 * basic auth or OAuth with the user:follow scope.
	 *
	 * @param   string  $user  The name of the user.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function follow($user)
	{
		// Build the request path.
		$path = '/user/following/' . $user;

		return $this->processResponse(
			$this->client->put($this->fetchUrl($path), ''),
			204
		);
	}

	/**
	 * Unfollow a user.
	 *
	 * Unfollowing a user requires the user to be logged in and authenticated
with
	 * basic auth or OAuth with the user:follow scope.
	 *
	 * @param   string  $user  The name of the user.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function unfollow($user)
	{
		// Build the request path.
		$path = '/user/following/' . $user;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
users/keys.php000064400000005722151156262630007406 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API References class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/users/keys
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageUsersKeys extends JGithubPackage
{
	/**
	 * List public keys for a user.
	 *
	 * Lists the verified public keys for a user. This is accessible by
anyone.
	 *
	 * @param   string  $user  The name of the user.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getListUser($user)
	{
		// Build the request path.
		$path = '/users/' . $user . '/keys';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * List your public keys.
	 *
	 * Lists the current user’s keys.
	 * Management of public keys via the API requires that you are
authenticated
	 * through basic auth, or OAuth with the ‘user’ scope.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function getList()
	{
		// Build the request path.
		$path = '/users/keys';

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get a single public key.
	 *
	 * @param   integer  $id  The id of the key.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function get($id)
	{
		// Build the request path.
		$path = '/users/keys/' . $id;

		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Create a public key
	 *
	 * @param   string  $title  The title of the key.
	 * @param   string  $key    The key.
	 *
	 * @since    3.3 (CMS)
	 *
	 * @return object
	 */
	public function create($title, $key)
	{
		// Build the request path.
		$path = '/users/keys';

		$data = array(
			'title' => $title,
			'key'   => $key,
		);

		return $this->processResponse(
			$this->client->post($this->fetchUrl($path),
json_encode($data)),
			201
		);
	}

	/**
	 * Update a public key.
	 *
	 * @param   integer  $id     The id of the key.
	 * @param   string   $title  The title of the key.
	 * @param   string   $key    The key.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function edit($id, $title, $key)
	{
		// Build the request path.
		$path = '/users/keys/' . $id;

		$data = array(
			'title' => $title,
			'key'   => $key,
		);

		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path),
json_encode($data))
		);
	}

	/**
	 * Delete a public key.
	 *
	 * @param   integer  $id  The id of the key.
	 *
	 * @since 3.3 (CMS)
	 *
	 * @return object
	 */
	public function delete($id)
	{
		// Build the request path.
		$path = '/users/keys/' . (int) $id;

		return $this->processResponse(
			$this->client->delete($this->fetchUrl($path)),
			204
		);
	}
}
users.php000064400000010016151156262630006423 0ustar00<?php
/**
 * @package     Joomla.Platform
 * @subpackage  GitHub
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * GitHub API References class for the Joomla Platform.
 *
 * @documentation https://developer.github.com/v3/users
 *
 * @since       3.1.4
 * @deprecated  4.0  Use the `joomla/github` package via Composer instead
 */
class JGithubPackageUsers extends JGithubPackage
{
	protected $name = 'Users';

	protected $packages = array('emails', 'followers',
'keys');

	/**
	 * Get a single user.
	 *
	 * @param   string  $user  The users login name.
	 *
	 * @throws DomainException
	 *
	 * @return object
	 */
	public function get($user)
	{
		// Build the request path.
		$path = '/users/' . $user;

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Get the current authenticated user.
	 *
	 * @throws DomainException
	 *
	 * @return mixed
	 */
	public function getAuthenticatedUser()
	{
		// Build the request path.
		$path = '/user';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/**
	 * Update a user.
	 *
	 * @param   string  $name      The full name
	 * @param   string  $email     The email
	 * @param   string  $blog      The blog
	 * @param   string  $company   The company
	 * @param   string  $location  The location
	 * @param   string  $hireable  If he is unemployed :P
	 * @param   string  $bio       The biometrical DNA fingerprint (or
something...)
	 *
	 * @throws DomainException
	 *
	 * @return mixed
	 */
	public function edit($name = '', $email = '', $blog =
'', $company = '', $location = '', $hireable
= '', $bio = '')
	{
		$data = array(
			'name'     => $name,
			'email'    => $email,
			'blog'     => $blog,
			'company'  => $company,
			'location' => $location,
			'hireable' => $hireable,
			'bio'      => $bio,
		);

		// Build the request path.
		$path = '/user';

		// Send the request.
		return $this->processResponse(
			$this->client->patch($this->fetchUrl($path),
json_encode($data))
		);
	}

	/**
	 * Get all users.
	 *
	 * This provides a dump of every user, in the order that they signed up
for GitHub.
	 *
	 * @param   integer  $since  The integer ID of the last User that you’ve
seen.
	 *
	 * @throws DomainException
	 * @return mixed
	 */
	public function getList($since = 0)
	{
		// Build the request path.
		$path = '/users';

		$path .= ($since) ? '?since=' . $since : '';

		// Send the request.
		return $this->processResponse(
			$this->client->get($this->fetchUrl($path))
		);
	}

	/*
	 * Legacy methods
	 */

	/**
	 * Get a single user.
	 *
	 * @param   string  $user  The users login name.
	 *
	 * @deprecated use users->get()
	 *
	 * @throws DomainException
	 *
	 * @return mixed
	 */
	public function getUser($user)
	{
		return $this->get($user);
	}

	/**
	 * Update a user.
	 *
	 * @param   string  $name      The full name
	 * @param   string  $email     The email
	 * @param   string  $blog      The blog
	 * @param   string  $company   The company
	 * @param   string  $location  The location
	 * @param   string  $hireable  If he is unemployed :P
	 * @param   string  $bio       The biometrical DNA fingerprint (or
something...)
	 *
	 * @deprecated use users->edit()
	 *
	 * @throws DomainException
	 *
	 * @return mixed
	 */
	public function updateUser($name = '', $email = '',
$blog = '', $company = '', $location = '',
$hireable = '', $bio = '')
	{
		return $this->edit($name = '', $email = '', $blog
= '', $company = '', $location = '',
$hireable = '', $bio = '');
	}

	/**
	 * Get all users.
	 *
	 * This provides a dump of every user, in the order that they signed up
for GitHub.
	 *
	 * @param   integer  $since  The integer ID of the last User that you’ve
seen.
	 *
	 * @deprecated use users->getList()
	 *
	 * @throws DomainException
	 * @return mixed
	 */
	public function getUsers($since = 0)
	{
		return $this->getList($since);
	}
}