|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Github\Api\Activity; |
| 4 | + |
| 5 | +use DateTime; |
| 6 | +use DateTimeInterface; |
| 7 | +use Github\Api\AbstractApi; |
| 8 | + |
| 9 | +/** |
| 10 | + * API for accessing Notifications from your Git/Github repositories. |
| 11 | + * |
| 12 | + * Important! You have to be authenticated to perform these methods |
| 13 | + * |
| 14 | + * @link https://developer.github.com/v3/activity/notifications/ |
| 15 | + * @author Dennis de Greef <[email protected]> |
| 16 | + */ |
| 17 | +class Notification extends AbstractApi |
| 18 | +{ |
| 19 | + /** |
| 20 | + * Get a listing of a notifications |
| 21 | + * @link https://developer.github.com/v3/activity/notifications/ |
| 22 | + * |
| 23 | + * @param bool $includingRead |
| 24 | + * @param bool $participating |
| 25 | + * @param null $since |
| 26 | + * |
| 27 | + * @return array array of notifications |
| 28 | + */ |
| 29 | + public function all($includingRead = false, $participating = false, $since = null) |
| 30 | + { |
| 31 | + $parameters = array( |
| 32 | + 'all' => $includingRead, |
| 33 | + 'participating' => $participating |
| 34 | + ); |
| 35 | + |
| 36 | + if($since !== null) { |
| 37 | + $parameters['since'] = $since; |
| 38 | + } |
| 39 | + |
| 40 | + return $this->get('notifications', $parameters); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Marks all notifications as read from the current date |
| 45 | + * Optionally give DateTimeInterface to mark as read before that date |
| 46 | + * |
| 47 | + * @link https://developer.github.com/v3/activity/notifications/#mark-as-read |
| 48 | + * |
| 49 | + * @param DateTimeInterface $since |
| 50 | + * |
| 51 | + */ |
| 52 | + public function markRead(DateTimeInterface $since = null) |
| 53 | + { |
| 54 | + $parameters = array(); |
| 55 | + |
| 56 | + if($since !== null) { |
| 57 | + $parameters['last_read_at'] = $since->format(DateTime::ISO8601); |
| 58 | + } |
| 59 | + |
| 60 | + $this->put('notifications', $parameters); |
| 61 | + } |
| 62 | +} |
0 commit comments