{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}

-- | Webhook endpoints
module Calamity.HTTP.Webhook (
  WebhookRequest (..),
  CreateWebhookData (..),
  ModifyWebhookData (..),
  ExecuteWebhookOptions (..),
) where

import Calamity.HTTP.Channel (AllowedMentions, CreateMessageAttachment (..))
import Calamity.HTTP.Internal.Request
import Calamity.HTTP.Internal.Route
import Calamity.Internal.Utils (CalamityToJSON (..), CalamityToJSON' (..), (.=), (.?=))
import Calamity.Types.Model.Channel
import Calamity.Types.Model.Guild
import Calamity.Types.Snowflake
import Data.Aeson qualified as Aeson
import Data.Default.Class
import Data.Text (Text)
import Data.Text qualified as T
import Network.HTTP.Client.MultipartFormData
import Network.HTTP.Req
import Network.Mime
import Optics

data CreateWebhookData = CreateWebhookData
  { CreateWebhookData -> Maybe Text
username :: Maybe Text
  , CreateWebhookData -> Maybe Text
avatar :: Maybe Text
  -- ^ The avatar field should be in discord's image data format: https://discord.com/developers/docs/reference#image-data
  }
  deriving (Int -> CreateWebhookData -> ShowS
[CreateWebhookData] -> ShowS
CreateWebhookData -> String
(Int -> CreateWebhookData -> ShowS)
-> (CreateWebhookData -> String)
-> ([CreateWebhookData] -> ShowS)
-> Show CreateWebhookData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateWebhookData -> ShowS
showsPrec :: Int -> CreateWebhookData -> ShowS
$cshow :: CreateWebhookData -> String
show :: CreateWebhookData -> String
$cshowList :: [CreateWebhookData] -> ShowS
showList :: [CreateWebhookData] -> ShowS
Show)
  deriving ([CreateWebhookData] -> Value
[CreateWebhookData] -> Encoding
CreateWebhookData -> Value
CreateWebhookData -> Encoding
(CreateWebhookData -> Value)
-> (CreateWebhookData -> Encoding)
-> ([CreateWebhookData] -> Value)
-> ([CreateWebhookData] -> Encoding)
-> ToJSON CreateWebhookData
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: CreateWebhookData -> Value
toJSON :: CreateWebhookData -> Value
$ctoEncoding :: CreateWebhookData -> Encoding
toEncoding :: CreateWebhookData -> Encoding
$ctoJSONList :: [CreateWebhookData] -> Value
toJSONList :: [CreateWebhookData] -> Value
$ctoEncodingList :: [CreateWebhookData] -> Encoding
toEncodingList :: [CreateWebhookData] -> Encoding
Aeson.ToJSON) via CalamityToJSON CreateWebhookData

instance CalamityToJSON' CreateWebhookData where
  toPairs :: forall kv. KeyValue kv => CreateWebhookData -> [Maybe kv]
toPairs CreateWebhookData {Maybe Text
$sel:username:CreateWebhookData :: CreateWebhookData -> Maybe Text
$sel:avatar:CreateWebhookData :: CreateWebhookData -> Maybe Text
username :: Maybe Text
avatar :: Maybe Text
..} =
    [ Key
"username" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
username
    , Key
"avatar" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
avatar
    ]

instance Default CreateWebhookData where
  def :: CreateWebhookData
def = Maybe Text -> Maybe Text -> CreateWebhookData
CreateWebhookData Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing

data ModifyWebhookData = ModifyWebhookData
  { ModifyWebhookData -> Maybe Text
username :: Maybe Text
  , ModifyWebhookData -> Maybe Text
avatar :: Maybe Text
  -- ^ The avatar field should be in discord's image data format: https://discord.com/developers/docs/reference#image-data
  , ModifyWebhookData -> Maybe (Snowflake Channel)
channelID :: Maybe (Snowflake Channel)
  }
  deriving (Int -> ModifyWebhookData -> ShowS
[ModifyWebhookData] -> ShowS
ModifyWebhookData -> String
(Int -> ModifyWebhookData -> ShowS)
-> (ModifyWebhookData -> String)
-> ([ModifyWebhookData] -> ShowS)
-> Show ModifyWebhookData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ModifyWebhookData -> ShowS
showsPrec :: Int -> ModifyWebhookData -> ShowS
$cshow :: ModifyWebhookData -> String
show :: ModifyWebhookData -> String
$cshowList :: [ModifyWebhookData] -> ShowS
showList :: [ModifyWebhookData] -> ShowS
Show)
  deriving ([ModifyWebhookData] -> Value
[ModifyWebhookData] -> Encoding
ModifyWebhookData -> Value
ModifyWebhookData -> Encoding
(ModifyWebhookData -> Value)
-> (ModifyWebhookData -> Encoding)
-> ([ModifyWebhookData] -> Value)
-> ([ModifyWebhookData] -> Encoding)
-> ToJSON ModifyWebhookData
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ModifyWebhookData -> Value
toJSON :: ModifyWebhookData -> Value
$ctoEncoding :: ModifyWebhookData -> Encoding
toEncoding :: ModifyWebhookData -> Encoding
$ctoJSONList :: [ModifyWebhookData] -> Value
toJSONList :: [ModifyWebhookData] -> Value
$ctoEncodingList :: [ModifyWebhookData] -> Encoding
toEncodingList :: [ModifyWebhookData] -> Encoding
Aeson.ToJSON) via CalamityToJSON ModifyWebhookData

instance CalamityToJSON' ModifyWebhookData where
  toPairs :: forall kv. KeyValue kv => ModifyWebhookData -> [Maybe kv]
toPairs ModifyWebhookData {Maybe Text
Maybe (Snowflake Channel)
$sel:username:ModifyWebhookData :: ModifyWebhookData -> Maybe Text
$sel:avatar:ModifyWebhookData :: ModifyWebhookData -> Maybe Text
$sel:channelID:ModifyWebhookData :: ModifyWebhookData -> Maybe (Snowflake Channel)
username :: Maybe Text
avatar :: Maybe Text
channelID :: Maybe (Snowflake Channel)
..} =
    [ Key
"username" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
username
    , Key
"avatar" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
avatar
    , Key
"channel_id" Key -> Maybe (Snowflake Channel) -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe (Snowflake Channel)
channelID
    ]

instance Default ModifyWebhookData where
  def :: ModifyWebhookData
def = Maybe Text
-> Maybe Text -> Maybe (Snowflake Channel) -> ModifyWebhookData
ModifyWebhookData Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe (Snowflake Channel)
forall a. Maybe a
Nothing

data ExecuteWebhookOptions = ExecuteWebhookOptions
  { ExecuteWebhookOptions -> Maybe Bool
wait :: Maybe Bool
  , ExecuteWebhookOptions -> Maybe Text
content :: Maybe Text
  , ExecuteWebhookOptions -> [CreateMessageAttachment]
attachments :: [CreateMessageAttachment]
  , ExecuteWebhookOptions -> Maybe [Embed]
embeds :: Maybe [Embed]
  , ExecuteWebhookOptions -> Maybe Text
username :: Maybe Text
  , ExecuteWebhookOptions -> Maybe Text
avatarUrl :: Maybe Text
  , ExecuteWebhookOptions -> Maybe AllowedMentions
allowedMentions :: Maybe AllowedMentions
  , ExecuteWebhookOptions -> Maybe Bool
tts :: Maybe Bool
  , ExecuteWebhookOptions -> [Component]
components :: [Component]
  }
  deriving (Int -> ExecuteWebhookOptions -> ShowS
[ExecuteWebhookOptions] -> ShowS
ExecuteWebhookOptions -> String
(Int -> ExecuteWebhookOptions -> ShowS)
-> (ExecuteWebhookOptions -> String)
-> ([ExecuteWebhookOptions] -> ShowS)
-> Show ExecuteWebhookOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExecuteWebhookOptions -> ShowS
showsPrec :: Int -> ExecuteWebhookOptions -> ShowS
$cshow :: ExecuteWebhookOptions -> String
show :: ExecuteWebhookOptions -> String
$cshowList :: [ExecuteWebhookOptions] -> ShowS
showList :: [ExecuteWebhookOptions] -> ShowS
Show)

instance Default ExecuteWebhookOptions where
  def :: ExecuteWebhookOptions
def = Maybe Bool
-> Maybe Text
-> [CreateMessageAttachment]
-> Maybe [Embed]
-> Maybe Text
-> Maybe Text
-> Maybe AllowedMentions
-> Maybe Bool
-> [Component]
-> ExecuteWebhookOptions
ExecuteWebhookOptions Maybe Bool
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing [] Maybe [Embed]
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe AllowedMentions
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing []

data CreateMessageAttachmentJson = CreateMessageAttachmentJson
  { CreateMessageAttachmentJson -> Int
id :: Int
  , CreateMessageAttachmentJson -> Text
filename :: Text
  , CreateMessageAttachmentJson -> Maybe Text
description :: Maybe Text
  }
  deriving (Int -> CreateMessageAttachmentJson -> ShowS
[CreateMessageAttachmentJson] -> ShowS
CreateMessageAttachmentJson -> String
(Int -> CreateMessageAttachmentJson -> ShowS)
-> (CreateMessageAttachmentJson -> String)
-> ([CreateMessageAttachmentJson] -> ShowS)
-> Show CreateMessageAttachmentJson
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateMessageAttachmentJson -> ShowS
showsPrec :: Int -> CreateMessageAttachmentJson -> ShowS
$cshow :: CreateMessageAttachmentJson -> String
show :: CreateMessageAttachmentJson -> String
$cshowList :: [CreateMessageAttachmentJson] -> ShowS
showList :: [CreateMessageAttachmentJson] -> ShowS
Show)
  deriving ([CreateMessageAttachmentJson] -> Value
[CreateMessageAttachmentJson] -> Encoding
CreateMessageAttachmentJson -> Value
CreateMessageAttachmentJson -> Encoding
(CreateMessageAttachmentJson -> Value)
-> (CreateMessageAttachmentJson -> Encoding)
-> ([CreateMessageAttachmentJson] -> Value)
-> ([CreateMessageAttachmentJson] -> Encoding)
-> ToJSON CreateMessageAttachmentJson
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: CreateMessageAttachmentJson -> Value
toJSON :: CreateMessageAttachmentJson -> Value
$ctoEncoding :: CreateMessageAttachmentJson -> Encoding
toEncoding :: CreateMessageAttachmentJson -> Encoding
$ctoJSONList :: [CreateMessageAttachmentJson] -> Value
toJSONList :: [CreateMessageAttachmentJson] -> Value
$ctoEncodingList :: [CreateMessageAttachmentJson] -> Encoding
toEncodingList :: [CreateMessageAttachmentJson] -> Encoding
Aeson.ToJSON) via CalamityToJSON CreateMessageAttachmentJson

instance CalamityToJSON' CreateMessageAttachmentJson where
  toPairs :: forall kv. KeyValue kv => CreateMessageAttachmentJson -> [Maybe kv]
toPairs CreateMessageAttachmentJson {Int
Maybe Text
Text
$sel:id:CreateMessageAttachmentJson :: CreateMessageAttachmentJson -> Int
$sel:filename:CreateMessageAttachmentJson :: CreateMessageAttachmentJson -> Text
$sel:description:CreateMessageAttachmentJson :: CreateMessageAttachmentJson -> Maybe Text
id :: Int
filename :: Text
description :: Maybe Text
..} =
    [ Key
"id" Key -> Int -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Int
id
    , Key
"filename" Key -> Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Text
filename
    , Key
"description" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
description
    ]

data ExecuteWebhookJson = ExecuteWebhookJson
  { ExecuteWebhookJson -> Maybe Text
content :: Maybe Text
  , ExecuteWebhookJson -> Maybe [Embed]
embeds :: Maybe [Embed]
  , ExecuteWebhookJson -> Maybe Text
username :: Maybe Text
  , ExecuteWebhookJson -> Maybe Text
avatarUrl :: Maybe Text
  , ExecuteWebhookJson -> Maybe Bool
tts :: Maybe Bool
  , ExecuteWebhookJson -> [CreateMessageAttachmentJson]
attachments :: [CreateMessageAttachmentJson]
  , ExecuteWebhookJson -> Maybe AllowedMentions
allowedMentions :: Maybe AllowedMentions
  , ExecuteWebhookJson -> [Component]
components :: [Component]
  }
  deriving (Int -> ExecuteWebhookJson -> ShowS
[ExecuteWebhookJson] -> ShowS
ExecuteWebhookJson -> String
(Int -> ExecuteWebhookJson -> ShowS)
-> (ExecuteWebhookJson -> String)
-> ([ExecuteWebhookJson] -> ShowS)
-> Show ExecuteWebhookJson
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExecuteWebhookJson -> ShowS
showsPrec :: Int -> ExecuteWebhookJson -> ShowS
$cshow :: ExecuteWebhookJson -> String
show :: ExecuteWebhookJson -> String
$cshowList :: [ExecuteWebhookJson] -> ShowS
showList :: [ExecuteWebhookJson] -> ShowS
Show)
  deriving ([ExecuteWebhookJson] -> Value
[ExecuteWebhookJson] -> Encoding
ExecuteWebhookJson -> Value
ExecuteWebhookJson -> Encoding
(ExecuteWebhookJson -> Value)
-> (ExecuteWebhookJson -> Encoding)
-> ([ExecuteWebhookJson] -> Value)
-> ([ExecuteWebhookJson] -> Encoding)
-> ToJSON ExecuteWebhookJson
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ExecuteWebhookJson -> Value
toJSON :: ExecuteWebhookJson -> Value
$ctoEncoding :: ExecuteWebhookJson -> Encoding
toEncoding :: ExecuteWebhookJson -> Encoding
$ctoJSONList :: [ExecuteWebhookJson] -> Value
toJSONList :: [ExecuteWebhookJson] -> Value
$ctoEncodingList :: [ExecuteWebhookJson] -> Encoding
toEncodingList :: [ExecuteWebhookJson] -> Encoding
Aeson.ToJSON) via CalamityToJSON ExecuteWebhookJson

instance CalamityToJSON' ExecuteWebhookJson where
  toPairs :: forall kv. KeyValue kv => ExecuteWebhookJson -> [Maybe kv]
toPairs ExecuteWebhookJson {[Component]
[CreateMessageAttachmentJson]
Maybe Bool
Maybe [Embed]
Maybe Text
Maybe AllowedMentions
$sel:content:ExecuteWebhookJson :: ExecuteWebhookJson -> Maybe Text
$sel:embeds:ExecuteWebhookJson :: ExecuteWebhookJson -> Maybe [Embed]
$sel:username:ExecuteWebhookJson :: ExecuteWebhookJson -> Maybe Text
$sel:avatarUrl:ExecuteWebhookJson :: ExecuteWebhookJson -> Maybe Text
$sel:tts:ExecuteWebhookJson :: ExecuteWebhookJson -> Maybe Bool
$sel:attachments:ExecuteWebhookJson :: ExecuteWebhookJson -> [CreateMessageAttachmentJson]
$sel:allowedMentions:ExecuteWebhookJson :: ExecuteWebhookJson -> Maybe AllowedMentions
$sel:components:ExecuteWebhookJson :: ExecuteWebhookJson -> [Component]
content :: Maybe Text
embeds :: Maybe [Embed]
username :: Maybe Text
avatarUrl :: Maybe Text
tts :: Maybe Bool
attachments :: [CreateMessageAttachmentJson]
allowedMentions :: Maybe AllowedMentions
components :: [Component]
..} =
    [ Key
"content" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
content
    , Key
"embeds" Key -> Maybe [Embed] -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe [Embed]
embeds
    , Key
"avatar_url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
avatarUrl
    , Key
"tts" Key -> Maybe Bool -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Bool
tts
    , Key
"attachments" Key -> [CreateMessageAttachmentJson] -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= [CreateMessageAttachmentJson]
attachments
    , Key
"allowed_mentions" Key -> Maybe AllowedMentions -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe AllowedMentions
allowedMentions
    , Key
"components" Key -> [Component] -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= [Component]
components
    ]

$(makeFieldLabelsNoPrefix ''CreateWebhookData)
$(makeFieldLabelsNoPrefix ''ModifyWebhookData)
$(makeFieldLabelsNoPrefix ''ExecuteWebhookOptions)

data WebhookRequest a where
  CreateWebhook :: HasID Channel c => c -> CreateWebhookData -> WebhookRequest Webhook
  GetChannelWebhooks :: HasID Channel c => c -> WebhookRequest [Webhook]
  GetGuildWebhooks :: HasID Guild c => c -> WebhookRequest [Webhook]
  GetWebhook :: HasID Webhook w => w -> WebhookRequest Webhook
  GetWebhookToken :: HasID Webhook w => w -> Text -> WebhookRequest Webhook
  ModifyWebhook :: HasID Webhook w => w -> ModifyWebhookData -> WebhookRequest Webhook
  ModifyWebhookToken :: HasID Webhook w => w -> Text -> ModifyWebhookData -> WebhookRequest Webhook
  DeleteWebhook :: HasID Webhook w => w -> WebhookRequest ()
  DeleteWebhookToken :: HasID Webhook w => w -> Text -> WebhookRequest ()
  ExecuteWebhook :: HasID Webhook w => w -> Text -> ExecuteWebhookOptions -> WebhookRequest ()

baseRoute :: Snowflake Webhook -> RouteBuilder _
baseRoute :: Snowflake Webhook
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook,
           AddRequiredInner (Lookup ('IDRequirement Webhook) '[]))]
