module TD.Query.CreateForumTopic
  (CreateForumTopic(..)
  , defaultCreateForumTopic
  ) 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.ForumTopicIcon as ForumTopicIcon

-- | Creates a topic in a forum supergroup chat; requires can_manage_topics administrator or can_create_topics member right in the supergroup. Returns 'TD.Data.ForumTopicInfo.ForumTopicInfo'
data CreateForumTopic
  = CreateForumTopic
    { CreateForumTopic -> Maybe Int
chat_id :: Maybe Int                           -- ^ Identifier of the chat
    , CreateForumTopic -> Maybe Text
name    :: Maybe T.Text                        -- ^ Name of the topic; 1-128 characters
    , CreateForumTopic -> Maybe ForumTopicIcon
icon    :: Maybe ForumTopicIcon.ForumTopicIcon -- ^ Icon of the topic. Icon color must be one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F. Telegram Premium users can use any custom emoji as topic icon, other users can use only a custom emoji returned by getForumTopicDefaultIcons
    }
  deriving (CreateForumTopic -> CreateForumTopic -> Bool
(CreateForumTopic -> CreateForumTopic -> Bool)
-> (CreateForumTopic -> CreateForumTopic -> Bool)
-> Eq CreateForumTopic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateForumTopic -> CreateForumTopic -> Bool
== :: CreateForumTopic -> CreateForumTopic -> Bool
$c/= :: CreateForumTopic -> CreateForumTopic -> Bool
/= :: CreateForumTopic -> CreateForumTopic -> Bool
Eq, Int -> CreateForumTopic -> ShowS
[CreateForumTopic] -> ShowS
CreateForumTopic -> String
(Int -> CreateForumTopic -> ShowS)
-> (CreateForumTopic -> String)
-> ([CreateForumTopic] -> ShowS)
-> Show CreateForumTopic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateForumTopic -> ShowS
showsPrec :: Int -> CreateForumTopic -> ShowS
$cshow :: CreateForumTopic -> String
show :: CreateForumTopic -> String
$cshowList :: [CreateForumTopic] -> ShowS
showList :: [CreateForumTopic] -> ShowS
Show)

instance I.ShortShow CreateForumTopic where
  shortShow :: CreateForumTopic -> String
shortShow
    CreateForumTopic
      { chat_id :: CreateForumTopic -> Maybe Int
chat_id = Maybe Int
chat_id_
      , name :: CreateForumTopic -> Maybe Text
name    = Maybe Text
name_
      , icon :: CreateForumTopic -> Maybe ForumTopicIcon
icon    = Maybe ForumTopicIcon
icon_
      }
        = String
"CreateForumTopic"
          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
"name"    String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          , String
"icon"    String -> Maybe ForumTopicIcon -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ForumTopicIcon
icon_
          ]

instance AT.ToJSON CreateForumTopic where
  toJSON :: CreateForumTopic -> Value
toJSON
    CreateForumTopic
      { chat_id :: CreateForumTopic -> Maybe Int
chat_id = Maybe Int
chat_id_
      , name :: CreateForumTopic -> Maybe Text
name    = Maybe Text
name_
      , icon :: CreateForumTopic -> Maybe ForumTopicIcon
icon    = Maybe ForumTopicIcon
icon_
      }
        = [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
"createForumTopic"
          , 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
"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
"icon"    Key -> Maybe ForumTopicIcon -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ForumTopicIcon
icon_
          ]

defaultCreateForumTopic :: CreateForumTopic
defaultCreateForumTopic :: CreateForumTopic
defaultCreateForumTopic =
  CreateForumTopic
    { chat_id :: Maybe Int
chat_id = Maybe Int
forall a. Maybe a
Nothing
    , name :: Maybe Text
name    = Maybe Text
forall a. Maybe a
Nothing
    , icon :: Maybe ForumTopicIcon
icon    = Maybe ForumTopicIcon
forall a. Maybe a
Nothing
    }