module GitHub.Endpoints.PullRequests.Comments (
pullRequestCommentsIO,
pullRequestCommentsR,
pullRequestComment,
pullRequestCommentR,
createPullComment,
createPullCommentR,
module GitHub.Data,
) where
import GitHub.Data
import GitHub.Internal.Prelude
import GitHub.Request
import Prelude ()
pullRequestCommentsIO :: Name Owner -> Name Repo -> IssueNumber -> IO (Either Error (Vector Comment))
user :: Name Owner
user repo :: Name Repo
repo prid :: IssueNumber
prid =
GenRequest 'MtJSON 'RO (Vector Comment)
-> IO (Either Error (Vector Comment))
forall (mt :: MediaType *) a.
ParseResponse mt a =>
GenRequest mt 'RO a -> IO (Either Error a)
executeRequest' (GenRequest 'MtJSON 'RO (Vector Comment)
-> IO (Either Error (Vector Comment)))
-> GenRequest 'MtJSON 'RO (Vector Comment)
-> IO (Either Error (Vector Comment))
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo
-> IssueNumber
-> FetchCount
-> GenRequest 'MtJSON 'RO (Vector Comment)
forall (k :: RW).
Name Owner
-> Name Repo
-> IssueNumber
-> FetchCount
-> Request k (Vector Comment)
pullRequestCommentsR Name Owner
user Name Repo
repo IssueNumber
prid FetchCount
FetchAll
pullRequestCommentsR :: Name Owner -> Name Repo -> IssueNumber -> FetchCount -> Request k (Vector Comment)
user :: Name Owner
user repo :: Name Repo
repo prid :: IssueNumber
prid =
Paths -> QueryString -> FetchCount -> Request k (Vector Comment)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery ["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, "pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
prid, "comments"] []
pullRequestComment :: Name Owner -> Name Repo -> Id Comment -> IO (Either Error Comment)
user :: Name Owner
user repo :: Name Repo
repo cid :: Id Comment
cid =
GenRequest 'MtJSON 'RO Comment -> IO (Either Error Comment)
forall (mt :: MediaType *) a.
ParseResponse mt a =>
GenRequest mt 'RO a -> IO (Either Error a)
executeRequest' (GenRequest 'MtJSON 'RO Comment -> IO (Either Error Comment))
-> GenRequest 'MtJSON 'RO Comment -> IO (Either Error Comment)
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo -> Id Comment -> GenRequest 'MtJSON 'RO Comment
forall (k :: RW).
Name Owner -> Name Repo -> Id Comment -> Request k Comment
pullRequestCommentR Name Owner
user Name Repo
repo Id Comment
cid
pullRequestCommentR :: Name Owner -> Name Repo -> Id Comment -> Request k Comment
user :: Name Owner
user repo :: Name Repo
repo cid :: Id Comment
cid =
Paths -> QueryString -> Request k Comment
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query ["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, "pulls", "comments", Id Comment -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Comment
cid] []
createPullComment :: Auth -> Name Owner -> Name Repo -> IssueNumber -> Text -> Text -> Int -> Text
-> IO (Either Error Comment)
auth :: Auth
auth user :: Name Owner
user repo :: Name Repo
repo iss :: IssueNumber
iss commit :: Text
commit path :: Text
path position :: Int
position body :: Text
body =
Auth -> GenRequest 'MtJSON 'RW Comment -> IO (Either Error Comment)
forall am (mt :: MediaType *) a (rw :: RW).
(AuthMethod am, ParseResponse mt a) =>
am -> GenRequest mt rw a -> IO (Either Error a)
executeRequest Auth
auth (GenRequest 'MtJSON 'RW Comment -> IO (Either Error Comment))
-> GenRequest 'MtJSON 'RW Comment -> IO (Either Error Comment)
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo
-> IssueNumber
-> Text
-> Text
-> Int
-> Text
-> GenRequest 'MtJSON 'RW Comment
createPullCommentR Name Owner
user Name Repo
repo IssueNumber
iss Text
commit Text
path Int
position Text
body
createPullCommentR :: Name Owner -> Name Repo -> IssueNumber -> Text -> Text -> Int -> Text -> Request 'RW Comment
user :: Name Owner
user repo :: Name Repo
repo iss :: IssueNumber
iss commit :: Text
commit path :: Text
path position :: Int
position body :: Text
body =
CommandMethod
-> Paths -> ByteString -> GenRequest 'MtJSON 'RW Comment
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post Paths
parts (NewPullComment -> ByteString
forall a. ToJSON a => a -> ByteString
encode (NewPullComment -> ByteString) -> NewPullComment -> ByteString
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Int -> Text -> NewPullComment
NewPullComment Text
commit Text
path Int
position Text
body)
where
parts :: Paths
parts = ["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, "pulls", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
iss, "comments"]