module GitHub.Endpoints.PullRequests (
pullRequestsForR,
pullRequestR,
pullRequestDiffR,
pullRequestPatchR,
createPullRequestR,
updatePullRequestR,
pullRequestCommitsR,
pullRequestFilesR,
isPullRequestMergedR,
mergePullRequestR,
module GitHub.Data
) where
import GitHub.Data
import GitHub.Internal.Prelude
import Prelude ()
import Data.ByteString.Lazy (ByteString)
pullRequestsForR
:: Name Owner
-> Name Repo
-> PullRequestMod
-> FetchCount
-> Request k (Vector SimplePullRequest)
pullRequestsForR user repo opts = pagedQuery
["repos", toPathPart user, toPathPart repo, "pulls"]
(prModToQueryString opts)
pullRequestDiffR :: Name Owner -> Name Repo -> IssueNumber -> GenRequest 'MtDiff rw ByteString
pullRequestDiffR user repo prid =
Query ["repos", toPathPart user, toPathPart repo, "pulls", toPathPart prid] []
pullRequestPatchR :: Name Owner -> Name Repo -> IssueNumber -> GenRequest 'MtPatch rw ByteString
pullRequestPatchR user repo prid =
Query ["repos", toPathPart user, toPathPart repo, "pulls", toPathPart prid] []
pullRequestR :: Name Owner -> Name Repo -> IssueNumber -> Request k PullRequest
pullRequestR user repo prid =
query ["repos", toPathPart user, toPathPart repo, "pulls", toPathPart prid] []
createPullRequestR :: Name Owner
-> Name Repo
-> CreatePullRequest
-> Request 'RW PullRequest
createPullRequestR user repo cpr =
command Post ["repos", toPathPart user, toPathPart repo, "pulls"] (encode cpr)
updatePullRequestR :: Name Owner
-> Name Repo
-> IssueNumber
-> EditPullRequest
-> Request 'RW PullRequest
updatePullRequestR user repo prid epr =
command Patch ["repos", toPathPart user, toPathPart repo, "pulls", toPathPart prid] (encode epr)
pullRequestCommitsR :: Name Owner -> Name Repo -> IssueNumber -> FetchCount -> Request k (Vector Commit)
pullRequestCommitsR user repo prid =
pagedQuery ["repos", toPathPart user, toPathPart repo, "pulls", toPathPart prid, "commits"] []
pullRequestFilesR :: Name Owner -> Name Repo -> IssueNumber -> FetchCount -> Request k (Vector File)
pullRequestFilesR user repo prid =
pagedQuery ["repos", toPathPart user, toPathPart repo, "pulls", toPathPart prid, "files"] []
isPullRequestMergedR :: Name Owner -> Name Repo -> IssueNumber -> GenRequest 'MtStatus rw Bool
isPullRequestMergedR user repo prid =
Query ["repos", toPathPart user, toPathPart repo, "pulls", toPathPart prid, "merge"] []
mergePullRequestR :: Name Owner -> Name Repo -> IssueNumber -> Maybe Text -> GenRequest 'MtStatus 'RW MergeResult
mergePullRequestR user repo prid commitMessage =
Command Put paths (encode $ buildCommitMessageMap commitMessage)
where
paths = ["repos", toPathPart user, toPathPart repo, "pulls", toPathPart prid, "merge"]
buildCommitMessageMap :: Maybe Text -> Value
buildCommitMessageMap (Just msg) = object ["commit_message" .= msg ]
buildCommitMessageMap Nothing = object []