baseRoute Snowflake Webhook
id = RouteBuilder '[]
mkRouteBuilder RouteBuilder '[] -> S -> ConsRes S '[]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
"webhooks" RouteBuilder '[] -> ID Webhook -> ConsRes (ID Webhook) '[]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// forall a. ID a
forall {k} (a :: k). ID a
ID @Webhook RouteBuilder
  '[ '( 'IDRequirement Webhook,
        AddRequiredInner (Lookup ('IDRequirement Webhook) '[]))]
-> (RouteBuilder
      '[ '( 'IDRequirement Webhook,
            AddRequiredInner (Lookup ('IDRequirement Webhook) '[]))]
    -> RouteBuilder
         '[ '( 'IDRequirement Webhook, 'Satisfied),
            '( 'IDRequirement Webhook,
               AddRequiredInner (Lookup ('IDRequirement Webhook) '[]))])
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook,
           AddRequiredInner (Lookup ('IDRequirement Webhook) '[]))]
forall a b. a -> (a -> b) -> b
& Snowflake Webhook
-> RouteBuilder
     '[ '( 'IDRequirement Webhook,
           AddRequiredInner (Lookup ('IDRequirement Webhook) '[]))]
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook,
           AddRequiredInner (Lookup ('IDRequirement Webhook) '[]))]
