|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Api\CurrentUser; |
| 4 | + |
| 5 | +use Github\Api\AbstractApi; |
| 6 | + |
| 7 | +/** |
| 8 | + * @link http://developer.github.com/v3/activity/notifications/ |
| 9 | + * @author Joseph Bielawski <stloyd@gmail.com> |
| 10 | + */ |
| 11 | +class Notifications extends AbstractApi |
| 12 | +{ |
| 13 | + /** |
| 14 | + * List all notifications for the authenticated user |
| 15 | + * @link http://developer.github.com/v3/activity/notifications/#list-your-notifications |
| 16 | + * |
| 17 | + * @param array $params |
| 18 | + * @return array |
| 19 | + */ |
| 20 | + public function all(array $params = array()) |
| 21 | + { |
| 22 | + return $this->get('notifications', $params); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * List all notifications for the authenticated user in selected repository |
| 27 | + * @link http://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository |
| 28 | + * |
| 29 | + * @param string $username the user who owns the repo |
| 30 | + * @param string $repository the name of the repo |
| 31 | + * @param array $params |
| 32 | + * @return array |
| 33 | + */ |
| 34 | + public function allInRepository($username, $repository, array $params = array()) |
| 35 | + { |
| 36 | + return $this->get('repos/'.urlencode($username).'/'.urlencode($repository).'/notifications', $params); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @link http://developer.github.com/v3/activity/notifications/#mark-as-read |
| 41 | + * |
| 42 | + * @param array $params |
| 43 | + * @return array |
| 44 | + */ |
| 45 | + public function markAsReadAll(array $params = array()) |
| 46 | + { |
| 47 | + return $this->put('notifications', $params); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @link http://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository |
| 52 | + * |
| 53 | + * @param string $username the user who owns the repo |
| 54 | + * @param string $repository the name of the repo |
| 55 | + * @param array $params |
| 56 | + * @return array |
| 57 | + */ |
| 58 | + public function markAsReadInRepository($username, $repository, array $params = array()) |
| 59 | + { |
| 60 | + return $this->put('repos/'.urlencode($username).'/'.urlencode($repository).'/notifications', $params); |
| 61 | + } |
| 62 | + |
| 63 | + /** |
| 64 | + * @link http://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read |
| 65 | + * |
| 66 | + * @param string $id the notification number |
| 67 | + * @param array $params |
| 68 | + * @return array |
| 69 | + */ |
| 70 | + public function markAsRead($id, array $params) |
| 71 | + { |
| 72 | + return $this->patch('notifications/threads/'.urlencode($id), $params); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * @link http://developer.github.com/v3/activity/notifications/#view-a-single-thread |
| 77 | + * |
| 78 | + * @param string $id the notification number |
| 79 | + * @return array |
| 80 | + */ |
| 81 | + public function show($id) |
| 82 | + { |
| 83 | + return $this->get('notifications/threads/'.urlencode($id)); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * @link http://developer.github.com/v3/activity/notifications/#get-a-thread-subscription |
| 88 | + * |
| 89 | + * @param string $id the notification number |
| 90 | + * @return array |
| 91 | + */ |
| 92 | + public function showSubscription($id) |
| 93 | + { |
| 94 | + return $this->get('notifications/threads/'.urlencode($id).'/subscription'); |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * @link http://developer.github.com/v3/activity/notifications/#set-a-thread-subscription |
| 99 | + * |
| 100 | + * @param string $id the notification number |
| 101 | + * @param array $params |
| 102 | + * @return array |
| 103 | + */ |
| 104 | + public function createSubscription($id, array $params) |
| 105 | + { |
| 106 | + return $this->put('notifications/threads/'.urlencode($id).'/subscription', $params); |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * @link http://developer.github.com/v3/activity/notifications/#delete-a-thread-subscription |
| 111 | + * |
| 112 | + * @param string $id the notification number |
| 113 | + * @return array |
| 114 | + */ |
| 115 | + public function removeSubscription($id) |
| 116 | + { |
| 117 | + return $this->delete('notifications/threads/'.urlencode($id).'/subscription'); |
| 118 | + } |
| 119 | +} |
0 commit comments