{-# LANGUAGE DataKinds                  #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE TypeApplications           #-}
{-# LANGUAGE TypeOperators              #-}
{-# LANGUAGE RecordWildCards            #-}
{-# LANGUAGE MultiParamTypeClasses      #-}
{-# LANGUAGE LambdaCase #-}

module Telegram.Bot.API.Stickers where

import Control.Monad.IO.Class
import Data.Aeson
import Data.Aeson.Text
import Data.Bool
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
import Data.Proxy
import GHC.Generics (Generic)
import Servant.API
import Servant.Client hiding (Response)
import Servant.Multipart.API
import Servant.Multipart.Client

import Telegram.Bot.API.Internal.Utils
import Telegram.Bot.API.MakingRequests (Response)
import Telegram.Bot.API.Types
import Data.Maybe (catMaybes)
import Data.Functor
import Telegram.Bot.API.Internal.TH (makeDefault)


-- | Type of uploaded sticker file. Static or animated.
data StickerType
  = PngSticker -- ^ PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.
  | TgsSticker -- ^ TGS animation with the sticker, uploaded using multipart/form-data. See <https:\/\/core.telegram.org\/animated_stickers#technical-requirements> for technical requirements.
  | WebmSticker -- ^ WEBM video with the sticker, uploaded using multipart/form-data. See <https:\/\/core.telegram.org\/stickers#video-sticker-requirements> for technical requirements.


-- | Sticker file with static/animated label.
data StickerFile = StickerFile {StickerFile -> InputFile
stickerFileSticker :: InputFile, StickerFile -> StickerType
stickerFileLabel :: StickerType}

-- ** 'sendSticker'

-- | Request parameters for 'sendSticker'.
data SendStickerRequest = SendStickerRequest
  { SendStickerRequest -> SomeChatId
sendStickerChatId                   :: SomeChatId -- ^ Unique identifier for the target chat or username of the target channel (in the format @channelusername).
  , SendStickerRequest -> Maybe MessageThreadId
sendStickerMessageThreadId          :: Maybe MessageThreadId -- ^ Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.
  , SendStickerRequest -> Maybe Text
sendStickerEmoji                    :: Maybe Text -- ^ Emoji associated with the sticker; only for just uploaded stickers.
  , SendStickerRequest -> InputFile
sendStickerSticker                  :: InputFile -- ^ Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data.
  , SendStickerRequest -> Maybe Bool
sendStickerDisableNotification      :: Maybe Bool -- ^ Sends the message silently. Users will receive a notification with no sound.
  , SendStickerRequest -> Maybe Bool
sendStickerProtectContent           :: Maybe Bool -- ^ Protects the contents of the sent message from forwarding and saving.
  , SendStickerRequest -> Maybe MessageId
sendStickerReplyToMessageId         :: Maybe MessageId -- ^	If the message is a reply, ID of the original message
  , SendStickerRequest -> Maybe Bool
sendStickerAllowSendingWithoutReply :: Maybe Bool -- ^ Pass True, if the message should be sent even if the specified replied-to message is not found
  , SendStickerRequest -> Maybe InlineKeyboardMarkup
sendStickerReplyMarkup              :: Maybe InlineKeyboardMarkup -- ^ Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
  }
  deriving forall x. Rep SendStickerRequest x -> SendStickerRequest
forall x. SendStickerRequest -> Rep SendStickerRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendStickerRequest x -> SendStickerRequest
$cfrom :: forall x. SendStickerRequest -> Rep SendStickerRequest x
Generic

instance ToJSON SendStickerRequest where toJSON :: SendStickerRequest -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON

instance ToMultipart Tmp SendStickerRequest where
  toMultipart :: SendStickerRequest -> MultipartData Tmp
toMultipart SendStickerRequest{Maybe Bool
Maybe Text
Maybe MessageThreadId
Maybe MessageId
Maybe InlineKeyboardMarkup
SomeChatId
InputFile
sendStickerReplyMarkup :: Maybe InlineKeyboardMarkup
sendStickerAllowSendingWithoutReply :: Maybe Bool
sendStickerReplyToMessageId :: Maybe MessageId
sendStickerProtectContent :: Maybe Bool
sendStickerDisableNotification :: Maybe Bool
sendStickerSticker :: InputFile
sendStickerEmoji :: Maybe Text
sendStickerMessageThreadId :: Maybe MessageThreadId
sendStickerChatId :: SomeChatId
sendStickerReplyMarkup :: SendStickerRequest -> Maybe InlineKeyboardMarkup
sendStickerAllowSendingWithoutReply :: SendStickerRequest -> Maybe Bool
sendStickerReplyToMessageId :: SendStickerRequest -> Maybe MessageId
sendStickerProtectContent :: SendStickerRequest -> Maybe Bool
sendStickerDisableNotification :: SendStickerRequest -> Maybe Bool
sendStickerSticker :: SendStickerRequest -> InputFile
sendStickerEmoji :: SendStickerRequest -> Maybe Text
sendStickerMessageThreadId :: SendStickerRequest -> Maybe MessageThreadId
sendStickerChatId :: SendStickerRequest -> SomeChatId
..} =
    Text -> InputFile -> MultipartData Tmp -> MultipartData Tmp
makeFile Text
"sticker" InputFile
sendStickerSticker (forall tag. [Input] -> [FileData tag] -> MultipartData tag
MultipartData [Input]
fields []) where
    fields :: [Input]
fields =
      [ Text -> Text -> Input
Input Text
"chat_id" forall a b. (a -> b) -> a -> b
$ case SomeChatId
sendStickerChatId of
          SomeChatId (ChatId Integer
chat_id) -> String -> Text
T.pack forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Integer
chat_id
          SomeChatUsername Text
txt -> Text
txt
      ] forall a. Semigroup a => a -> a -> a
<> forall a. [Maybe a] -> [a]
catMaybes
      [ Maybe MessageThreadId
sendStickerMessageThreadId forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&>
        \MessageThreadId
t -> Text -> Text -> Input
Input Text
"message_thread_id" (String -> Text
T.pack forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show MessageThreadId
t)
      , Maybe Bool
sendStickerDisableNotification forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&>
        \Bool
t -> Text -> Text -> Input
Input Text
"disable_notification" (forall a. a -> a -> Bool -> a
bool Text
"false" Text
"true" Bool
t)
      , Maybe Bool
sendStickerProtectContent forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&>
        \Bool
t -> Text -> Text -> Input
Input Text
"protect_content" (forall a. a -> a -> Bool -> a
bool Text
"false" Text
"true" Bool
t)
      , Maybe MessageId
sendStickerReplyToMessageId forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&>
        \MessageId
t -> Text -> Text -> Input
Input Text
"reply_to_message_id" (Text -> Text
TL.toStrict forall a b. (a -> b) -> a -> b
$ forall a. ToJSON a => a -> Text
encodeToLazyText MessageId
t)
      , Maybe Bool
sendStickerAllowSendingWithoutReply forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&>
        \Bool
t -> Text -> Text -> Input
Input Text
"allow_sending_without_reply" (forall a. a -> a -> Bool -> a
bool Text
"false" Text
"true" Bool
t)
      , Maybe InlineKeyboardMarkup
sendStickerReplyMarkup forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&>
        \InlineKeyboardMarkup
t -> Text -> Text -> Input
Input Text
"reply_markup" (Text -> Text
TL.toStrict forall a b. (a -> b) -> a -> b
$ forall a. ToJSON a => a -> Text
encodeToLazyText InlineKeyboardMarkup
t)
      ]

type SendStickerContent
  = "sendSticker"
  :> MultipartForm Tmp SendStickerRequest
  :> Post '[JSON] (Response Message)

type SendStickerLink
  = "sendSticker"
  :> ReqBody '[JSON] SendStickerRequest
  :> Post '[JSON] (Response Message)

-- | Use this method to send static .WEBP or animated .TGS stickers.
--   On success, the sent Message is returned.
sendSticker :: SendStickerRequest -> ClientM (Response Message)
sendSticker :: SendStickerRequest -> ClientM (Response Message)
sendSticker SendStickerRequest
r =
  case SendStickerRequest -> InputFile
sendStickerSticker SendStickerRequest
r of
    InputFile{} -> do
      ByteString
boundary <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ByteString
genBoundary
      forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @SendStickerContent) (ByteString
boundary, SendStickerRequest
r)
    InputFile
_ -> forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @SendStickerLink) SendStickerRequest
r

-- ** 'getCustomEmojiStickers'

-- | Request parameters for 'getCustomEmojiStickers'.
data GetCustomEmojiStickersRequest = GetCustomEmojiStickersRequest
  { GetCustomEmojiStickersRequest -> [Text]
getCustomEmojiStickersRequestCustomEmojiIds :: [Text] -- ^ List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
  }
  deriving forall x.
Rep GetCustomEmojiStickersRequest x
-> GetCustomEmojiStickersRequest
forall x.
GetCustomEmojiStickersRequest
-> Rep GetCustomEmojiStickersRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetCustomEmojiStickersRequest x
-> GetCustomEmojiStickersRequest
$cfrom :: forall x.
GetCustomEmojiStickersRequest
-> Rep GetCustomEmojiStickersRequest x
Generic

instance ToJSON GetCustomEmojiStickersRequest where toJSON :: GetCustomEmojiStickersRequest -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON

type GetCustomEmojiStickers
  = "getCustomEmojiStickers"
  :> ReqBody '[JSON] GetCustomEmojiStickersRequest
  :> Post '[JSON] (Response [Sticker])

getCustomEmojiStickers :: GetCustomEmojiStickersRequest -> ClientM (Response [Sticker])
getCustomEmojiStickers :: GetCustomEmojiStickersRequest -> ClientM (Response [Sticker])
getCustomEmojiStickers = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @GetCustomEmojiStickers)

-- ** 'uploadStickerFile'

-- | Request parameters for 'uploadStickerFile'.
data UploadStickerFileRequest = UploadStickerFileRequest
  { UploadStickerFileRequest -> UserId
uploadStickerFileUserId        :: UserId -- ^ User identifier of sticker file owner
  , UploadStickerFileRequest -> InputFile
uploadStickerFileSticker       :: InputFile -- ^ A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements.
  , UploadStickerFileRequest -> Text
uploadStickerFileStickerFormat :: Text -- ^ Format of the sticker, must be one of “static”, “animated”, “video”
  } deriving forall x.
Rep UploadStickerFileRequest x -> UploadStickerFileRequest
forall x.
UploadStickerFileRequest -> Rep UploadStickerFileRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UploadStickerFileRequest x -> UploadStickerFileRequest
$cfrom :: forall x.
UploadStickerFileRequest -> Rep UploadStickerFileRequest x
Generic

instance ToJSON UploadStickerFileRequest where toJSON :: UploadStickerFileRequest -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON

instance ToMultipart Tmp UploadStickerFileRequest where
  toMultipart :: UploadStickerFileRequest -> MultipartData Tmp
toMultipart UploadStickerFileRequest{Text
UserId
InputFile
uploadStickerFileStickerFormat :: Text
uploadStickerFileSticker :: InputFile
uploadStickerFileUserId :: UserId
uploadStickerFileStickerFormat :: UploadStickerFileRequest -> Text
uploadStickerFileSticker :: UploadStickerFileRequest -> InputFile
uploadStickerFileUserId :: UploadStickerFileRequest -> UserId
..} =
    Text -> InputFile -> MultipartData Tmp -> MultipartData Tmp
makeFile Text
"sticker" InputFile
uploadStickerFileSticker (forall tag. [Input] -> [FileData tag] -> MultipartData tag
MultipartData [Input]
fields []) where
    fields :: [Input]
fields = [ Text -> Text -> Input
Input Text
"user_id" forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ UserId
uploadStickerFileUserId
             , Text -> Text -> Input
Input Text
"sticker_format" forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ Text
uploadStickerFileStickerFormat
             ]

type UploadStickerFileContent
  = "uploadStickerFile"
  :> MultipartForm Tmp UploadStickerFileRequest
  :> Post '[JSON] (Response File)

type UploadStickerFileLink
  = "uploadStickerFile"
  :> ReqBody '[JSON] UploadStickerFileRequest
  :> Post '[JSON] (Response File)

-- | Use this method to upload f file in .WEBP, .PNG, .TGS, or .WEBM format
--   with a sticker for later use in createNewStickerSet
--   and addStickerToSet methods (can be used multiple times).
--   Returns the uploaded File on success.
uploadStickerFile :: UploadStickerFileRequest -> ClientM (Response File)
uploadStickerFile :: UploadStickerFileRequest -> ClientM (Response File)
uploadStickerFile UploadStickerFileRequest
r =
  case UploadStickerFileRequest -> InputFile
uploadStickerFileSticker UploadStickerFileRequest
r of
    InputFile{} -> do
      ByteString
boundary <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ByteString
genBoundary
      forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @UploadStickerFileContent) (ByteString
boundary, UploadStickerFileRequest
r)
    InputFile
_ -> forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @UploadStickerFileLink) UploadStickerFileRequest
r


