module TD.Query.SetChatTheme
  (SetChatTheme(..)
  , defaultSetChatTheme
  ) 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

-- | Changes the chat theme. Supported only in private and secret chats. Returns 'TD.Data.Ok.Ok'
data SetChatTheme
  = SetChatTheme
    { SetChatTheme -> Maybe Int
chat_id    :: Maybe Int    -- ^ Chat identifier
    , SetChatTheme -> Maybe Text
theme_name :: Maybe T.Text -- ^ Name of the new chat theme; pass an empty string to return the default theme
    }
  deriving (SetChatTheme -> SetChatTheme -> Bool
(SetChatTheme -> SetChatTheme -> Bool)
-> (SetChatTheme -> SetChatTheme -> Bool) -> Eq SetChatTheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetChatTheme -> SetChatTheme -> Bool
== :: SetChatTheme -> SetChatTheme -> Bool
$c/= :: SetChatTheme -> SetChatTheme -> Bool
/= :: SetChatTheme -> SetChatTheme -> Bool
Eq, Int -> SetChatTheme -> ShowS
[SetChatTheme] -> ShowS
SetChatTheme -> String
(Int -> SetChatTheme -> ShowS)
-> (SetChatTheme -> String)
-> ([SetChatTheme] -> ShowS)
-> Show SetChatTheme
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetChatTheme -> ShowS
showsPrec :: Int -> SetChatTheme -> ShowS
$cshow :: SetChatTheme -> String
show :: SetChatTheme -> String
$cshowList :: [SetChatTheme] -> ShowS
showList :: [SetChatTheme] -> ShowS
Show)

instance I.ShortShow SetChatTheme where
  shortShow :: SetChatTheme -> String
shortShow
    SetChatTheme
      { chat_id :: SetChatTheme -> Maybe Int
chat_id    = Maybe Int
chat_id_
      , theme_name :: SetChatTheme -> Maybe Text
theme_name = Maybe Text
theme_name_
      }
        = String
"SetChatTheme"
          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
"theme_name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
theme_name_
          ]

instance AT.ToJSON SetChatTheme where
  toJSON :: SetChatTheme -> Value
toJSON
    SetChatTheme
      { chat_id :: SetChatTheme -> Maybe Int
chat_id    = Maybe Int
chat_id_
      , theme_name :: SetChatTheme -> Maybe Text
theme_name = Maybe Text
theme_name_
      }
        = [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
"setChatTheme"
          , 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
"theme_name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
theme_name_
          ]

defaultSetChatTheme :: SetChatTheme
defaultSetChatTheme :: SetChatTheme
defaultSetChatTheme =
  SetChatTheme
    { chat_id :: Maybe Int
chat_id    = Maybe Int
forall a. Maybe a
Nothing
    , theme_name :: Maybe Text
theme_name = Maybe Text
forall a. Maybe a
Nothing
    }