module TD.Query.AddBotMediaPreview
  (AddBotMediaPreview(..)
  , defaultAddBotMediaPreview
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
import qualified TD.Data.InputStoryContent as InputStoryContent

-- | Adds a new media preview to the beginning of the list of media previews of a bot. Returns the added preview after addition is completed server-side. The total number of previews must not exceed getOption("bot_media_preview_count_max") for the given language. Returns 'TD.Data.BotMediaPreview.BotMediaPreview'
data AddBotMediaPreview
  = AddBotMediaPreview
    { AddBotMediaPreview -> Maybe Int
bot_user_id   :: Maybe Int                                 -- ^ Identifier of the target bot. The bot must be owned and must have the main Web App
    , AddBotMediaPreview -> Maybe Text
language_code :: Maybe T.Text                              -- ^ A two-letter ISO 639-1 language code for which preview is added. If empty, then the preview will be shown to all users for whose languages there are no dedicated previews. If non-empty, then there must be an official language pack of the same name, which is returned by getLocalizationTargetInfo
    , AddBotMediaPreview -> Maybe InputStoryContent
content       :: Maybe InputStoryContent.InputStoryContent -- ^ Content of the added preview
    }
  deriving (AddBotMediaPreview -> AddBotMediaPreview -> Bool
(AddBotMediaPreview -> AddBotMediaPreview -> Bool)
-> (AddBotMediaPreview -> AddBotMediaPreview -> Bool)
-> Eq AddBotMediaPreview
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddBotMediaPreview -> AddBotMediaPreview -> Bool
== :: AddBotMediaPreview -> AddBotMediaPreview -> Bool
$c/= :: AddBotMediaPreview -> AddBotMediaPreview -> Bool
/= :: AddBotMediaPreview -> AddBotMediaPreview -> Bool
Eq, Int -> AddBotMediaPreview -> ShowS
[AddBotMediaPreview] -> ShowS
AddBotMediaPreview -> String
(Int -> AddBotMediaPreview -> ShowS)
-> (AddBotMediaPreview -> String)
-> ([AddBotMediaPreview] -> ShowS)
-> Show AddBotMediaPreview
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddBotMediaPreview -> ShowS
showsPrec :: Int -> AddBotMediaPreview -> ShowS
$cshow :: AddBotMediaPreview -> String
show :: AddBotMediaPreview -> String
$cshowList :: [AddBotMediaPreview] -> ShowS
showList :: [AddBotMediaPreview] -> ShowS
Show)

instance I.ShortShow AddBotMediaPreview where
  shortShow :: AddBotMediaPreview -> String
shortShow
    AddBotMediaPreview
      { bot_user_id :: AddBotMediaPreview -> Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
      , language_code :: AddBotMediaPreview -> Maybe Text
language_code = Maybe Text
language_code_
      , content :: AddBotMediaPreview -> Maybe InputStoryContent
content       = Maybe InputStoryContent
content_
      }
        = String
"AddBotMediaPreview"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"bot_user_id"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bot_user_id_
          , String
"language_code" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
language_code_
          , String
"content"       String -> Maybe InputStoryContent -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputStoryContent
content_
          ]

instance AT.ToJSON AddBotMediaPreview where
  toJSON :: AddBotMediaPreview -> Value
toJSON
    AddBotMediaPreview
      { bot_user_id :: AddBotMediaPreview -> Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
      , language_code :: AddBotMediaPreview -> Maybe Text
language_code = Maybe Text
language_code_
      , content :: AddBotMediaPreview -> Maybe InputStoryContent
content       = Maybe InputStoryContent
content_
      }
        = [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
"addBotMediaPreview"
          , Key
"bot_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
bot_user_id_
          , Key
"language_code" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
language_code_
          , Key
"content"       Key -> Maybe InputStoryContent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputStoryContent
content_
          ]

defaultAddBotMediaPreview :: AddBotMediaPreview
defaultAddBotMediaPreview :: AddBotMediaPreview
defaultAddBotMediaPreview =
  AddBotMediaPreview
    { bot_user_id :: Maybe Int
bot_user_id   = Maybe Int
forall a. Maybe a
Nothing
    , language_code :: Maybe Text
language_code = Maybe Text
forall a. Maybe a
Nothing
    , content :: Maybe InputStoryContent
content       = Maybe InputStoryContent
forall a. Maybe a
Nothing
    }