{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}

-- | Provides actions for Channel API interactions
module Discord.Internal.Rest.Invite
  ( InviteRequest(..)
  ) where

import Network.HTTP.Req ((/:))
import qualified Network.HTTP.Req as R
import qualified Data.Text as T

import Discord.Internal.Rest.Prelude
import Discord.Internal.Types

instance Request (InviteRequest a) where
  majorRoute :: InviteRequest a -> String
majorRoute = forall a. InviteRequest a -> String
inviteMajorRoute
  jsonRequest :: InviteRequest a -> JsonRequest
jsonRequest = forall a. InviteRequest a -> JsonRequest
inviteJsonRequest


-- | Data constructor for requests. See <https://discord.com/developers/docs/resources/ API>
data InviteRequest a where
  -- | Get invite for given code
  GetInvite :: T.Text -> InviteRequest Invite
  -- | Delete invite by code
  DeleteInvite :: T.Text -> InviteRequest Invite

inviteMajorRoute :: InviteRequest a -> String
inviteMajorRoute :: forall a. InviteRequest a -> String
inviteMajorRoute InviteRequest a
c = case InviteRequest a
c of
  (GetInvite Text
_) ->     String
"invite "
  (DeleteInvite Text
_) ->  String
"invite "

invite :: R.Url 'R.Https
invite :: Url 'Https
invite = Url 'Https
baseUrl forall (scheme :: Scheme). Url scheme -> Text -> Url scheme
/: Text
"invites"

inviteJsonRequest :: InviteRequest r -> JsonRequest
inviteJsonRequest :: forall a. InviteRequest a -> JsonRequest
inviteJsonRequest InviteRequest r
c = case InviteRequest r
c of
  (GetInvite Text
g) -> Url 'Https -> Option 'Https -> JsonRequest
Get (Url 'Https
invite forall (scheme :: Scheme). Url scheme -> Text -> Url scheme
R./: Text
g) forall a. Monoid a => a
mempty
  (DeleteInvite Text
g) -> Url 'Https -> Option 'Https -> JsonRequest
Delete (Url 'Https
invite forall (scheme :: Scheme). Url scheme -> Text -> Url scheme
R./: Text
g) forall a. Monoid a => a
mempty