module TD.Query.AddRecentSticker
  (AddRecentSticker(..)
  , defaultAddRecentSticker
  ) 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.InputFile as InputFile

-- | Manually adds a new sticker to the list of recently used stickers. The new sticker is added to the top of the list. If the sticker was already in the list, it is removed from the list first. Only stickers belonging to a sticker set or in WEBP or WEBM format can be added to this list. Emoji stickers can't be added to recent stickers. Returns 'TD.Data.Stickers.Stickers'
data AddRecentSticker
  = AddRecentSticker
    { AddRecentSticker -> Maybe Bool
is_attached :: Maybe Bool                -- ^ Pass true to add the sticker to the list of stickers recently attached to photo or video files; pass false to add the sticker to the list of recently sent stickers
    , AddRecentSticker -> Maybe InputFile
sticker     :: Maybe InputFile.InputFile -- ^ Sticker file to add
    }
  deriving (AddRecentSticker -> AddRecentSticker -> Bool
(AddRecentSticker -> AddRecentSticker -> Bool)
-> (AddRecentSticker -> AddRecentSticker -> Bool)
-> Eq AddRecentSticker
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddRecentSticker -> AddRecentSticker -> Bool
== :: AddRecentSticker -> AddRecentSticker -> Bool
$c/= :: AddRecentSticker -> AddRecentSticker -> Bool
/= :: AddRecentSticker -> AddRecentSticker -> Bool
Eq, Int -> AddRecentSticker -> ShowS
[AddRecentSticker] -> ShowS
AddRecentSticker -> String
(Int -> AddRecentSticker -> ShowS)
-> (AddRecentSticker -> String)
-> ([AddRecentSticker] -> ShowS)
-> Show AddRecentSticker
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddRecentSticker -> ShowS
showsPrec :: Int -> AddRecentSticker -> ShowS
$cshow :: AddRecentSticker -> String
show :: AddRecentSticker -> String
$cshowList :: [AddRecentSticker] -> ShowS
showList :: [AddRecentSticker] -> ShowS
Show)

instance I.ShortShow AddRecentSticker where
  shortShow :: AddRecentSticker -> String
shortShow
    AddRecentSticker
      { is_attached :: AddRecentSticker -> Maybe Bool
is_attached = Maybe Bool
is_attached_
      , sticker :: AddRecentSticker -> Maybe InputFile
sticker     = Maybe InputFile
sticker_
      }
        = String
"AddRecentSticker"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"is_attached" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_attached_
          , String
"sticker"     String -> Maybe InputFile -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputFile
sticker_
          ]

instance AT.ToJSON AddRecentSticker where
  toJSON :: AddRecentSticker -> Value
toJSON
    AddRecentSticker
      { is_attached :: AddRecentSticker -> Maybe Bool
is_attached = Maybe Bool
is_attached_
      , sticker :: AddRecentSticker -> 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
"addRecentSticker"
          , Key
"is_attached" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_attached_
          , 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_
          ]

defaultAddRecentSticker :: AddRecentSticker
defaultAddRecentSticker :: AddRecentSticker
defaultAddRecentSticker =
  AddRecentSticker
    { is_attached :: Maybe Bool
is_attached = Maybe Bool
forall a. Maybe a
Nothing
    , sticker :: Maybe InputFile
sticker     = Maybe InputFile
forall a. Maybe a
Nothing
    }