{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
module Discord.Rest.Invite
( InviteRequest(..)
) where
import Data.Monoid (mempty)
import Network.HTTP.Req ((/:))
import qualified Network.HTTP.Req as R
import qualified Data.Text as T
import Discord.Rest.Prelude
import Discord.Types
instance Request (InviteRequest a) where
majorRoute = inviteMajorRoute
jsonRequest = inviteJsonRequest
data InviteRequest a where
GetInvite :: T.Text -> InviteRequest Invite
DeleteInvite :: T.Text -> InviteRequest Invite
inviteMajorRoute :: InviteRequest a -> String
inviteMajorRoute c = case c of
(GetInvite _) -> "invite "
(DeleteInvite _) -> "invite "
baseUrl :: R.Url 'R.Https
baseUrl = R.https "discordapp.com" R./: "api" R./: apiVersion
where apiVersion = "v6"
invite :: R.Url 'R.Https
invite = baseUrl /: "invites"
inviteJsonRequest :: InviteRequest r -> JsonRequest
inviteJsonRequest c = case c of
(GetInvite g) -> Get (invite R./: g) mempty
(DeleteInvite g) -> Delete (invite R./: g) mempty