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 Activity class for the Joomla Platform.
14 *
15 * @since 3.3 (CMS)
16 * @deprecated 4.0 Use the `joomla/github` package via Composer instead
17 *
18 * @documentation https://developer.github.com/v3/orgs/
19 *
20 * @property-read JGithubPackageOrgsMembers $members GitHub API object for members.
21 * @property-read JGithubPackageOrgsTeams $teams GitHub API object for teams.
22 */
23 class JGithubPackageOrgs extends JGithubPackage
24 {
25 protected $name = 'Orgs';
26
27 protected $packages = array('members', 'teams');
28
29 /**
30 * List User Organizations.
31 *
32 * If a user name is given, public and private organizations for the authenticated user will be listed.
33 *
34 * @param string $user The user name.
35 *
36 * @since 3.3 (CMS)
37 *
38 * @return object
39 */
40 public function getList($user = '')
41 {
42 // Build the request path.
43 $path = ($user)
44 ? '/users/' . $user . '/orgs'
45 : '/user/orgs';
46
47 // Send the request.
48 return $this->processResponse(
49 $this->client->get($this->fetchUrl($path))
50 );
51 }
52
53 /**
54 * Get an Organization.
55 *
56 * @param string $org The organization name.
57 *
58 * @since 3.3 (CMS)
59 *
60 * @return object
61 */
62 public function get($org)
63 {
64 // Build the request path.
65 $path = '/orgs/' . $org;
66
67 // Send the request.
68 return $this->processResponse(
69 $this->client->get($this->fetchUrl($path))
70 );
71 }
72
73 /**
74 * Edit an Organization.
75 *
76 * @param string $org The organization name.
77 * @param string $billingEmail Billing email address. This address is not publicized.
78 * @param string $company The company name.
79 * @param string $email The email address.
80 * @param string $location The location name.
81 * @param string $name The name.
82 *
83 * @since 3.3 (CMS)
84 *
85 * @return object
86 */
87 public function edit($org, $billingEmail = '', $company = '', $email = '', $location = '', $name = '')
88 {
89 // Build the request path.
90 $path = '/orgs/' . $org;
91
92 $args = array('billing_email', 'company', 'email', 'location', 'name');
93
94 $data = array();
95
96 $fArgs = func_get_args();
97
98 foreach ($args as $i => $arg)
99 {
100 if (array_key_exists($i + 1, $fArgs) && $fArgs[$i + 1])
101 {
102 $data[$arg] = $fArgs[$i + 1];
103 }
104 }
105
106 // Send the request.
107 return $this->processResponse(
108 $this->client->patch($this->fetchUrl($path), $data)
109 );
110 }
111 }
112