module TD.Query.EditBotMediaPreview
  (EditBotMediaPreview(..)
  , defaultEditBotMediaPreview
  ) 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

-- | Replaces media preview in the list of media previews of a bot. Returns the new preview after edit is completed server-side. Returns 'TD.Data.BotMediaPreview.BotMediaPreview'
data EditBotMediaPreview
  = EditBotMediaPreview
    { EditBotMediaPreview -> Maybe Int
bot_user_id   :: Maybe Int                                 -- ^ Identifier of the target bot. The bot must be owned and must have the main Web App
    , EditBotMediaPreview -> Maybe Text
language_code :: Maybe T.Text                              -- ^ Language code of the media preview to edit
    , EditBotMediaPreview -> Maybe Int
file_id       :: Maybe Int                                 -- ^ File identifier of the media to replace
    , EditBotMediaPreview -> Maybe InputStoryContent
content       :: Maybe InputStoryContent.InputStoryContent -- ^ Content of the new preview
    }
  deriving (EditBotMediaPreview -> EditBotMediaPreview -> Bool
(EditBotMediaPreview -> EditBotMediaPreview -> Bool)
-> (EditBotMediaPreview -> EditBotMediaPreview -> Bool)
-> Eq EditBotMediaPreview
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditBotMediaPreview -> EditBotMediaPreview -> Bool
== :: EditBotMediaPreview -> EditBotMediaPreview -> Bool
$c/= :: EditBotMediaPreview -> EditBotMediaPreview -> Bool
/= :: EditBotMediaPreview -> EditBotMediaPreview -> Bool
Eq, Int -> EditBotMediaPreview -> ShowS
[EditBotMediaPreview] -> ShowS
EditBotMediaPreview -> String
(Int -> EditBotMediaPreview -> ShowS)
-> (EditBotMediaPreview -> String)
-> ([EditBotMediaPreview] -> ShowS)
-> Show EditBotMediaPreview
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditBotMediaPreview -> ShowS
showsPrec :: Int -> EditBotMediaPreview -> ShowS
$cshow :: EditBotMediaPreview -> String
show :: EditBotMediaPreview -> String
$cshowList :: [EditBotMediaPreview] -> ShowS
showList :: [EditBotMediaPreview] -> ShowS
Show)

instance I.ShortShow EditBotMediaPreview where
  shortShow :: EditBotMediaPreview -> String
shortShow
    EditBotMediaPreview
      { bot_user_id :: EditBotMediaPreview -> Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
      , language_code :: EditBotMediaPreview -> Maybe Text
language_code = Maybe Text
language_code_
      , file_id :: EditBotMediaPreview -> Maybe Int
file_id       = Maybe Int
file_id_
      , content :: EditBotMediaPreview -> Maybe InputStoryContent
content       = Maybe InputStoryContent
content_
      }
        = String
"EditBotMediaPreview"
          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
"file_id"       String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
file_id_
          , String
"content"       String -> Maybe InputStoryContent -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputStoryContent
content_
          ]

instance AT.ToJSON EditBotMediaPreview where
  toJSON :: EditBotMediaPreview -> Value
toJSON
    EditBotMediaPreview
      { bot_user_id :: EditBotMediaPreview -> Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
      , language_code :: EditBotMediaPreview -> Maybe Text
language_code = Maybe Text
language_code_
      , file_id :: EditBotMediaPreview -> Maybe Int
file_id       = Maybe Int
file_id_
      , content :: EditBotMediaPreview -> 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
"editBotMediaPreview"
          , 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
"file_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
file_id_
          , 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_
          ]

defaultEditBotMediaPreview :: EditBotMediaPreview
defaultEditBotMediaPreview :: EditBotMediaPreview
defaultEditBotMediaPreview =
  EditBotMediaPreview
    { 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
    , file_id :: Maybe Int
file_id       = Maybe Int
forall a. Maybe a
Nothing
    , content :: Maybe InputStoryContent
content       = Maybe InputStoryContent
forall a. Maybe a
Nothing
    }