module TD.Query.EditForumTopic
  (EditForumTopic(..)
  , defaultEditForumTopic
  ) 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

-- | Edits title and icon of a topic in a forum supergroup chat; requires can_manage_topics right in the supergroup unless the user is creator of the topic. Returns 'TD.Data.Ok.Ok'
data EditForumTopic
  = EditForumTopic
    { EditForumTopic -> Maybe Int
chat_id                :: Maybe Int    -- ^ Identifier of the chat
    , EditForumTopic -> Maybe Int
message_thread_id      :: Maybe Int    -- ^ Message thread identifier of the forum topic
    , EditForumTopic -> Maybe Text
name                   :: Maybe T.Text -- ^ New name of the topic; 0-128 characters. If empty, the previous topic name is kept
    , EditForumTopic -> Maybe Bool
edit_icon_custom_emoji :: Maybe Bool   -- ^ Pass true to edit the icon of the topic. Icon of the General topic can't be edited
    , EditForumTopic -> Maybe Int
icon_custom_emoji_id   :: Maybe Int    -- ^ Identifier of the new custom emoji for topic icon; pass 0 to remove the custom emoji. Ignored if edit_icon_custom_emoji is false. Telegram Premium users can use any custom emoji, other users can use only a custom emoji returned by getForumTopicDefaultIcons
    }
  deriving (EditForumTopic -> EditForumTopic -> Bool
(EditForumTopic -> EditForumTopic -> Bool)
-> (EditForumTopic -> EditForumTopic -> Bool) -> Eq EditForumTopic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditForumTopic -> EditForumTopic -> Bool
== :: EditForumTopic -> EditForumTopic -> Bool
$c/= :: EditForumTopic -> EditForumTopic -> Bool
/= :: EditForumTopic -> EditForumTopic -> Bool
Eq, Int -> EditForumTopic -> ShowS
[EditForumTopic] -> ShowS
EditForumTopic -> String
(Int -> EditForumTopic -> ShowS)
-> (EditForumTopic -> String)
-> ([EditForumTopic] -> ShowS)
-> Show EditForumTopic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditForumTopic -> ShowS
showsPrec :: Int -> EditForumTopic -> ShowS
$cshow :: EditForumTopic -> String
show :: EditForumTopic -> String
$cshowList :: [EditForumTopic] -> ShowS
showList :: [EditForumTopic] -> ShowS
Show)

instance I.ShortShow EditForumTopic where
  shortShow :: EditForumTopic -> String
shortShow
    EditForumTopic
      { chat_id :: EditForumTopic -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , message_thread_id :: EditForumTopic -> Maybe Int
message_thread_id      = Maybe Int
message_thread_id_
      , name :: EditForumTopic -> Maybe Text
name                   = Maybe Text
name_
      , edit_icon_custom_emoji :: EditForumTopic -> Maybe Bool
edit_icon_custom_emoji = Maybe Bool
edit_icon_custom_emoji_
      , icon_custom_emoji_id :: EditForumTopic -> Maybe Int
icon_custom_emoji_id   = Maybe Int
icon_custom_emoji_id_
      }
        = String
"EditForumTopic"
          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
"message_thread_id"      String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_thread_id_
          , String
"name"                   String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          , String
"edit_icon_custom_emoji" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
edit_icon_custom_emoji_
          , String
"icon_custom_emoji_id"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
icon_custom_emoji_id_
          ]

instance AT.ToJSON EditForumTopic where
  toJSON :: EditForumTopic -> Value
toJSON
    EditForumTopic
      { chat_id :: EditForumTopic -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , message_thread_id :: EditForumTopic -> Maybe Int
message_thread_id      = Maybe Int
message_thread_id_
      , name :: EditForumTopic -> Maybe Text
name                   = Maybe Text
name_
      , edit_icon_custom_emoji :: EditForumTopic -> Maybe Bool
edit_icon_custom_emoji = Maybe Bool
edit_icon_custom_emoji_
      , icon_custom_emoji_id :: EditForumTopic -> Maybe Int
icon_custom_emoji_id   = Maybe Int
icon_custom_emoji_id_
      }
        = [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
"editForumTopic"
          , 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
"message_thread_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
message_thread_id_
          , Key
"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
name_
          , Key
"edit_icon_custom_emoji" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
edit_icon_custom_emoji_
          , Key
"icon_custom_emoji_id"   Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
icon_custom_emoji_id_
          ]

defaultEditForumTopic :: EditForumTopic
defaultEditForumTopic :: EditForumTopic
defaultEditForumTopic =
  EditForumTopic
    { chat_id :: Maybe Int
chat_id                = Maybe Int
forall a. Maybe a
Nothing
    , message_thread_id :: Maybe Int
message_thread_id      = Maybe Int
forall a. Maybe a
Nothing
    , name :: Maybe Text
name                   = Maybe Text
forall a. Maybe a
Nothing
    , edit_icon_custom_emoji :: Maybe Bool
edit_icon_custom_emoji = Maybe Bool
forall a. Maybe a
Nothing
    , icon_custom_emoji_id :: Maybe Int
icon_custom_emoji_id   = Maybe Int
forall a. Maybe a
Nothing
    }