forked from haskell-github/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReactions.hs
More file actions
60 lines (53 loc) · 2.99 KB
/
Reactions.hs
File metadata and controls
60 lines (53 loc) · 2.99 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
-- |
-- The Reactions API as described at
-- <https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28>.
module GitHub.Endpoints.Reactions (
issueReactionsR,
createIssueReactionR,
deleteIssueReactionR,
commentReactionsR,
createCommentReactionR,
deleteCommentReactionR,
module GitHub.Data,
) where
import GitHub.Data
import GitHub.Internal.Prelude
import Prelude ()
-- | List reactions for an issue.
-- See <https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-an-issue>
issueReactionsR :: Name Owner -> Name Repo -> Id Issue -> FetchCount -> Request k (Vector Reaction)
issueReactionsR owner repo iid =
pagedQuery ["repos", toPathPart owner, toPathPart repo, "issues", toPathPart iid, "reactions"] []
-- | Create reaction for an issue comment.
-- See <https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-an-issue>
createIssueReactionR :: Name Owner -> Name Repo -> Id Issue -> ReactionContent -> Request 'RW Reaction
createIssueReactionR owner repo iid content =
command Post parts (encode $ NewReaction content)
where
parts = ["repos", toPathPart owner, toPathPart repo, "issues", toPathPart iid, "reactions"]
-- | Delete an issue comment reaction.
-- See <https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#delete-an-issue-reaction>
deleteIssueReactionR :: Name Owner -> Name Repo -> Id Issue -> Id Reaction -> GenRequest 'MtUnit 'RW ()
deleteIssueReactionR owner repo iid rid =
Command Delete parts mempty
where
parts = ["repos", toPathPart owner, toPathPart repo, "issues", toPathPart iid, "reactions", toPathPart rid]
-- | List reactions for an issue comment.
-- See <https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-an-issue-comment>
commentReactionsR :: Name Owner -> Name Repo -> Id Comment -> FetchCount -> Request k (Vector Reaction)
commentReactionsR owner repo cid =
pagedQuery ["repos", toPathPart owner, toPathPart repo, "issues", "comments", toPathPart cid, "reactions"] []
-- | Create reaction for an issue comment.
-- See https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-an-issue-comment
createCommentReactionR :: Name Owner -> Name Repo -> Id Comment -> ReactionContent -> Request 'RW Reaction
createCommentReactionR owner repo cid content =
command Post parts (encode $ NewReaction content)
where
parts = ["repos", toPathPart owner, toPathPart repo, "issues", "comments", toPathPart cid, "reactions"]
-- | Delete an issue comment reaction.
-- See <https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#delete-an-issue-comment-reaction>
deleteCommentReactionR :: Name Owner -> Name Repo -> Id Comment -> Id Reaction -> GenRequest 'MtUnit 'RW ()
deleteCommentReactionR owner repo cid rid =
Command Delete parts mempty
where
parts = ["repos", toPathPart owner, toPathPart repo, "issues", "comments", toPathPart cid, "reactions", toPathPart rid]