module GitHub.Endpoints.Issues.Comments (
comment,
commentR,
comments,
commentsR,
comments',
createComment,
createCommentR,
deleteComment,
deleteCommentR,
editComment,
editCommentR,
module GitHub.Data,
) where
import GitHub.Data
import GitHub.Internal.Prelude
import GitHub.Request
import Prelude ()
comment :: Name Owner -> Name Repo -> Id Comment -> IO (Either Error IssueComment)
user :: Name Owner
user repo :: Name Repo
repo cid :: Id Comment
cid =
GenRequest 'MtJSON 'RO IssueComment
-> IO (Either Error IssueComment)
forall (mt :: MediaType *) a.
ParseResponse mt a =>
GenRequest mt 'RO a -> IO (Either Error a)
executeRequest' (GenRequest 'MtJSON 'RO IssueComment
-> IO (Either Error IssueComment))
-> GenRequest 'MtJSON 'RO IssueComment
-> IO (Either Error IssueComment)
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo -> Id Comment -> GenRequest 'MtJSON 'RO IssueComment
forall (k :: RW).
Name Owner -> Name Repo -> Id Comment -> Request k IssueComment
commentR Name Owner
user Name Repo
repo Id Comment
cid
commentR :: Name Owner -> Name Repo -> Id Comment -> Request k IssueComment
user :: Name Owner
user repo :: Name Repo
repo cid :: Id Comment
cid =
Paths -> QueryString -> Request k IssueComment
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, "issues", "comments", Id Comment -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Comment
cid] []
comments :: Name Owner -> Name Repo -> IssueNumber -> IO (Either Error (Vector IssueComment))
= Maybe Auth
-> Name Owner
-> Name Repo
-> IssueNumber
-> IO (Either Error (Vector IssueComment))
comments' Maybe Auth
forall a. Maybe a
Nothing
comments' :: Maybe Auth -> Name Owner -> Name Repo -> IssueNumber -> IO (Either Error (Vector IssueComment))
auth :: Maybe Auth
auth user :: Name Owner
user repo :: Name Repo
repo iid :: IssueNumber
iid =
Maybe Auth
-> GenRequest 'MtJSON 'RO (Vector IssueComment)
-> IO (Either Error (Vector IssueComment))
forall am (mt :: MediaType *) a.
(AuthMethod am, ParseResponse mt a) =>
Maybe am -> GenRequest mt 'RO a -> IO (Either Error a)
executeRequestMaybe Maybe Auth
auth (GenRequest 'MtJSON 'RO (Vector IssueComment)
-> IO (Either Error (Vector IssueComment)))
-> GenRequest 'MtJSON 'RO (Vector IssueComment)
-> IO (Either Error (Vector IssueComment))
forall a b. (a -> b) -> a -> b
$ Name Owner
-> Name Repo
-> IssueNumber
-> FetchCount
-> GenRequest 'MtJSON 'RO (Vector IssueComment)
forall (k :: RW).
Name Owner
-> Name Repo
-> IssueNumber
-> FetchCount
-> Request k (Vector IssueComment)
commentsR Name Owner
user Name Repo
repo IssueNumber
iid FetchCount
FetchAll
commentsR :: Name Owner -> Name Repo -> IssueNumber -> FetchCount -> Request k (Vector IssueComment)
user :: Name Owner
user repo :: Name Repo
repo iid :: IssueNumber
iid =
Paths
-> QueryString -> FetchCount -> Request k (Vector IssueComment)
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, "issues", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
iid, "comments"] []
createComment :: Auth -> Name Owner -> Name Repo -> IssueNumber -> Text
-> IO (Either Error Comment)
auth :: Auth
auth user :: Name Owner
user repo :: Name Repo
repo iss :: IssueNumber
iss 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
-> GenRequest 'MtJSON 'RW Comment
createCommentR Name Owner
user Name Repo
repo IssueNumber
iss Text
body
createCommentR :: Name Owner -> Name Repo -> IssueNumber -> Text -> Request 'RW Comment
user :: Name Owner
user repo :: Name Repo
repo iss :: IssueNumber
iss body :: Text
body =
CommandMethod
-> Paths -> ByteString -> GenRequest 'MtJSON 'RW Comment
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post Paths
parts (NewComment -> ByteString
forall a. ToJSON a => a -> ByteString
encode (NewComment -> ByteString) -> NewComment -> ByteString
forall a b. (a -> b) -> a -> b
$ Text -> NewComment
NewComment 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, "issues", IssueNumber -> Text
forall a. IsPathPart a => a -> Text
toPathPart IssueNumber
iss, "comments"]
editComment :: Auth -> Name Owner -> Name Repo -> Id Comment -> Text
-> IO (Either Error Comment)
auth :: Auth
auth user :: Name Owner
user repo :: Name Repo
repo commid :: Id Comment
commid 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
-> Id Comment
-> Text
-> GenRequest 'MtJSON 'RW Comment
editCommentR Name Owner
user Name Repo
repo Id Comment
commid Text
body
editCommentR :: Name Owner -> Name Repo -> Id Comment -> Text -> Request 'RW Comment
user :: Name Owner
user repo :: Name Repo
repo commid :: Id Comment
commid body :: Text
body =
CommandMethod
-> Paths -> ByteString -> GenRequest 'MtJSON 'RW Comment
forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Patch Paths
parts (EditComment -> ByteString
forall a. ToJSON a => a -> ByteString
encode (EditComment -> ByteString) -> EditComment -> ByteString
forall a b. (a -> b) -> a -> b
$ Text -> EditComment
EditComment 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, "issues", "comments", Id Comment -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Comment
commid]
deleteComment :: Auth -> Name Owner -> Name Repo -> Id Comment
-> IO (Either Error ())
auth :: Auth
auth user :: Name Owner
user repo :: Name Repo
repo commid :: Id Comment
commid =
Auth -> GenRequest 'MtUnit 'RW () -> IO (Either Error ())
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 'MtUnit 'RW () -> IO (Either Error ()))
-> GenRequest 'MtUnit 'RW () -> IO (Either Error ())
forall a b. (a -> b) -> a -> b
$ Name Owner -> Name Repo -> Id Comment -> GenRequest 'MtUnit 'RW ()
deleteCommentR Name Owner
user Name Repo
repo Id Comment
commid
deleteCommentR :: Name Owner -> Name Repo -> Id Comment -> GenRequest 'MtUnit 'RW ()
user :: Name Owner
user repo :: Name Repo
repo commid :: Id Comment
commid =
CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType *) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete Paths
parts ByteString
forall a. Monoid a => a
mempty
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, "issues", "comments", Id Comment -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Comment
commid]