-- ** 'createNewStickerSet'

-- | Request parameters for 'createNewStickerSet'.
data CreateNewStickerSetRequest = CreateNewStickerSetRequest
  { CreateNewStickerSetRequest -> UserId
createNewStickerSetUserId        :: UserId -- ^ User identifier of created sticker set owner
  , CreateNewStickerSetRequest -> Text
createNewStickerSetName          :: T.Text -- ^ Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
  , CreateNewStickerSetRequest -> Text
createNewStickerSetTitle         :: T.Text -- ^ Sticker set title, 1-64 characters
  , CreateNewStickerSetRequest -> [InputSticker]
createNewStickerSetStickers      :: [InputSticker] -- ^ A JSON-serialized list of 1-50 initial stickers to be added to the sticker set.
  , CreateNewStickerSetRequest -> Text
createNewStickerFormat           :: Text -- ^ Format of stickers in the set, must be one of “static”, “animated”, “video”.
  , CreateNewStickerSetRequest -> Maybe StickerSetType
createNewStickerSetType             :: Maybe StickerSetType -- ^ Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created.
  , CreateNewStickerSetRequest -> Maybe Bool
createNewStickerSetNeedsRepainting :: Maybe Bool -- ^ 'True' if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only.
  } deriving forall x.
Rep CreateNewStickerSetRequest x -> CreateNewStickerSetRequest
forall x.
CreateNewStickerSetRequest -> Rep CreateNewStickerSetRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateNewStickerSetRequest x -> CreateNewStickerSetRequest
$cfrom :: forall x.
CreateNewStickerSetRequest -> Rep CreateNewStickerSetRequest x
Generic

