{-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Discord.Internal.Rest.Interactions where import Data.Aeson (encode) import qualified Data.ByteString.Lazy as BL import Discord.Internal.Rest.Prelude import Discord.Internal.Types import Discord.Internal.Types.Interactions import Network.HTTP.Client.MultipartFormData (PartM, partBS) import Network.HTTP.Req ((/:)) import qualified Network.HTTP.Req as R import qualified Data.Text as T data InteractionResponseRequest a where CreateInteractionResponse :: InteractionId -> InteractionToken -> InteractionResponse -> InteractionResponseRequest () GetOriginalInteractionResponse :: ApplicationId -> InteractionToken -> InteractionResponseRequest Message EditOriginalInteractionResponse :: ApplicationId -> InteractionToken -> InteractionResponseMessage -> InteractionResponseRequest Message DeleteOriginalInteractionResponse :: ApplicationId -> InteractionToken -> InteractionResponseRequest () CreateFollowupInteractionMessage :: ApplicationId -> InteractionToken -> InteractionResponseMessage -> InteractionResponseRequest Message GetFollowupInteractionMessage :: ApplicationId -> InteractionToken -> MessageId -> InteractionResponseRequest Message EditFollowupInteractionMessage :: ApplicationId -> InteractionToken -> MessageId -> InteractionResponse -> InteractionResponseRequest Message DeleteFollowupInteractionMessage :: ApplicationId -> InteractionToken -> MessageId -> InteractionResponseRequest () instance Request (InteractionResponseRequest a) where jsonRequest :: InteractionResponseRequest a -> JsonRequest jsonRequest = InteractionResponseRequest a -> JsonRequest forall a. InteractionResponseRequest a -> JsonRequest interactionResponseJsonRequest majorRoute :: InteractionResponseRequest a -> String majorRoute = InteractionResponseRequest a -> String forall a. InteractionResponseRequest a -> String interactionResponseMajorRoute interactionResponseMajorRoute :: InteractionResponseRequest a -> String interactionResponseMajorRoute :: InteractionResponseRequest a -> String interactionResponseMajorRoute InteractionResponseRequest a a = case InteractionResponseRequest a a of (CreateInteractionResponse InteractionId iid InteractionToken _ InteractionResponse _) -> String "intresp " String -> String -> String forall a. Semigroup a => a -> a -> a <> InteractionId -> String forall a. Show a => a -> String show InteractionId iid (GetOriginalInteractionResponse ApplicationId aid InteractionToken _) -> String "intresp " String -> String -> String forall a. Semigroup a => a -> a -> a <> ApplicationId -> String forall a. Show a => a -> String show ApplicationId aid (EditOriginalInteractionResponse ApplicationId aid InteractionToken _ InteractionResponseMessage _) -> String "intresp " String -> String -> String forall a. Semigroup a => a -> a -> a <> ApplicationId -> String forall a. Show a => a -> String show ApplicationId aid (DeleteOriginalInteractionResponse ApplicationId aid InteractionToken _) -> String "intresp " String -> String -> String forall a. Semigroup a => a -> a -> a <> ApplicationId -> String forall a. Show a => a -> String show ApplicationId aid (CreateFollowupInteractionMessage ApplicationId iid InteractionToken _ InteractionResponseMessage _) -> String "intrespf " String -> String -> String forall a. Semigroup a => a -> a -> a <> ApplicationId -> String forall a. Show a => a -> String show ApplicationId iid (GetFollowupInteractionMessage ApplicationId aid InteractionToken _ MessageId _) -> String "intrespf " String -> String -> String forall a. Semigroup a => a -> a -> a <> ApplicationId -> String forall a. Show a => a -> String show ApplicationId aid (EditFollowupInteractionMessage ApplicationId aid InteractionToken _ MessageId _ InteractionResponse _) -> String "intrespf " String -> String -> String forall a. Semigroup a => a -> a -> a <> ApplicationId -> String forall a. Show a => a -> String show ApplicationId aid (DeleteFollowupInteractionMessage ApplicationId aid InteractionToken _ MessageId _) -> String "intrespf " String -> String -> String forall a. Semigroup a => a -> a -> a <> ApplicationId -> String forall a. Show a => a -> String show ApplicationId aid interaction :: ApplicationId -> InteractionToken -> R.Url 'R.Https interaction :: ApplicationId -> InteractionToken -> Url 'Https interaction ApplicationId aid InteractionToken it = Url 'Https baseUrl Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: Text "webhooks" Url 'Https -> ApplicationId -> Url 'Https forall a (scheme :: Scheme). Show a => Url scheme -> a -> Url scheme // ApplicationId aid Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: InteractionToken -> Text fromToken InteractionToken it Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: Text "messages" interactionResponseJsonRequest :: InteractionResponseRequest a -> JsonRequest interactionResponseJsonRequest :: InteractionResponseRequest a -> JsonRequest interactionResponseJsonRequest InteractionResponseRequest a a = case InteractionResponseRequest a a of (CreateInteractionResponse InteractionId iid InteractionToken it InteractionResponse i) -> Url 'Https -> RestIO ReqBodyMultipart -> Option 'Https -> JsonRequest forall a. HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest Post (Url 'Https baseUrl Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: Text "interactions" Url 'Https -> InteractionId -> Url 'Https forall a (scheme :: Scheme). Show a => Url scheme -> a -> Url scheme // InteractionId iid Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: InteractionToken -> Text fromToken InteractionToken it Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: Text "callback") (InteractionResponse -> RestIO ReqBodyMultipart convert InteractionResponse i) Option 'Https forall a. Monoid a => a mempty (GetOriginalInteractionResponse ApplicationId aid InteractionToken it) -> Url 'Https -> Option 'Https -> JsonRequest Get (ApplicationId -> InteractionToken -> Url 'Https interaction ApplicationId aid InteractionToken it Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: Text "@original") Option 'Https forall a. Monoid a => a mempty (EditOriginalInteractionResponse ApplicationId aid InteractionToken it InteractionResponseMessage i) -> Url 'Https -> RestIO ReqBodyMultipart -> Option 'Https -> JsonRequest forall a. HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest Patch (ApplicationId -> InteractionToken -> Url 'Https interaction ApplicationId aid InteractionToken it Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: Text "@original") (InteractionResponseMessage -> RestIO ReqBodyMultipart convertIRM InteractionResponseMessage i) Option 'Https forall a. Monoid a => a mempty (DeleteOriginalInteractionResponse ApplicationId aid InteractionToken it) -> Url 'Https -> Option 'Https -> JsonRequest Delete (ApplicationId -> InteractionToken -> Url 'Https interaction ApplicationId aid InteractionToken it Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: Text "@original") Option 'Https forall a. Monoid a => a mempty (CreateFollowupInteractionMessage ApplicationId aid InteractionToken it InteractionResponseMessage i) -> Url 'Https -> RestIO ReqBodyMultipart -> Option 'Https -> JsonRequest forall a. HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest Post (Url 'Https baseUrl Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: Text "webhooks" Url 'Https -> ApplicationId -> Url 'Https forall a (scheme :: Scheme). Show a => Url scheme -> a -> Url scheme // ApplicationId aid Url 'Https -> Text -> Url 'Https forall (scheme :: Scheme). Url scheme -> Text -> Url scheme /: InteractionToken -> Text fromToken InteractionToken it) (InteractionResponseMessage -> RestIO ReqBodyMultipart convertIRM InteractionResponseMessage i) Option 'Https forall a. Monoid a => a mempty (GetFollowupInteractionMessage ApplicationId aid InteractionToken it MessageId mid) -> Url 'Https -> Option 'Https -> JsonRequest Get (ApplicationId -> InteractionToken -> Url 'Https interaction ApplicationId aid InteractionToken it Url 'Https -> MessageId -> Url 'Https forall a (scheme :: Scheme). Show a => Url scheme -> a -> Url scheme // MessageId mid) Option 'Https forall a. Monoid a => a mempty (EditFollowupInteractionMessage ApplicationId aid InteractionToken it MessageId mid InteractionResponse i) -> Url 'Https -> RestIO ReqBodyMultipart -> Option 'Https -> JsonRequest forall a. HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest Patch (ApplicationId -> InteractionToken -> Url 'Https interaction ApplicationId aid InteractionToken it Url 'Https -> MessageId -> Url 'Https forall a (scheme :: Scheme). Show a => Url scheme -> a -> Url scheme // MessageId mid) (InteractionResponse -> RestIO ReqBodyMultipart convert InteractionResponse i) Option 'Https forall a. Monoid a => a mempty (DeleteFollowupInteractionMessage ApplicationId aid InteractionToken it MessageId mid) -> Url 'Https -> Option 'Https -> JsonRequest Delete (ApplicationId -> InteractionToken -> Url 'Https interaction ApplicationId aid InteractionToken it Url 'Https -> MessageId -> Url 'Https forall a (scheme :: Scheme). Show a => Url scheme -> a -> Url scheme // MessageId mid) Option 'Https forall a. Monoid a => a mempty where convert :: InteractionResponse -> RestIO R.ReqBodyMultipart convert :: InteractionResponse -> RestIO ReqBodyMultipart convert ir :: InteractionResponse ir@(InteractionResponseChannelMessage InteractionResponseMessage irm) = [Part] -> RestIO ReqBodyMultipart forall (m :: * -> *). MonadIO m => [Part] -> m ReqBodyMultipart R.reqBodyMultipart (Text -> ByteString -> Part forall (m :: * -> *). Applicative m => Text -> ByteString -> PartM m partBS Text "payload_json" (ByteString -> ByteString BL.toStrict (ByteString -> ByteString) -> ByteString -> ByteString forall a b. (a -> b) -> a -> b $ InteractionResponse -> ByteString forall a. ToJSON a => a -> ByteString encode InteractionResponse ir) Part -> [Part] -> [Part] forall a. a -> [a] -> [a] : InteractionResponseMessage -> [Part] convert' InteractionResponseMessage irm) convert ir :: InteractionResponse ir@(InteractionResponseUpdateMessage InteractionResponseMessage irm) = [Part] -> RestIO ReqBodyMultipart forall (m :: * -> *). MonadIO m => [Part] -> m ReqBodyMultipart R.reqBodyMultipart (Text -> ByteString -> Part forall (m :: * -> *). Applicative m => Text -> ByteString -> PartM m partBS Text "payload_json" (ByteString -> ByteString BL.toStrict (ByteString -> ByteString) -> ByteString -> ByteString forall a b. (a -> b) -> a -> b $ InteractionResponse -> ByteString forall a. ToJSON a => a -> ByteString encode InteractionResponse ir) Part -> [Part] -> [Part] forall a. a -> [a] -> [a] : InteractionResponseMessage -> [Part] convert' InteractionResponseMessage irm) convert InteractionResponse ir = [Part] -> RestIO ReqBodyMultipart forall (m :: * -> *). MonadIO m => [Part] -> m ReqBodyMultipart R.reqBodyMultipart [Text -> ByteString -> Part forall (m :: * -> *). Applicative m => Text -> ByteString -> PartM m partBS Text "payload_json" (ByteString -> Part) -> ByteString -> Part forall a b. (a -> b) -> a -> b $ ByteString -> ByteString BL.toStrict (ByteString -> ByteString) -> ByteString -> ByteString forall a b. (a -> b) -> a -> b $ InteractionResponse -> ByteString forall a. ToJSON a => a -> ByteString encode InteractionResponse ir] convertIRM :: InteractionResponseMessage -> RestIO R.ReqBodyMultipart convertIRM :: InteractionResponseMessage -> RestIO ReqBodyMultipart convertIRM InteractionResponseMessage irm = [Part] -> RestIO ReqBodyMultipart forall (m :: * -> *). MonadIO m => [Part] -> m ReqBodyMultipart R.reqBodyMultipart (Text -> ByteString -> Part forall (m :: * -> *). Applicative m => Text -> ByteString -> PartM m partBS Text "payload_json" (ByteString -> ByteString BL.toStrict (ByteString -> ByteString) -> ByteString -> ByteString forall a b. (a -> b) -> a -> b $ InteractionResponseMessage -> ByteString forall a. ToJSON a => a -> ByteString encode InteractionResponseMessage irm) Part -> [Part] -> [Part] forall a. a -> [a] -> [a] : InteractionResponseMessage -> [Part] convert' InteractionResponseMessage irm) convert' :: InteractionResponseMessage -> [PartM IO] convert' :: InteractionResponseMessage -> [Part] convert' InteractionResponseMessage {Maybe Bool Maybe [CreateEmbed] Maybe [ActionRow] Maybe [Attachment] Maybe Text Maybe AllowedMentions Maybe InteractionResponseMessageFlags interactionResponseMessageAttachments :: InteractionResponseMessage -> Maybe [Attachment] interactionResponseMessageComponents :: InteractionResponseMessage -> Maybe [ActionRow] interactionResponseMessageFlags :: InteractionResponseMessage -> Maybe InteractionResponseMessageFlags interactionResponseMessageAllowedMentions :: InteractionResponseMessage -> Maybe AllowedMentions interactionResponseMessageEmbeds :: InteractionResponseMessage -> Maybe [CreateEmbed] interactionResponseMessageContent :: InteractionResponseMessage -> Maybe Text interactionResponseMessageTTS :: InteractionResponseMessage -> Maybe Bool interactionResponseMessageAttachments :: Maybe [Attachment] interactionResponseMessageComponents :: Maybe [ActionRow] interactionResponseMessageFlags :: Maybe InteractionResponseMessageFlags interactionResponseMessageAllowedMentions :: Maybe AllowedMentions interactionResponseMessageEmbeds :: Maybe [CreateEmbed] interactionResponseMessageContent :: Maybe Text interactionResponseMessageTTS :: Maybe Bool ..} = case Maybe [CreateEmbed] interactionResponseMessageEmbeds of Maybe [CreateEmbed] Nothing -> [] Just [CreateEmbed] f -> (Maybe CreateEmbed -> [Part] maybeEmbed (Maybe CreateEmbed -> [Part]) -> (CreateEmbed -> Maybe CreateEmbed) -> CreateEmbed -> [Part] forall b c a. (b -> c) -> (a -> b) -> a -> c . CreateEmbed -> Maybe CreateEmbed forall a. a -> Maybe a Just) (CreateEmbed -> [Part]) -> [CreateEmbed] -> [Part] forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< [CreateEmbed] f fromToken :: InteractionToken -> T.Text fromToken :: InteractionToken -> Text fromToken (InteractionToken Text t) = Text t