1 <?php
 2 /**
 3  * @package     Joomla.Platform
 4  * @subpackage  GitHub
 5  *
 6  * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
 7  * @license     GNU General Public License version 2 or later; see LICENSE
 8  */
 9 
10 defined('JPATH_PLATFORM') or die;
11 
12 /**
13  * GitHub API Assignees class for the Joomla Platform.
14  *
15  * @documentation https://developer.github.com/v3/issues/assignees/
16  *
17  * @since       12.3
18  * @deprecated  4.0  Use the `joomla/github` package via Composer instead
19  */
20 class JGithubPackageIssuesAssignees extends JGithubPackage
21 {
22     /**
23      * List assignees.
24      *
25      * This call lists all the available assignees (owner + collaborators) to which issues may be assigned.
26      *
27      * @param   string  $owner  The name of the owner of the GitHub repository.
28      * @param   string  $repo   The name of the GitHub repository.
29      *
30      * @return object
31      */
32     public function getList($owner, $repo)
33     {
34         // Build the request path.
35         $path = '/repos/' . $owner . '/' . $repo . '/assignees';
36 
37         return $this->processResponse(
38             $this->client->get($this->fetchUrl($path))
39         );
40     }
41 
42     /**
43      * Check assignee.
44      *
45      * You may check to see if a particular user is an assignee for a repository.
46      * If the given assignee login belongs to an assignee for the repository, a 204 header
47      * with no content is returned.
48      * Otherwise a 404 status code is returned.
49      *
50      * @param   string  $owner     The name of the owner of the GitHub repository.
51      * @param   string  $repo      The name of the GitHub repository.
52      * @param   string  $assignee  The assinees login name.
53      *
54      * @throws DomainException|Exception
55      * @return boolean
56      */
57     public function check($owner, $repo, $assignee)
58     {
59         // Build the request path.
60         $path = '/repos/' . $owner . '/' . $repo . '/assignees/' . $assignee;
61 
62         try
63         {
64             $response = $this->client->get($this->fetchUrl($path));
65 
66             if (204 == $response->code)
67             {
68                 return true;
69             }
70 
71             throw new DomainException('Invalid response: ' . $response->code);
72         }
73         catch (DomainException $e)
74         {
75             if (isset($response->code) && 404 == $response->code)
76             {
77                 return false;
78             }
79 
80             throw $e;
81         }
82     }
83 }
84