-----------------------------------------------------------------------------
-- |
-- License     :  BSD-3-Clause
-- Maintainer  :  Oleg Grenrus <oleg.grenrus@iki.fi>
--
-- The reviews API as described on <http://developer.github.com/v3/pulls/reviews/>.
module GitHub.Endpoints.PullRequests.Reviews
    ( pullRequestReviewsR
    , pullRequestReviewR
    , pullRequestReviewCommentsR
    , module GitHub.Data
    ) where

import GitHub.Data
import GitHub.Internal.Prelude
import Prelude ()

-- | List reviews for a pull request.
-- See <https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request>
pullRequestReviewsR
    :: Name Owner
    -> Name Repo
    -> IssueNumber
    -> FetchCount
    -> Request k (Vector Review)
pullRequestReviewsR :: forall (k :: RW).
Name Owner
-> Name Repo
-> IssueNumber
-> FetchCount
-> Request k (Vector Review)
pullRequestReviewsR Name Owner
owner Name Repo
repo IssueNumber
prid =
    Paths -> QueryString -> FetchCount -> Request k (Vector Review)
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
owner
        , 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
"reviews"
        ]
        []

-- | Query a single pull request review.
-- see <https://developer.github.com/v3/pulls/reviews/#get-a-single-review>
pullRequestReviewR
    :: Name Owner
    -> Name Repo
    -> IssueNumber
    -> Id Review
    -> Request k Review
pullRequestReviewR :: forall (k :: RW).
Name Owner
-> Name Repo -> IssueNumber -> Id Review -> Request k Review
pullRequestReviewR Name Owner
owner Name Repo
repo IssueNumber
prid Id Review
rid =
    Paths -> QueryString -> Request k Review
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query
        [ Text
"repos"
        , Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
owner
        , 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
"reviews"
        , Id Review -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Review
rid
        ]
        []

-- | Query the comments for a single pull request review.
-- see <https://developer.github.com/v3/pulls/reviews/#get-comments-for-a-single-review>
pullRequestReviewCommentsR
    :: Name Owner
    -> Name Repo
    -> IssueNumber
    -> Id Review
    -> Request k [ReviewComment]
pullRequestReviewCommentsR :: forall (k :: RW).
Name Owner
-> Name Repo
-> IssueNumber
-> Id Review
-> Request k [ReviewComment]
pullRequestReviewCommentsR Name Owner
owner Name Repo
repo IssueNumber
prid Id Review
rid =
    Paths -> QueryString -> Request k [ReviewComment]
forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query
        [ Text
"repos"
        , Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
owner
        , 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
"reviews"
        , Id Review -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Review
rid
        , Text
"comments"
        ]
        []