Repository navigation
Expand file tree
/
Copy pathIssues.hs
More file actions
68 lines (57 loc) · 2.47 KB
/
Copy pathIssues.hs
File metadata and controls
68 lines (57 loc) · 2.47 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
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- License : BSD-3-Clause
-- Maintainer : Oleg Grenrus <oleg.grenrus@iki.fi>
--
-- The issues API as described on <http://developer.github.com/v3/issues/>.
module GitHub.Endpoints.Issues (
currentUserIssuesR,
organizationIssuesR,
issueR,
issuesForRepoR,
createIssueR,
newIssue,
editIssueR,
editOfIssue,
module GitHub.Data,
) where
import GitHub.Data
import GitHub.Internal.Prelude
import Prelude ()
-- | See <https://developer.github.com/v3/issues/#list-issues>.
currentUserIssuesR :: IssueMod -> FetchCount -> Request 'RA (Vector Issue)
currentUserIssuesR opts =
pagedQuery ["user", "issues"] (issueModToQueryString opts)
-- | See <https://developer.github.com/v3/issues/#list-issues>.
organizationIssuesR :: Name Organization -> IssueMod -> FetchCount -> Request k (Vector Issue)
organizationIssuesR org opts =
pagedQuery ["orgs", toPathPart org, "issues"] (issueModToQueryString opts)
-- | Query a single issue.
-- See <https://developer.github.com/v3/issues/#get-a-single-issue>
issueR :: Name Owner -> Name Repo -> Id Issue -> Request k Issue
issueR user reqRepoName reqIssueNumber =
query ["repos", toPathPart user, toPathPart reqRepoName, "issues", toPathPart reqIssueNumber] []
-- | List issues for a repository.
-- See <https://developer.github.com/v3/issues/#list-issues-for-a-repository>
issuesForRepoR :: Name Owner -> Name Repo -> IssueRepoMod -> FetchCount -> Request k (Vector Issue)
issuesForRepoR user reqRepoName opts =
pagedQuery ["repos", toPathPart user, toPathPart reqRepoName, "issues"] qs
where
qs = issueRepoModToQueryString opts
-- Creating new issues.
newIssue :: Text -> NewIssue
newIssue title = NewIssue title Nothing mempty Nothing Nothing
-- | Create an issue.
-- See <https://developer.github.com/v3/issues/#create-an-issue>
createIssueR :: Name Owner -> Name Repo -> NewIssue -> Request 'RW Issue
createIssueR user repo =
command Post ["repos", toPathPart user, toPathPart repo, "issues"] . encode
-- Editing issues.
editOfIssue :: EditIssue
editOfIssue = EditIssue Nothing Nothing Nothing Nothing Nothing Nothing
-- | Edit an issue.
-- See <https://developer.github.com/v3/issues/#edit-an-issue>
editIssueR :: Name Owner -> Name Repo -> Id Issue -> EditIssue -> Request 'RW Issue
editIssueR user repo iss =
command Patch ["repos", toPathPart user, toPathPart repo, "issues", toPathPart iss] . encode