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 :: forall (k :: RW).
Name Owner
-> Name Repo
-> PullRequestMod
-> FetchCount
-> Request k (Vector SimplePullRequest)
pullRequestsForR Name Owner
user Name Repo
repo PullRequestMod
opts = Paths
-> QueryString
-> FetchCount
-> Request k (Vector SimplePullRequest)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery
[Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls"]
(PullRequestMod -> QueryString
prModToQueryString PullRequestMod
opts)
pullRequestDiffR :: Name Owner -> Name Repo -> IssueNumber -> GenRequest 'MtDiff rw ByteString
pullRequestDiffR :: forall (rw :: RW).
Name Owner
-> Name Repo -> IssueNumber -> GenRequest 'MtDiff rw ByteString
pullRequestDiffR Name Owner
user Name Repo
repo IssueNumber
prid =
Paths -> QueryString -> GenRequest 'MtDiff rw ByteString
forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
prid] []
pullRequestPatchR :: Name Owner -> Name Repo -> IssueNumber -> GenRequest 'MtPatch rw ByteString
pullRequestPatchR :: forall (rw :: RW).
Name Owner
-> Name Repo -> IssueNumber -> GenRequest 'MtPatch rw ByteString
pullRequestPatchR Name Owner
user Name Repo
repo IssueNumber
prid =
Paths -> QueryString -> GenRequest 'MtPatch rw ByteString
forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
prid] []
pullRequestR :: Name Owner -> Name Repo -> IssueNumber -> Request k PullRequest
pullRequestR :: forall (k :: RW).
Name Owner -> Name Repo -> IssueNumber -> Request k PullRequest
pullRequestR Name Owner
user Name Repo
repo IssueNumber
prid =
Paths -> QueryString -> Request k PullRequest
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
prid] []
createPullRequestR :: Name Owner
-> Name Repo
-> CreatePullRequest
-> Request 'RW PullRequest
createPullRequestR :: Name Owner
-> Name Repo -> CreatePullRequest -> Request 'RW PullRequest
createPullRequestR Name Owner
user Name Repo
repo CreatePullRequest
cpr =
CommandMethod -> Paths -> ByteString -> Request 'RW PullRequest
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls"] (CreatePullRequest -> ByteString
forall a. ToJSON a => a -> ByteString
encode CreatePullRequest
cpr)
updatePullRequestR :: Name Owner
-> Name Repo
-> IssueNumber
-> EditPullRequest
-> Request 'RW PullRequest
updatePullRequestR :: Name Owner
-> Name Repo
-> IssueNumber
-> EditPullRequest
-> Request 'RW PullRequest
updatePullRequestR Name Owner
user Name Repo
repo IssueNumber
prid EditPullRequest
epr =
CommandMethod -> Paths -> ByteString -> Request 'RW PullRequest
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Patch [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
prid] (EditPullRequest -> ByteString
forall a. ToJSON a => a -> ByteString
encode EditPullRequest
epr)
pullRequestCommitsR :: Name Owner -> Name Repo -> IssueNumber -> FetchCount -> Request k (Vector Commit)
pullRequestCommitsR :: forall (k :: RW).
Name Owner
-> Name Repo
-> IssueNumber
-> FetchCount
-> Request k (Vector Commit)
pullRequestCommitsR Name Owner
user Name Repo
repo IssueNumber
prid =
Paths -> QueryString -> FetchCount -> Request k (Vector Commit)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
prid, Text
"commits"] []
pullRequestFilesR :: Name Owner -> Name Repo -> IssueNumber -> FetchCount -> Request k (Vector File)
pullRequestFilesR :: forall (k :: RW).
Name Owner
-> Name Repo
-> IssueNumber
-> FetchCount
-> Request k (Vector File)
pullRequestFilesR Name Owner
user Name Repo
repo IssueNumber
prid =
Paths -> QueryString -> FetchCount -> Request k (Vector File)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
prid, Text
"files"] []
isPullRequestMergedR :: Name Owner -> Name Repo -> IssueNumber -> GenRequest 'MtStatus rw Bool
isPullRequestMergedR :: forall (rw :: RW).
Name Owner
-> Name Repo -> IssueNumber -> GenRequest 'MtStatus rw Bool
isPullRequestMergedR Name Owner
user Name Repo
repo IssueNumber
prid =
Paths -> QueryString -> GenRequest 'MtStatus rw Bool
forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
prid, Text
"merge"] []
mergePullRequestR :: Name Owner -> Name Repo -> IssueNumber -> Maybe Text -> GenRequest 'MtStatus 'RW MergeResult
mergePullRequestR :: Name Owner
-> Name Repo
-> IssueNumber
-> Maybe Text
-> GenRequest 'MtStatus 'RW MergeResult
mergePullRequestR Name Owner
user Name Repo
repo IssueNumber
prid Maybe Text
commitMessage =
CommandMethod
-> Paths -> ByteString -> GenRequest 'MtStatus 'RW MergeResult
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put Paths
paths (Value -> ByteString
forall a. ToJSON a => a -> ByteString
encode (Value -> ByteString) -> Value -> ByteString
forall a b. (a -> b) -> a -> b
$ Maybe Text -> Value
buildCommitMessageMap Maybe Text
commitMessage)
where
paths :: Paths
paths = [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
prid, Text
"merge"]
buildCommitMessageMap :: Maybe Text -> Value
buildCommitMessageMap :: Maybe Text -> Value
buildCommitMessageMap (Just Text
msg) = [Pair] -> Value
object [Key
"commit_message" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
msg ]
buildCommitMessageMap Maybe Text
Nothing = [Pair] -> Value
object []