instance ToJSON CreateNewStickerSetRequest where toJSON :: CreateNewStickerSetRequest -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON

type CreateNewStickerSet
  = "createNewStickerSet"
  :> ReqBody '[JSON] CreateNewStickerSetRequest
  :> Post '[JSON] (Response Bool)

-- | Use this method to create a new sticker
--   set owned by a user. The bot will be able
--   to edit the sticker set thus created. You
--   must use exactly one of the fields png_sticker or tgs_sticker.
--   Returns True on success.
createNewStickerSet :: CreateNewStickerSetRequest -> ClientM (Response Bool)
createNewStickerSet :: CreateNewStickerSetRequest -> ClientM (Response Bool)
createNewStickerSet = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @CreateNewStickerSet)

-- ** 'addStickerToSet'

-- | Request parameters for 'addStickerToSet'.
data AddStickerToSetRequest = AddStickerToSetRequest
  { AddStickerToSetRequest -> UserId
addStickerToSetUserId       :: UserId -- ^ User identifier of sticker set owner
  , AddStickerToSetRequest -> Text
addStickerToSetName         :: T.Text -- ^ Sticker set name
  , AddStickerToSetRequest -> InputSticker
addStickerToSetStickers     :: InputSticker -- ^ A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed.
  } deriving forall x. Rep AddStickerToSetRequest x -> AddStickerToSetRequest
