-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.power
More file actions
122 lines (115 loc) · 3.16 KB
/
code.power
File metadata and controls
122 lines (115 loc) · 3.16 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* List user's notification threads.
*
* @param bool|null $all Show notifications marked as read (optional).
* @param array|null $statusTypes Show notifications with the provided status types (optional).
* @param array|null $subjectType Filter notifications by subject type (optional).
* @param string|null $since Show notifications updated after the given time (optional).
* @param string|null $before Show notifications updated before the given time (optional).
* @param int $page Page number of results to return (optional).
* @param int $limit Page size of results (optional).
*
* @return array|null
* @since 3.2.0
**/
public function list(
?bool $all = null,
?array $statusTypes = null,
?array $subjectType = null,
?string $since = null,
?string $before = null,
int $page = 1,
int $limit = 10
): ?array
{
// Build the request path.
$path = "/notifications";
// Configure the URI with query parameters.
$uri = $this->uri->get($path);
if ($all !== null)
{
$uri->setVar('all', $all);
}
if ($statusTypes !== null)
{
$uri->setVar('status-types', implode(',', $statusTypes));
}
if ($subjectType !== null)
{
$uri->setVar('subject-type', implode(',', $subjectType));
}
if ($since !== null)
{
$uri->setVar('since', $since);
}
if ($before !== null)
{
$uri->setVar('before', $before);
}
$uri->setVar('page', $page);
$uri->setVar('limit', $limit);
// Send the get request.
return $this->response->get(
$this->http->get($uri)
);
}
/**
* Mark notification threads as read, pinned, or unread.
*
* @param string|null $lastReadAt Describes the last point that notifications were checked (optional).
* @param bool|null $all If true, mark all notifications on this repo (optional).
* @param array|null $statusTypes Mark notifications with the provided status types (optional).
* @param string|null $toStatus Status to mark notifications as (optional).
*
* @return array|null
* @since 3.2.0
**/
public function update(
?string $lastReadAt = null,
?bool $all = null,
?array $statusTypes = null,
?string $toStatus = null
): ?array
{
// Build the request path.
$path = "/notifications";
// Configure the URI with query parameters.
$uri = $this->uri->get($path);
if ($lastReadAt !== null)
{
$uri->setVar('last_read_at', $lastReadAt);
}
if ($all !== null)
{
$uri->setVar('all', $all);
}
if ($statusTypes !== null)
{
$uri->setVar('status-types', implode(',', $statusTypes));
}
if ($toStatus !== null)
{
$uri->setVar('to-status', $toStatus);
}
// Send the put request.
return $this->response->get(
$this->http->put($uri, ''), 205
);
}
/**
* Check if unread notifications exist.
*
* @return object|null
* @since 3.2.0
**/
public function check(): ?object
{
// Build the request path.
$path = "/notifications/new";
// Send the get request.
return $this->response->get(
$this->http->get(
$this->uri->get($path)
)
);
}