module TD.Query.ToggleChatViewAsTopics
  (ToggleChatViewAsTopics(..)
  , defaultToggleChatViewAsTopics
  ) where

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

-- | Changes the view_as_topics setting of a forum chat or Saved Messages. Returns 'TD.Data.Ok.Ok'
data ToggleChatViewAsTopics
  = ToggleChatViewAsTopics
    { ToggleChatViewAsTopics -> Maybe Int
chat_id        :: Maybe Int  -- ^ Chat identifier
    , ToggleChatViewAsTopics -> Maybe Bool
view_as_topics :: Maybe Bool -- ^ New value of view_as_topics
    }
  deriving (ToggleChatViewAsTopics -> ToggleChatViewAsTopics -> Bool
(ToggleChatViewAsTopics -> ToggleChatViewAsTopics -> Bool)
-> (ToggleChatViewAsTopics -> ToggleChatViewAsTopics -> Bool)
-> Eq ToggleChatViewAsTopics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToggleChatViewAsTopics -> ToggleChatViewAsTopics -> Bool
== :: ToggleChatViewAsTopics -> ToggleChatViewAsTopics -> Bool
$c/= :: ToggleChatViewAsTopics -> ToggleChatViewAsTopics -> Bool
/= :: ToggleChatViewAsTopics -> ToggleChatViewAsTopics -> Bool
Eq, Int -> ToggleChatViewAsTopics -> ShowS
[ToggleChatViewAsTopics] -> ShowS
ToggleChatViewAsTopics -> String
(Int -> ToggleChatViewAsTopics -> ShowS)
-> (ToggleChatViewAsTopics -> String)
-> ([ToggleChatViewAsTopics] -> ShowS)
-> Show ToggleChatViewAsTopics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToggleChatViewAsTopics -> ShowS
showsPrec :: Int -> ToggleChatViewAsTopics -> ShowS
$cshow :: ToggleChatViewAsTopics -> String
show :: ToggleChatViewAsTopics -> String
$cshowList :: [ToggleChatViewAsTopics] -> ShowS
showList :: [ToggleChatViewAsTopics] -> ShowS
Show)

instance I.ShortShow ToggleChatViewAsTopics where
  shortShow :: ToggleChatViewAsTopics -> String
shortShow
    ToggleChatViewAsTopics
      { chat_id :: ToggleChatViewAsTopics -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , view_as_topics :: ToggleChatViewAsTopics -> Maybe Bool
view_as_topics = Maybe Bool
view_as_topics_
      }
        = String
"ToggleChatViewAsTopics"
          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
"view_as_topics" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
view_as_topics_
          ]

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

defaultToggleChatViewAsTopics :: ToggleChatViewAsTopics
defaultToggleChatViewAsTopics :: ToggleChatViewAsTopics
defaultToggleChatViewAsTopics =
  ToggleChatViewAsTopics
    { chat_id :: Maybe Int
chat_id        = Maybe Int
forall a. Maybe a
Nothing
    , view_as_topics :: Maybe Bool
view_as_topics = Maybe Bool
forall a. Maybe a
Nothing
    }