Spade
Mini Shell
events.php000064400000011024151172217120006556 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))
);
}
}
notifications.php000064400000016613151172217120010134 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
);
}
}
starring.php000064400000006010151172217120007102 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
);
}
}
watching.php000064400000011247151172217130007066 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
);
}
}