module TD.Query.DeleteChatBackground
  (DeleteChatBackground(..)
  , defaultDeleteChatBackground
  ) where

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

-- | Deletes background in a specific chat. Returns 'TD.Data.Ok.Ok'
data DeleteChatBackground
  = DeleteChatBackground
    { DeleteChatBackground -> Maybe Int
chat_id          :: Maybe Int  -- ^ Chat identifier
    , DeleteChatBackground -> Maybe Bool
restore_previous :: Maybe Bool -- ^ Pass true to restore previously set background. Can be used only in private and secret chats with non-deleted users if userFullInfo.set_chat_background == true. Supposed to be used from messageChatSetBackground messages with the currently set background that was set for both sides by the other user
    }
  deriving (DeleteChatBackground -> DeleteChatBackground -> Bool
(DeleteChatBackground -> DeleteChatBackground -> Bool)
-> (DeleteChatBackground -> DeleteChatBackground -> Bool)
-> Eq DeleteChatBackground
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeleteChatBackground -> DeleteChatBackground -> Bool
== :: DeleteChatBackground -> DeleteChatBackground -> Bool
$c/= :: DeleteChatBackground -> DeleteChatBackground -> Bool
/= :: DeleteChatBackground -> DeleteChatBackground -> Bool
Eq, Int -> DeleteChatBackground -> ShowS
[DeleteChatBackground] -> ShowS
DeleteChatBackground -> String
(Int -> DeleteChatBackground -> ShowS)
-> (DeleteChatBackground -> String)
-> ([DeleteChatBackground] -> ShowS)
-> Show DeleteChatBackground
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeleteChatBackground -> ShowS
showsPrec :: Int -> DeleteChatBackground -> ShowS
$cshow :: DeleteChatBackground -> String
show :: DeleteChatBackground -> String
$cshowList :: [DeleteChatBackground] -> ShowS
showList :: [DeleteChatBackground] -> ShowS
Show)

instance I.ShortShow DeleteChatBackground where
  shortShow :: DeleteChatBackground -> String
shortShow
    DeleteChatBackground
      { chat_id :: DeleteChatBackground -> Maybe Int
chat_id          = Maybe Int
chat_id_
      , restore_previous :: DeleteChatBackground -> Maybe Bool
restore_previous = Maybe Bool
restore_previous_
      }
        = String
"DeleteChatBackground"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id"          String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"restore_previous" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
restore_previous_
          ]

instance AT.ToJSON DeleteChatBackground where
  toJSON :: DeleteChatBackground -> Value
toJSON
    DeleteChatBackground
      { chat_id :: DeleteChatBackground -> Maybe Int
chat_id          = Maybe Int
chat_id_
      , restore_previous :: DeleteChatBackground -> Maybe Bool
restore_previous = Maybe Bool
restore_previous_
      }
        = [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
"deleteChatBackground"
          , Key
"chat_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
chat_id_
          , Key
"restore_previous" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
restore_previous_
          ]

defaultDeleteChatBackground :: DeleteChatBackground
defaultDeleteChatBackground :: DeleteChatBackground
defaultDeleteChatBackground =
  DeleteChatBackground
    { chat_id :: Maybe Int
chat_id          = Maybe Int
forall a. Maybe a
Nothing
    , restore_previous :: Maybe Bool
restore_previous = Maybe Bool
forall a. Maybe a
Nothing
    }