forall x. AddStickerToSetRequest -> Rep AddStickerToSetRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddStickerToSetRequest x -> AddStickerToSetRequest
$cfrom :: forall x. AddStickerToSetRequest -> Rep AddStickerToSetRequest x
Generic

instance ToJSON AddStickerToSetRequest where toJSON :: AddStickerToSetRequest -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON

type AddStickerToSet
  = "addStickerToSet"
  :> ReqBody '[JSON] AddStickerToSetRequest
  :> Post '[JSON] (Response Bool)

-- | Use this method to add a new sticker to a set
--   created by the bot. You must use exactly one of
--   the fields png_sticker or tgs_sticker. Animated
--   stickers can be added to animated sticker sets and
--   only to them. Animated sticker sets can have up to 50
--   stickers. Static sticker sets can have up to 120 stickers.
--   Returns True on success.
addStickerToSet :: AddStickerToSetRequest -> ClientM (Response Bool)
addStickerToSet :: AddStickerToSetRequest -> ClientM (Response Bool)
addStickerToSet = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @AddStickerToSet)


-- ** 'getStickerSet'

type GetStickerSet
  = "getStickerSet"
  :> RequiredQueryParam "name" T.Text
  :> Get '[JSON] (Response StickerSet)

-- | Use this method to get a sticker set. On success, a StickerSet object is returned.
getStickerSet :: T.Text -- ^ Name of the sticker set
  -> ClientM (Response StickerSet)
