-----------------------------------------------------------------------------
-- |
-- License     :  BSD-3-Clause
-- Maintainer  :  Oleg Grenrus <oleg.grenrus@iki.fi>
--
-- The user emails API as described on
-- <http://developer.github.com/v3/users/emails/>.
module GitHub.Endpoints.Users.Emails (
    currentUserEmails',
    currentUserEmailsR,
    currentUserPublicEmails',
    currentUserPublicEmailsR,
    module GitHub.Data,
    ) where

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

-- | List email addresses for the authenticated user.
--
-- > currentUserEmails' (OAuth "token")
currentUserEmails' :: Auth -> IO (Either Error (Vector Email))
currentUserEmails' :: Auth -> IO (Either Error (Vector Email))
currentUserEmails' auth :: Auth
auth =
    Auth
-> GenRequest 'MtJSON 'RA (Vector Email)
-> IO (Either Error (Vector Email))
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 'RA (Vector Email)
 -> IO (Either Error (Vector Email)))
-> GenRequest 'MtJSON 'RA (Vector Email)
-> IO (Either Error (Vector Email))
forall a b. (a -> b) -> a -> b
$ FetchCount -> GenRequest 'MtJSON 'RA (Vector Email)
currentUserEmailsR FetchCount
FetchAll

-- | List email addresses.
-- See <https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user>
currentUserEmailsR :: FetchCount -> Request 'RA (Vector Email)
currentUserEmailsR :: FetchCount -> GenRequest 'MtJSON 'RA (Vector Email)
currentUserEmailsR =
    Paths
-> QueryString
-> FetchCount
-> GenRequest 'MtJSON 'RA (Vector Email)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery ["user", "emails"] []

-- | List public email addresses for the authenticated user.
--
-- > currentUserPublicEmails' (OAuth "token")
currentUserPublicEmails' :: Auth -> IO (Either Error (Vector Email))
currentUserPublicEmails' :: Auth -> IO (Either Error (Vector Email))
currentUserPublicEmails' auth :: Auth
auth =
    Auth
-> GenRequest 'MtJSON 'RA (Vector Email)
-> IO (Either Error (Vector Email))
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 'RA (Vector Email)
 -> IO (Either Error (Vector Email)))
-> GenRequest 'MtJSON 'RA (Vector Email)
-> IO (Either Error (Vector Email))
forall a b. (a -> b) -> a -> b
$ FetchCount -> GenRequest 'MtJSON 'RA (Vector Email)
currentUserPublicEmailsR FetchCount
FetchAll

-- | List public email addresses.
-- See <https://developer.github.com/v3/users/emails/#list-public-email-addresses-for-a-user>
currentUserPublicEmailsR :: FetchCount -> Request 'RA (Vector Email)
currentUserPublicEmailsR :: FetchCount -> GenRequest 'MtJSON 'RA (Vector Email)
currentUserPublicEmailsR =
    Paths
-> QueryString
-> FetchCount
-> GenRequest 'MtJSON 'RA (Vector Email)
forall a (mt :: RW).
FromJSON a =>
Paths -> QueryString -> FetchCount -> Request mt (Vector a)
pagedQuery ["user", "public_emails"] []