|
| 1 | +module GitHub.Activity.Notifications where |
| 2 | +import GitHub.Internal |
| 3 | + |
| 4 | +notifications = "/notifications" |
| 5 | +thread i = notifications <> "/threads/" <> i |
| 6 | +subscription = thread i <> "/subscription" |
| 7 | +repoNotifications o r = ownerRepo o r <> "/notifications" |
| 8 | + |
| 9 | +mParam :: IsString s => s -> Maybe s -> Maybe (s, s) |
| 10 | + |
| 11 | +-- GET /notifications |
| 12 | +listNotifications :: |
| 13 | + Maybe Bool -> |
| 14 | + Maybe Bool -> |
| 15 | + Maybe UTCTime -> |
| 16 | + GitHub NotificationData |
| 17 | +listNotifications a p s = ghGet |
| 18 | + [ mParam "all" a |
| 19 | + , mParam "participating" p |
| 20 | + , mParam "since" s |
| 21 | + ] |
| 22 | + $ notifications |
| 23 | + |
| 24 | +-- GET /repos/:owner/:repo/notifications |
| 25 | +listRepositoryNotifications :: |
| 26 | + OwnerName -> |
| 27 | + RepoName -> |
| 28 | + Maybe Bool -> |
| 29 | + Maybe Bool -> |
| 30 | + Maybe UTCTime -> |
| 31 | + GitHub NotificationData |
| 32 | +listRepositoryNotifications o r a p s = ghGet |
| 33 | + [ mParam "all" a |
| 34 | + , mParam "participating" p |
| 35 | + , mParam "since" s |
| 36 | + ] |
| 37 | + $ repoNotifications o r |
| 38 | + |
| 39 | +-- PUT /notifications |
| 40 | +markNotificationsRead :: |
| 41 | + Maybe UTCTime -> |
| 42 | + GitHub NotificationData |
| 43 | +markNotificationsRead o r s = ghPut' notifications [] |
| 44 | + |
| 45 | +-- PUT /repos/:owner/:repo/notifications |
| 46 | +markRepositoryNotificationsRead :: |
| 47 | + OwnerName -> |
| 48 | + RepoName -> |
| 49 | + Maybe UTCTime -> |
| 50 | + GitHub NotificationData |
| 51 | +markRepositoryNotificationsRead o r t = ghPut (repoNotifications o r) $ NotificationsReadOptions t |
| 52 | + |
| 53 | +-- GET /notifications/threads/:id |
| 54 | +getNotificationThread :: |
| 55 | + Int -> |
| 56 | + GitHub NotificationThreadData |
| 57 | +getNotificationThread = ghGet [] . thread |
| 58 | + |
| 59 | +-- PATCH /notifications/threads/:id |
| 60 | +markNotificationThreadRead :: |
| 61 | + Int -> |
| 62 | + GitHub () |
| 63 | +markNotificationThreadRead = ghPatch' . thread |
| 64 | + |
| 65 | +-- GET /notifications/threads/:id/subscription |
| 66 | +getThreadSubscription :: |
| 67 | + Int -> |
| 68 | + GitHub ThreadSubscriptionData |
| 69 | +getThreadSubscription = ghGet [] . subscription |
| 70 | + |
| 71 | +-- PUT /notifications/threads/:id/subscription |
| 72 | +setThreadSubscription :: |
| 73 | + Int -> |
| 74 | + NewSubscription -> |
| 75 | + GitHub ThreadSubscriptionData |
| 76 | +setThreadSubscription i = ghPut (subscription i) |
| 77 | + |
| 78 | +-- DELETE /notifications/threads/:id/subscription |
| 79 | +deleteThreadSubscription :: |
| 80 | + Int -> |
| 81 | + GitHub () |
| 82 | +deleteThreadSubscription = ghDelete . subscription |
0 commit comments