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 Issues Events class for the Joomla Platform.
14 *
15 * Records various events that occur around an Issue or Pull Request.
16 * This is useful both for display on issue/pull request information pages and also
17 * to determine who should be notified of comments.
18 *
19 * @documentation https://developer.github.com/v3/issues/events/
20 *
21 * @since 12.3
22 * @deprecated 4.0 Use the `joomla/github` package via Composer instead
23 */
24 class JGithubPackageIssuesEvents extends JGithubPackage
25 {
26 /**
27 * List events for an issue.
28 *
29 * @param string $owner The name of the owner of the GitHub repository.
30 * @param string $repo The name of the GitHub repository.
31 * @param integer $issue_number The issue number.
32 * @param integer $page The page number from which to get items.
33 * @param integer $limit The number of items on a page.
34 *
35 * @return object
36 */
37 public function getList($owner, $repo, $issue_number, $page = 0, $limit = 0)
38 {
39 // Build the request path.
40 $path = '/repos/' . $owner . '/' . $repo . '/issues/' . (int) $issue_number . '/events';
41
42 // Send the request.
43 return $this->processResponse(
44 $this->client->get($this->fetchUrl($path, $page, $limit))
45 );
46 }
47
48 /**
49 * List events for a repository.
50 *
51 * @param string $owner The name of the owner of the GitHub repository.
52 * @param string $repo The name of the GitHub repository.
53 * @param integer $issueId The issue number.
54 * @param integer $page The page number from which to get items.
55 * @param integer $limit The number of items on a page.
56 *
57 * @return object
58 */
59 public function getListRepository($owner, $repo, $issueId, $page = 0, $limit = 0)
60 {
61 // Build the request path.
62 $path = '/repos/' . $owner . '/' . $repo . '/issues/' . (int) $issueId . '/comments';
63
64 // Send the request.
65 return $this->processResponse(
66 $this->client->get($this->fetchUrl($path, $page, $limit))
67 );
68 }
69
70 /**
71 * Get a single event.
72 *
73 * @param string $owner The name of the owner of the GitHub repository.
74 * @param string $repo The name of the GitHub repository.
75 * @param integer $id The event number.
76 *
77 * @return object
78 */
79 public function get($owner, $repo, $id)
80 {
81 // Build the request path.
82 $path = '/repos/' . $owner . '/' . $repo . '/issues/events/' . (int) $id;
83
84 // Send the request.
85 return $this->processResponse(
86 $this->client->get($this->fetchUrl($path))
87 );
88 }
89 }
90