getStickerSet :: Text -> ClientM (Response StickerSet)
getStickerSet = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @GetStickerSet)

-- ** 'setStickerPositionInSet'

type SetStickerPositionInSet
  = "setStickerPositionInSet"
  :> RequiredQueryParam "sticker" T.Text
  :> RequiredQueryParam "position" Integer
  :> Post '[JSON] (Response Bool)

-- | Use this method to move a sticker in a set created by the bot to a specific position.
--   Returns True on success.
setStickerPositionInSet :: T.Text -- ^ File identifier of the sticker
  -> Integer -- ^ New sticker position in the set, zero-based
  -> ClientM (Response Bool)
setStickerPositionInSet :: Text -> Integer -> ClientM (Response Bool)
setStickerPositionInSet = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @SetStickerPositionInSet)


-- ** 'deleteStickerFromSet'

type DeleteStickerFromSet
  = "deleteStickerFromSet"
  :> RequiredQueryParam "sticker" T.Text
  :> Post '[JSON] (Response Bool)

-- | Use this method to delete a sticker from a set created by the bot.
--   Returns True on success.
deleteStickerFromSet :: T.Text -- ^ File identifier of the sticker
  -> ClientM (Response Bool)
deleteStickerFromSet :: Text -> ClientM (Response Bool)
deleteStickerFromSet = forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @DeleteStickerFromSet)

-- ** 'setStickerSetThumbnail'

-- | Request parameters for 'setStickerSetThumbnail'.
data SetStickerSetThumbnailRequest = SetStickerSetThumbnailRequest
  { SetStickerSetThumbnailRequest -> Text
setStickerSetThumbnailName   :: T.Text -- ^ Sticker set name
  , SetStickerSetThumbnailRequest -> UserId
setStickerSetThumbnailUserId :: UserId -- ^ User identifier of the sticker set owner
  , SetStickerSetThumbnailRequest -> InputFile
setStickerSetThumbnailThumbnail  :: InputFile -- ^ A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see <https:\/\/core.telegram.org\/animated_stickers#technical-requirements> for animated sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated sticker set thumbnail can't be uploaded via HTTP URL.
  } deriving forall x.
Rep SetStickerSetThumbnailRequest x
-> SetStickerSetThumbnailRequest
forall x.
SetStickerSetThumbnailRequest
-> Rep SetStickerSetThumbnailRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SetStickerSetThumbnailRequest x
-> SetStickerSetThumbnailRequest
$cfrom :: forall x.
SetStickerSetThumbnailRequest
-> Rep SetStickerSetThumbnailRequest x
Generic

instance ToJSON SetStickerSetThumbnailRequest where toJSON :: SetStickerSetThumbnailRequest -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON

instance ToMultipart Tmp SetStickerSetThumbnailRequest where
  toMultipart :: SetStickerSetThumbnailRequest -> MultipartData Tmp
toMultipart SetStickerSetThumbnailRequest{Text
UserId
InputFile
setStickerSetThumbnailThumbnail :: InputFile
setStickerSetThumbnailUserId :: UserId
setStickerSetThumbnailName :: Text
setStickerSetThumbnailThumbnail :: SetStickerSetThumbnailRequest -> InputFile
setStickerSetThumbnailUserId :: SetStickerSetThumbnailRequest -> UserId
setStickerSetThumbnailName :: SetStickerSetThumbnailRequest -> Text
..} =
    Text -> InputFile -> MultipartData Tmp -> MultipartData Tmp
makeFile Text
"png_sticker" InputFile
setStickerSetThumbnailThumbnail (forall tag. [Input] -> [FileData tag] -> MultipartData tag
MultipartData [Input]
fields []) where
    fields :: [Input]
fields =
      [ Text -> Text -> Input
Input Text
"user_id" forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show forall a b. (a -> b) -> a -> b
$ UserId
setStickerSetThumbnailUserId
      , Text -> Text -> Input
Input Text
"name" Text
setStickerSetThumbnailName
      ]

type SetStickerSetThumbnailContent
  = "setStickerSetThumbnail"
  :> MultipartForm Tmp SetStickerSetThumbnailRequest
  :> Post '[JSON] (Response Bool)

type SetStickerSetThumbnailLink
  = "setStickerSetThumbnail"
  :> ReqBody '[JSON] SetStickerSetThumbnailRequest
  :> Post '[JSON] (Response Bool)

-- | Use this method to set the thumbnail of a sticker set.
--   Animated thumbnails can be set for animated sticker sets only.
--   Returns True on success.
setStickerSetThumbnail :: SetStickerSetThumbnailRequest -> ClientM (Response Bool)
setStickerSetThumbnail :: SetStickerSetThumbnailRequest -> ClientM (Response Bool)
setStickerSetThumbnail SetStickerSetThumbnailRequest
r =
  case SetStickerSetThumbnailRequest -> InputFile
setStickerSetThumbnailThumbnail SetStickerSetThumbnailRequest
r of
    InputFile{} -> do
      ByteString
boundary <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ByteString
genBoundary
      forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @SetStickerSetThumbnailContent) (ByteString
boundary, SetStickerSetThumbnailRequest
r)
    InputFile
_ -> forall api.
HasClient ClientM api =>
Proxy api -> Client ClientM api
client (forall {k} (t :: k). Proxy t
Proxy @SetStickerSetThumbnailLink) SetStickerSetThumbnailRequest
r

foldMap makeDefault
  [ ''SendStickerRequest
  , ''GetCustomEmojiStickersRequest
  , ''UploadStickerFileRequest
  , ''CreateNewStickerSetRequest
  , ''AddStickerToSetRequest
  , ''SetStickerSetThumbnailRequest
  ]