forall t (reqs :: [(RequirementType, RouteRequirement)]).
Typeable t =>
Snowflake t
-> RouteBuilder reqs
-> RouteBuilder ('( 'IDRequirement t, 'Satisfied) : reqs)
giveID Snowflake Webhook
id

instance Request (WebhookRequest a) where
  type Result (WebhookRequest a) = a

  route :: WebhookRequest a -> Route
route (CreateWebhook (forall b a. HasID b a => a -> Snowflake b
getID @Channel -> Snowflake Channel
cid) CreateWebhookData
_) =
    RouteBuilder '[]
mkRouteBuilder RouteBuilder '[] -> S -> ConsRes S '[]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
"channels" RouteBuilder '[] -> ID Channel -> ConsRes (ID Channel) '[]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// forall a. ID a
forall {k} (a :: k). ID a
ID @Channel RouteBuilder
  '[ '( 'IDRequirement Channel,
        AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> S
-> ConsRes
     S
     '[ '( 'IDRequirement Channel,
           AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
"webhooks"
      RouteBuilder
  '[ '( 'IDRequirement Channel,
        AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> (RouteBuilder
      '[ '( 'IDRequirement Channel,
            AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
    -> RouteBuilder
         '[ '( 'IDRequirement Channel, 'Satisfied),
            '( 'IDRequirement Channel,
               AddRequiredInner (Lookup ('IDRequirement Channel) '[]))])
-> RouteBuilder
     '[ '( 'IDRequirement Channel, 'Satisfied),
        '( 'IDRequirement Channel,
           AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
forall a b. a -> (a -> b) -> b
& Snowflake Channel
-> RouteBuilder
     '[ '( 'IDRequirement Channel,
           AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> RouteBuilder
     '[ '( 'IDRequirement Channel, 'Satisfied),
        '( 'IDRequirement Channel,
           AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
forall t (reqs :: [(RequirementType, RouteRequirement)]).
Typeable t =>
Snowflake t
-> RouteBuilder reqs
-> RouteBuilder ('( 'IDRequirement t, 'Satisfied) : reqs)
giveID Snowflake Channel
cid
      RouteBuilder
  '[ '( 'IDRequirement Channel, 'Satisfied),
     '( 'IDRequirement Channel,
        AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> (RouteBuilder
      '[ '( 'IDRequirement Channel, 'Satisfied),
         '( 'IDRequirement Channel,
            AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Channel, 'Satisfied),
     '( 'IDRequirement Channel,
        AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute
  route (GetChannelWebhooks (forall b a. HasID b a => a -> Snowflake b
getID @Channel -> Snowflake Channel
cid)) =
    RouteBuilder '[]
mkRouteBuilder RouteBuilder '[] -> S -> ConsRes S '[]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
"channels" RouteBuilder '[] -> ID Channel -> ConsRes (ID Channel) '[]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// forall a. ID a
forall {k} (a :: k). ID a
ID @Channel RouteBuilder
  '[ '( 'IDRequirement Channel,
        AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> S
-> ConsRes
     S
     '[ '( 'IDRequirement Channel,
           AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
"webhooks"
      RouteBuilder
  '[ '( 'IDRequirement Channel,
        AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> (RouteBuilder
      '[ '( 'IDRequirement Channel,
            AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
    -> RouteBuilder
         '[ '( 'IDRequirement Channel, 'Satisfied),
            '( 'IDRequirement Channel,
               AddRequiredInner (Lookup ('IDRequirement Channel) '[]))])
-> RouteBuilder
     '[ '( 'IDRequirement Channel, 'Satisfied),
        '( 'IDRequirement Channel,
           AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
forall a b. a -> (a -> b) -> b
& Snowflake Channel
-> RouteBuilder
     '[ '( 'IDRequirement Channel,
           AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> RouteBuilder
     '[ '( 'IDRequirement Channel, 'Satisfied),
        '( 'IDRequirement Channel,
           AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
forall t (reqs :: [(RequirementType, RouteRequirement)]).
Typeable t =>
Snowflake t
-> RouteBuilder reqs
-> RouteBuilder ('( 'IDRequirement t, 'Satisfied) : reqs)
giveID Snowflake Channel
cid
      RouteBuilder
  '[ '( 'IDRequirement Channel, 'Satisfied),
     '( 'IDRequirement Channel,
        AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> (RouteBuilder
      '[ '( 'IDRequirement Channel, 'Satisfied),
         '( 'IDRequirement Channel,
            AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Channel, 'Satisfied),
     '( 'IDRequirement Channel,
        AddRequiredInner (Lookup ('IDRequirement Channel) '[]))]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute
  route (GetGuildWebhooks (forall b a. HasID b a => a -> Snowflake b
getID @Guild -> Snowflake Guild
gid)) =
    RouteBuilder '[]
mkRouteBuilder RouteBuilder '[] -> S -> ConsRes S '[]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
"guilds" RouteBuilder '[] -> ID Guild -> ConsRes (ID Guild) '[]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// forall a. ID a
forall {k} (a :: k). ID a
ID @Guild RouteBuilder
  '[ '( 'IDRequirement Guild,
        AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
-> S
-> ConsRes
     S
     '[ '( 'IDRequirement Guild,
           AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
"webhooks"
      RouteBuilder
  '[ '( 'IDRequirement Guild,
        AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
-> (RouteBuilder
      '[ '( 'IDRequirement Guild,
            AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
    -> RouteBuilder
         '[ '( 'IDRequirement Guild, 'Satisfied),
            '( 'IDRequirement Guild,
               AddRequiredInner (Lookup ('IDRequirement Guild) '[]))])
-> RouteBuilder
     '[ '( 'IDRequirement Guild, 'Satisfied),
        '( 'IDRequirement Guild,
           AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
forall a b. a -> (a -> b) -> b
& Snowflake Guild
-> RouteBuilder
     '[ '( 'IDRequirement Guild,
           AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
-> RouteBuilder
     '[ '( 'IDRequirement Guild, 'Satisfied),
        '( 'IDRequirement Guild,
           AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
forall t (reqs :: [(RequirementType, RouteRequirement)]).
Typeable t =>
Snowflake t
-> RouteBuilder reqs
-> RouteBuilder ('( 'IDRequirement t, 'Satisfied) : reqs)
giveID Snowflake Guild
gid
      RouteBuilder
  '[ '( 'IDRequirement Guild, 'Satisfied),
     '( 'IDRequirement Guild,
        AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
-> (RouteBuilder
      '[ '( 'IDRequirement Guild, 'Satisfied),
         '( 'IDRequirement Guild,
            AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Guild, 'Satisfied),
     '( 'IDRequirement Guild,
        AddRequiredInner (Lookup ('IDRequirement Guild) '[]))]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute
  route (GetWebhook (forall b a. HasID b a => a -> Snowflake b
getID @Webhook -> Snowflake Webhook
wid)) =
    Snowflake Webhook
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
baseRoute Snowflake Webhook
wid
      RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> (RouteBuilder
      '[ '( 'IDRequirement Webhook, 'Satisfied),
         '( 'IDRequirement Webhook, 'Required)]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute
  route (GetWebhookToken (forall b a. HasID b a => a -> Snowflake b
getID @Webhook -> Snowflake Webhook
wid) Text
t) =
    Snowflake Webhook
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
baseRoute Snowflake Webhook
wid RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> S
-> ConsRes
     S
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
t
      RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> (RouteBuilder
      '[ '( 'IDRequirement Webhook, 'Satisfied),
         '( 'IDRequirement Webhook, 'Required)]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute
  route (ModifyWebhook (forall b a. HasID b a => a -> Snowflake b
getID @Webhook -> Snowflake Webhook
wid) ModifyWebhookData
_) =
    Snowflake Webhook
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
baseRoute Snowflake Webhook
wid
      RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> (RouteBuilder
      '[ '( 'IDRequirement Webhook, 'Satisfied),
         '( 'IDRequirement Webhook, 'Required)]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute
  route (ModifyWebhookToken (forall b a. HasID b a => a -> Snowflake b
getID @Webhook -> Snowflake Webhook
wid) Text
t ModifyWebhookData
_) =
    Snowflake Webhook
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
baseRoute Snowflake Webhook
wid RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> S
-> ConsRes
     S
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
t
      RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> (RouteBuilder
      '[ '( 'IDRequirement Webhook, 'Satisfied),
         '( 'IDRequirement Webhook, 'Required)]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute
  route (DeleteWebhook (forall b a. HasID b a => a -> Snowflake b
getID @Webhook -> Snowflake Webhook
wid)) =
    Snowflake Webhook
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
baseRoute Snowflake Webhook
wid
      RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> (RouteBuilder
      '[ '( 'IDRequirement Webhook, 'Satisfied),
         '( 'IDRequirement Webhook, 'Required)]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute
  route (DeleteWebhookToken (forall b a. HasID b a => a -> Snowflake b
getID @Webhook -> Snowflake Webhook
wid) Text
t) =
    Snowflake Webhook
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
baseRoute Snowflake Webhook
wid RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> S
-> ConsRes
     S
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
t
      RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> (RouteBuilder
      '[ '( 'IDRequirement Webhook, 'Satisfied),
         '( 'IDRequirement Webhook, 'Required)]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute
  route (ExecuteWebhook (forall b a. HasID b a => a -> Snowflake b
getID @Webhook -> Snowflake Webhook
wid) Text
t ExecuteWebhookOptions
_) =
    Snowflake Webhook
-> RouteBuilder
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
baseRoute Snowflake Webhook
wid RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> S
-> ConsRes
     S
     '[ '( 'IDRequirement Webhook, 'Satisfied),
        '( 'IDRequirement Webhook, 'Required)]
forall a (reqs :: [(RequirementType, RouteRequirement)]).
RouteFragmentable a reqs =>
RouteBuilder reqs -> a -> ConsRes a reqs
// Text -> S
S Text
t
      RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> (RouteBuilder
      '[ '( 'IDRequirement Webhook, 'Satisfied),
         '( 'IDRequirement Webhook, 'Required)]
    -> Route)
-> Route
forall a b. a -> (a -> b) -> b
& RouteBuilder
  '[ '( 'IDRequirement Webhook, 'Satisfied),
     '( 'IDRequirement Webhook, 'Required)]
-> Route
forall (reqs :: [(RequirementType, RouteRequirement)]).
EnsureFulfilled reqs =>
RouteBuilder reqs -> Route
buildRoute

  action :: WebhookRequest a -> Url 'Https -> Option 'Https -> Req LbsResponse
action (CreateWebhook c
_ CreateWebhookData
o) = ReqBodyJson CreateWebhookData
-> Url 'Https -> Option 'Https -> Req LbsResponse
forall a.
HttpBody a =>
a -> Url 'Https -> Option 'Https -> Req LbsResponse
postWith' (ReqBodyJson CreateWebhookData
 -> Url 'Https -> Option 'Https -> Req LbsResponse)
-> ReqBodyJson CreateWebhookData
-> Url 'Https
-> Option 'Https
-> Req LbsResponse
forall a b. (a -> b) -> a -> b
$ CreateWebhookData -> ReqBodyJson CreateWebhookData
forall a. a -> ReqBodyJson a
ReqBodyJson CreateWebhookData
o
  action (GetChannelWebhooks c
_) = Url 'Https -> Option 'Https -> Req LbsResponse
getWith
  action (GetGuildWebhooks c
_) = Url 'Https -> Option 'Https -> Req LbsResponse
getWith
  action (GetWebhook w
_) = Url 'Https -> Option 'Https -> Req LbsResponse
getWith
  action (GetWebhookToken w
_ Text
_) = Url 'Https -> Option 'Https -> Req LbsResponse
getWith
  action (ModifyWebhook w
_ ModifyWebhookData
o) = ReqBodyJson ModifyWebhookData
-> Url 'Https -> Option 'Https -> Req LbsResponse
forall a.
HttpBody a =>
a -> Url 'Https -> Option 'Https -> Req LbsResponse
patchWith' (ReqBodyJson ModifyWebhookData
 -> Url 'Https -> Option 'Https -> Req LbsResponse)
-> ReqBodyJson ModifyWebhookData
-> Url 'Https
-> Option 'Https
-> Req LbsResponse
forall a b. (a -> b) -> a -> b
$ ModifyWebhookData -> ReqBodyJson ModifyWebhookData
forall a. a -> ReqBodyJson a
ReqBodyJson ModifyWebhookData
o
  action (ModifyWebhookToken w
_ Text
_ ModifyWebhookData
o) = ReqBodyJson ModifyWebhookData
-> Url 'Https -> Option 'Https -> Req LbsResponse
forall a.
HttpBody a =>
a -> Url 'Https -> Option 'Https -> Req LbsResponse
patchWith' (ReqBodyJson ModifyWebhookData
 -> Url 'Https -> Option 'Https -> Req LbsResponse)
-> ReqBodyJson ModifyWebhookData
-> Url 'Https
-> Option 'Https
-> Req LbsResponse
forall a b. (a -> b) -> a -> b
$ ModifyWebhookData -> ReqBodyJson ModifyWebhookData
forall a. a -> ReqBodyJson a
ReqBodyJson ModifyWebhookData
o
  action (DeleteWebhook w
_) = Url 'Https -> Option 'Https -> Req LbsResponse
deleteWith
  action (DeleteWebhookToken w
_ Text
_) = Url 'Https -> Option 'Https -> Req LbsResponse
deleteWith
  action (ExecuteWebhook w
_ Text
_ ExecuteWebhookOptions
wh) = \Url 'Https
u Option 'Https
o -> do
    let filePart :: CreateMessageAttachment -> a -> PartM IO
filePart CreateMessageAttachment {Text
filename :: Text
$sel:filename:CreateMessageAttachment :: CreateMessageAttachment -> Text
filename, ByteString
content :: ByteString
$sel:content:CreateMessageAttachment :: CreateMessageAttachment -> ByteString
content} a
n =
          (forall (m :: * -> *).
Applicative m =>
Text -> ByteString -> PartM m
partLBS @IO (String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ String
"files[" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> a -> String
forall a. Show a => a -> String
show a
n String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"]") ByteString
content)
            { partFilename :: Maybe String
partFilename = String -> Maybe String
forall a. a -> Maybe a
Just (Text -> String
T.unpack Text
filename)
            , partContentType :: Maybe MimeType
partContentType = MimeType -> Maybe MimeType
forall a. a -> Maybe a
Just (Text -> MimeType
defaultMimeLookup Text
filename)
            }
        attachmentPart :: CreateMessageAttachment -> Int -> CreateMessageAttachmentJson
attachmentPart CreateMessageAttachment {Text
$sel:filename:CreateMessageAttachment :: CreateMessageAttachment -> Text
filename :: Text
filename, Maybe Text
description :: Maybe Text
$sel:description:CreateMessageAttachment :: CreateMessageAttachment -> Maybe Text
description} Int
n =
          Int -> Text -> Maybe Text -> CreateMessageAttachmentJson
CreateMessageAttachmentJson Int
n Text
filename Maybe Text
description
        files :: [PartM IO]
files = (CreateMessageAttachment -> Int -> PartM IO)
-> [CreateMessageAttachment] -> [Int] -> [PartM IO]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith CreateMessageAttachment -> Int -> PartM IO
forall {a}. Show a => CreateMessageAttachment -> a -> PartM IO
filePart (ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic'
     A_Lens NoIx ExecuteWebhookOptions [CreateMessageAttachment]
-> [CreateMessageAttachment]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions [CreateMessageAttachment]
#attachments) [(Int
0 :: Int) ..]
        attachments :: [CreateMessageAttachmentJson]
attachments = (CreateMessageAttachment -> Int -> CreateMessageAttachmentJson)
-> [CreateMessageAttachment]
-> [Int]
-> [CreateMessageAttachmentJson]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith CreateMessageAttachment -> Int -> CreateMessageAttachmentJson
attachmentPart (ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic'
     A_Lens NoIx ExecuteWebhookOptions [CreateMessageAttachment]
-> [CreateMessageAttachment]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions [CreateMessageAttachment]
#attachments) [Int
0 ..]
        jsonBody :: ExecuteWebhookJson
jsonBody =
          ExecuteWebhookJson
            { $sel:content:ExecuteWebhookJson :: Maybe Text
content = ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Text)
#content
            , $sel:username:ExecuteWebhookJson :: Maybe Text
username = ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Text)
#username
            , $sel:avatarUrl:ExecuteWebhookJson :: Maybe Text
avatarUrl = ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Text)
#avatarUrl
            , $sel:tts:ExecuteWebhookJson :: Maybe Bool
tts = ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Bool)
-> Maybe Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Bool)
#tts
            , $sel:embeds:ExecuteWebhookJson :: Maybe [Embed]
embeds = ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe [Embed])
-> Maybe [Embed]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe [Embed])
#embeds
            , $sel:allowedMentions:ExecuteWebhookJson :: Maybe AllowedMentions
allowedMentions = ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe AllowedMentions)
-> Maybe AllowedMentions
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe AllowedMentions)
#allowedMentions
            , $sel:components:ExecuteWebhookJson :: [Component]
components = ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic' A_Lens NoIx ExecuteWebhookOptions [Component]
-> [Component]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions [Component]
#components
            , $sel:attachments:ExecuteWebhookJson :: [CreateMessageAttachmentJson]
attachments = [CreateMessageAttachmentJson]
attachments
            }
    ReqBodyMultipart
body <- [PartM IO] -> Req ReqBodyMultipart
forall (m :: * -> *). MonadIO m => [PartM IO] -> m ReqBodyMultipart
reqBodyMultipart (Text -> ByteString -> PartM IO
forall (m :: * -> *).
Applicative m =>
Text -> ByteString -> PartM m
partLBS Text
"payload_json" (ExecuteWebhookJson -> ByteString
forall a. ToJSON a => a -> ByteString
Aeson.encode ExecuteWebhookJson
jsonBody) PartM IO -> [PartM IO] -> [PartM IO]
forall a. a -> [a] -> [a]
: [PartM IO]
files)
    ReqBodyMultipart
-> Option 'Https -> Url 'Https -> Option 'Https -> Req LbsResponse
forall a.
HttpBody a =>
a
-> Option 'Https -> Url 'Https -> Option 'Https -> Req LbsResponse
postWithP' ReqBodyMultipart
body (Text
"wait" Text -> Maybe Bool -> Option 'Https
forall a. ToHttpApiData a => Text -> Maybe a -> Option 'Https
=:? (ExecuteWebhookOptions
wh ExecuteWebhookOptions
-> Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Bool)
-> Maybe Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx ExecuteWebhookOptions (Maybe Bool)
#wait)) Url 'Https
u Option 'Https
o