-- |
-- The repo statuses API as described on
-- <https://developer.github.com/v3/repos/statuses/>.

module GitHub.Endpoints.Repos.Statuses (
    createStatusR,
    statusesForR,
    statusForR,
    module GitHub.Data
    ) where

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

-- | Create a new status
-- See <https://developer.github.com/v3/repos/statuses/#create-a-status>
createStatusR :: Name Owner -> Name Repo -> Name Commit -> NewStatus -> Request 'RW Status
createStatusR :: Name Owner
-> Name Repo -> Name Commit -> NewStatus -> Request 'RW Status
createStatusR Name Owner
owner Name Repo
repo Name Commit
sha =
    forall a. CommandMethod -> Paths -> ByteString -> Request 'RW a
command CommandMethod
Post Paths
parts forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ToJSON a => a -> ByteString
encode
    where
        parts :: Paths
parts = [Text
"repos", forall a. IsPathPart a => a -> Text
toPathPart Name Owner
owner, forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"statuses", forall a. IsPathPart a => a -> Text
toPathPart Name Commit
sha]

-- | All statuses for a commit
-- See <https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref>
statusesForR :: Name Owner -> Name Repo -> Name Commit -> FetchCount -> Request 'RW (Vector Status)
statusesForR :: Name Owner
-> Name Repo
-> Name Commit
-> FetchCount
-> Request 'RW (Vector Status)
statusesForR Name Owner
user Name Repo
repo Name Commit
sha =
    forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery [Text
"repos", forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"commits", forall a. IsPathPart a => a -> Text
toPathPart Name Commit
sha, Text
"statuses"] []

-- | The combined status for a specific commit
-- See <https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref>
statusForR :: Name Owner -> Name Repo -> Name Commit -> Request 'RW CombinedStatus
statusForR :: Name Owner
-> Name Repo -> Name Commit -> Request 'RW CombinedStatus
statusForR Name Owner
user Name Repo
repo Name Commit
sha =
    forall (mt :: RW) a. Paths -> QueryString -> Request mt a
query [Text
"repos", forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"commits", forall a. IsPathPart a => a -> Text
toPathPart Name Commit
sha, Text
"status"] []