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 References class for the Joomla Platform.
14 *
15 * Management of email addresses via the API requires that you are authenticated
16 * through basic auth or OAuth with the user scope.
17 *
18 * @documentation https://developer.github.com/v3/repos/users/emails
19 *
20 * @since 12.3
21 * @deprecated 4.0 Use the `joomla/github` package via Composer instead
22 */
23 class JGithubPackageUsersEmails extends JGithubPackage
24 {
25 /**
26 * List email addresses for a user.
27 *
28 * Future response:
29 * In the final version of the API, this method will return an array of hashes
30 * with extended information for each email address indicating if the address
31 * has been verified and if it’s the user’s primary email address for GitHub.
32 *
33 * Until API v3 is finalized, use the application/vnd.github.v3 media type
34 * to get this response format.
35 *
36 * @since 3.3 (CMS)
37 *
38 * @return object
39 */
40 public function getList()
41 {
42 // Build the request path.
43 $path = '/user/emails';
44
45 return $this->processResponse(
46 $this->client->get($this->fetchUrl($path))
47 );
48 }
49
50 /**
51 * Add email address(es).
52 *
53 * @param string|array $email The email address(es).
54 *
55 * @since 3.3 (CMS)
56 *
57 * @return object
58 */
59 public function add($email)
60 {
61 // Build the request path.
62 $path = '/user/emails';
63
64 return $this->processResponse(
65 $this->client->post($this->fetchUrl($path), json_encode($email)),
66 201
67 );
68 }
69
70 /**
71 * Delete email address(es).
72 *
73 * @param string|array $email The email address(es).
74 *
75 * @since 3.3 (CMS)
76 *
77 * @return object
78 */
79 public function delete($email)
80 {
81 // Build the request path.
82 $path = '/user/emails';
83
84 $this->client->setOption('body', json_encode($email));
85
86 return $this->processResponse(
87 $this->client->delete($this->fetchUrl($path)),
88 204
89 );
90 }
91 }
92