{-# LANGUAGE DeriveGeneric #-}
module Telegram.Bot.API.Types.Chat where

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Text
import GHC.Generics (Generic)

import Telegram.Bot.API.Internal.Utils
import Telegram.Bot.API.Types.ChatType
import Telegram.Bot.API.Types.Common

-- ** 'Chat'

-- | This object represents a chat.
data Chat = Chat
  { Chat -> ChatId
chatId :: ChatId -- ^ Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
  , Chat -> ChatType
chatType :: ChatType -- ^ Type of the chat, can be either “private”, “group”, “supergroup” or “channel”
  , Chat -> Maybe Text
chatTitle :: Maybe Text -- ^ Title, for supergroups, channels and group chats.
  , Chat -> Maybe Text
chatUsername :: Maybe Text -- ^ Username, for private chats, supergroups and channels if available.
  , Chat -> Maybe Text
chatFirstName :: Maybe Text -- ^ First name of the other party in a private chat.
  , Chat -> Maybe Text
chatLastName :: Maybe Text -- ^ Last name of the other party in a private chat.
  , Chat -> Maybe Bool
chatIsForum :: Maybe Bool -- ^ 'True', if the supergroup chat is a forum (has topics enabled).
  }
  deriving ((forall x. Chat -> Rep Chat x)
-> (forall x. Rep Chat x -> Chat) -> Generic Chat
forall x. Rep Chat x -> Chat
forall x. Chat -> Rep Chat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Chat -> Rep Chat x
from :: forall x. Chat -> Rep Chat x
$cto :: forall x. Rep Chat x -> Chat
to :: forall x. Rep Chat x -> Chat
Generic, Int -> Chat -> ShowS
[Chat] -> ShowS
Chat -> String
(Int -> Chat -> ShowS)
-> (Chat -> String) -> ([Chat] -> ShowS) -> Show Chat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Chat -> ShowS
showsPrec :: Int -> Chat -> ShowS
$cshow :: Chat -> String
show :: Chat -> String
$cshowList :: [Chat] -> ShowS
showList :: [Chat] -> ShowS
Show)

instance ToJSON   Chat where toJSON :: Chat -> Value
toJSON = Chat -> Value
forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
instance FromJSON Chat where parseJSON :: Value -> Parser Chat
parseJSON = Value -> Parser Chat
forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON