module TD.Query.UploadStickerFile
  (UploadStickerFile(..)
  , defaultUploadStickerFile
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.StickerFormat as StickerFormat
import qualified TD.Data.InputFile as InputFile

-- | Uploads a file with a sticker; returns the uploaded file. Returns 'TD.Data.File.File'
data UploadStickerFile
  = UploadStickerFile
    { UploadStickerFile -> Maybe Int
user_id        :: Maybe Int                         -- ^ Sticker file owner; ignored for regular users
    , UploadStickerFile -> Maybe StickerFormat
sticker_format :: Maybe StickerFormat.StickerFormat -- ^ Sticker format
    , UploadStickerFile -> Maybe InputFile
sticker        :: Maybe InputFile.InputFile         -- ^ File file to upload; must fit in a 512x512 square. For WEBP stickers the file must be in WEBP or PNG format, which will be converted to WEBP server-side. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements
    }
  deriving (UploadStickerFile -> UploadStickerFile -> Bool
(UploadStickerFile -> UploadStickerFile -> Bool)
-> (UploadStickerFile -> UploadStickerFile -> Bool)
-> Eq UploadStickerFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UploadStickerFile -> UploadStickerFile -> Bool
== :: UploadStickerFile -> UploadStickerFile -> Bool
$c/= :: UploadStickerFile -> UploadStickerFile -> Bool
/= :: UploadStickerFile -> UploadStickerFile -> Bool
Eq, Int -> UploadStickerFile -> ShowS
[UploadStickerFile] -> ShowS
UploadStickerFile -> String
(Int -> UploadStickerFile -> ShowS)
-> (UploadStickerFile -> String)
-> ([UploadStickerFile] -> ShowS)
-> Show UploadStickerFile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UploadStickerFile -> ShowS
showsPrec :: Int -> UploadStickerFile -> ShowS
$cshow :: UploadStickerFile -> String
show :: UploadStickerFile -> String
$cshowList :: [UploadStickerFile] -> ShowS
showList :: [UploadStickerFile] -> ShowS
Show)

instance I.ShortShow UploadStickerFile where
  shortShow :: UploadStickerFile -> String
shortShow
    UploadStickerFile
      { user_id :: UploadStickerFile -> Maybe Int
user_id        = Maybe Int
user_id_
      , sticker_format :: UploadStickerFile -> Maybe StickerFormat
sticker_format = Maybe StickerFormat
sticker_format_
      , sticker :: UploadStickerFile -> Maybe InputFile
sticker        = Maybe InputFile
sticker_
      }
        = String
"UploadStickerFile"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"user_id"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"sticker_format" String -> Maybe StickerFormat -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StickerFormat
sticker_format_
          , String
"sticker"        String -> Maybe InputFile -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputFile
sticker_
          ]

instance AT.ToJSON UploadStickerFile where
  toJSON :: UploadStickerFile -> Value
toJSON
    UploadStickerFile
      { user_id :: UploadStickerFile -> Maybe Int
user_id        = Maybe Int
user_id_
      , sticker_format :: UploadStickerFile -> Maybe StickerFormat
sticker_format = Maybe StickerFormat
sticker_format_
      , sticker :: UploadStickerFile -> Maybe InputFile
sticker        = Maybe InputFile
sticker_
      }
        = [Pair] -> Value
A.object
          [ Key
"@type"          Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"uploadStickerFile"
          , Key
"user_id"        Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
user_id_
          , Key
"sticker_format" Key -> Maybe StickerFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe StickerFormat
sticker_format_
          , Key
"sticker"        Key -> Maybe InputFile -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputFile
sticker_
          ]

defaultUploadStickerFile :: UploadStickerFile
defaultUploadStickerFile :: UploadStickerFile
defaultUploadStickerFile =
  UploadStickerFile
    { user_id :: Maybe Int
user_id        = Maybe Int
forall a. Maybe a
Nothing
    , sticker_format :: Maybe StickerFormat
sticker_format = Maybe StickerFormat
forall a. Maybe a
Nothing
    , sticker :: Maybe InputFile
sticker        = Maybe InputFile
forall a. Maybe a
Nothing
    }