Repository navigation
Expand file tree
/
Copy pathEmails.php
More file actions
94 lines (85 loc) · 2.13 KB
/
Copy pathEmails.php
File metadata and controls
94 lines (85 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
namespace Github\Api\CurrentUser;
use Github\Api\AbstractApi;
use Github\Exception\InvalidArgumentException;
/**
* @link http://developer.github.com/v3/users/emails/
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class Emails extends AbstractApi
{
/**
* List emails for the authenticated user.
*
* @link http://developer.github.com/v3/users/emails/
*
* @return array
*/
public function all()
{
return $this->get('/user/emails');
}
/**
* List public email addresses for a user.
*
* @link https://developer.github.com/v3/users/emails/#list-public-email-addresses-for-a-user
*
* @return array
*/
public function allPublic()
{
return $this->get('/user/public_emails');
}
/**
* Adds one or more email for the authenticated user.
*
* @link http://developer.github.com/v3/users/emails/
*
* @param string|array $emails
*
* @throws \Github\Exception\InvalidArgumentException
*
* @return array
*/
public function add($emails)
{
if (is_string($emails)) {
$emails = [$emails];
} elseif (0 === count($emails)) {
throw new InvalidArgumentException();
}
return $this->post('/user/emails', $emails);
}
/**
* Removes one or more email for the authenticated user.
*
* @link http://developer.github.com/v3/users/emails/
*
* @param string|array $emails
*
* @throws \Github\Exception\InvalidArgumentException
*
* @return array
*/
public function remove($emails)
{
if (is_string($emails)) {
$emails = [$emails];
} elseif (0 === count($emails)) {
throw new InvalidArgumentException();
}
return $this->delete('/user/emails', $emails);
}
/**
* Toggle primary email visibility.
*
* @link https://developer.github.com/v3/users/emails/#toggle-primary-email-visibility
*
* @return array
*/
public function toggleVisibility()
{
return $this->patch('/user/email/visibility');
}
}