-----------------------------------------------------------------------------
-- |
-- License     :  BSD-3-Clause
-- Maintainer  :  Oleg Grenrus <oleg.grenrus@iki.fi>
--
-- The Github issue events API, which is described on
-- <http://developer.github.com/v3/issues/events/>
module GitHub.Endpoints.Issues.Events (
    eventsForIssueR,
    eventsForRepoR,
    eventR,
    module GitHub.Data,
    ) where

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

-- | List events for an issue.
-- See <https://developer.github.com/v3/issues/events/#list-events-for-an-issue>
eventsForIssueR :: Name Owner -> Name Repo -> Id Issue -> FetchCount -> Request k (Vector IssueEvent)
eventsForIssueR :: forall (k :: RW).
Name Owner
-> Name Repo
-> Id Issue
-> FetchCount
-> Request k (Vector IssueEvent)
eventsForIssueR Name Owner
user Name Repo
repo Id Issue
iid =
    Paths -> QueryString -> FetchCount -> Request k (Vector IssueEvent)
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
"issues", Id Issue -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Issue
iid, Text
"events"] []

-- | List events for a repository.
-- See <https://developer.github.com/v3/issues/events/#list-events-for-a-repository>
eventsForRepoR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector IssueEvent)
eventsForRepoR :: forall (k :: RW).
Name Owner
-> Name Repo -> FetchCount -> Request k (Vector IssueEvent)
eventsForRepoR Name Owner
user Name Repo
repo =
    Paths -> QueryString -> FetchCount -> Request k (Vector IssueEvent)
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
"issues", Text
"events"] []

-- | Query a single event.
-- See <https://developer.github.com/v3/issues/events/#get-a-single-event>
eventR :: Name Owner -> Name Repo -> Id IssueEvent -> Request k IssueEvent
eventR :: forall (k :: RW).
Name Owner -> Name Repo -> Id IssueEvent -> Request k IssueEvent
eventR Name Owner
user Name Repo
repo Id IssueEvent
eid =
    Paths -> QueryString -> Request k IssueEvent
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
"issues", Text
"events", Id IssueEvent -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id IssueEvent
eid] []