module TD.Query.SearchStickers
  (SearchStickers(..)
  , defaultSearchStickers
  ) 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.StickerType as StickerType
import qualified Data.Text as T

-- | Searches for stickers from public sticker sets that correspond to any of the given emoji. Returns 'TD.Data.Stickers.Stickers'
data SearchStickers
  = SearchStickers
    { SearchStickers -> Maybe StickerType
sticker_type :: Maybe StickerType.StickerType -- ^ Type of the stickers to return
    , SearchStickers -> Maybe Text
emojis       :: Maybe T.Text                  -- ^ Space-separated list of emojis to search for; must be non-empty
    , SearchStickers -> Maybe Int
limit        :: Maybe Int                     -- ^ The maximum number of stickers to be returned; 0-100
    }
  deriving (SearchStickers -> SearchStickers -> Bool
(SearchStickers -> SearchStickers -> Bool)
-> (SearchStickers -> SearchStickers -> Bool) -> Eq SearchStickers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SearchStickers -> SearchStickers -> Bool
== :: SearchStickers -> SearchStickers -> Bool
$c/= :: SearchStickers -> SearchStickers -> Bool
/= :: SearchStickers -> SearchStickers -> Bool
Eq, Int -> SearchStickers -> ShowS
[SearchStickers] -> ShowS
SearchStickers -> String
(Int -> SearchStickers -> ShowS)
-> (SearchStickers -> String)
-> ([SearchStickers] -> ShowS)
-> Show SearchStickers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SearchStickers -> ShowS
showsPrec :: Int -> SearchStickers -> ShowS
$cshow :: SearchStickers -> String
show :: SearchStickers -> String
$cshowList :: [SearchStickers] -> ShowS
showList :: [SearchStickers] -> ShowS
Show)

instance I.ShortShow SearchStickers where
  shortShow :: SearchStickers -> String
shortShow
    SearchStickers
      { sticker_type :: SearchStickers -> Maybe StickerType
sticker_type = Maybe StickerType
sticker_type_
      , emojis :: SearchStickers -> Maybe Text
emojis       = Maybe Text
emojis_
      , limit :: SearchStickers -> Maybe Int
limit        = Maybe Int
limit_
      }
        = String
"SearchStickers"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"sticker_type" String -> Maybe StickerType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StickerType
sticker_type_
          , String
"emojis"       String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
emojis_
          , String
"limit"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON SearchStickers where
  toJSON :: SearchStickers -> Value
toJSON
    SearchStickers
      { sticker_type :: SearchStickers -> Maybe StickerType
sticker_type = Maybe StickerType
sticker_type_
      , emojis :: SearchStickers -> Maybe Text
emojis       = Maybe Text
emojis_
      , limit :: SearchStickers -> Maybe Int
limit        = Maybe Int
limit_
      }
        = [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
"searchStickers"
          , Key
"sticker_type" Key -> Maybe StickerType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe StickerType
sticker_type_
          , Key
"emojis"       Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
emojis_
          , Key
"limit"        Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
limit_
          ]

defaultSearchStickers :: SearchStickers
defaultSearchStickers :: SearchStickers
defaultSearchStickers =
  SearchStickers
    { sticker_type :: Maybe StickerType
sticker_type = Maybe StickerType
forall a. Maybe a
Nothing
    , emojis :: Maybe Text
emojis       = Maybe Text
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit        = Maybe Int
forall a. Maybe a
Nothing
    }