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

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Time.Clock.POSIX (POSIXTime)
import GHC.Generics (Generic)

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

-- ** 'BusinessConnection'

-- | Describes the connection of the bot with a business account.
data BusinessConnection = BusinessConnection
  { BusinessConnection -> BusinessConnectionId
businessConnectionId :: BusinessConnectionId -- ^ Unique identifier of the business connection.
  , BusinessConnection -> User
businessConnectionUser :: User -- ^ Business account user that created the business connection.
  , BusinessConnection -> ChatId
businessConnectionUserChatId :: ChatId -- ^ Identifier of a private chat with the user who created the business connection. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
  , BusinessConnection -> POSIXTime
businessConnectionDate :: POSIXTime -- ^ Date the connection was established in Unix time.
  , BusinessConnection -> Bool
businessConnectionCanReply :: Bool -- ^ 'True', if the bot can act on behalf of the business account in chats that were active in the last 24 hours.
  , BusinessConnection -> Bool
businessConnectionIsEnabled :: Bool -- ^ 'True', if the connection is active.
  }
  deriving ((forall x. BusinessConnection -> Rep BusinessConnection x)
-> (forall x. Rep BusinessConnection x -> BusinessConnection)
-> Generic BusinessConnection
forall x. Rep BusinessConnection x -> BusinessConnection
forall x. BusinessConnection -> Rep BusinessConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BusinessConnection -> Rep BusinessConnection x
from :: forall x. BusinessConnection -> Rep BusinessConnection x
$cto :: forall x. Rep BusinessConnection x -> BusinessConnection
to :: forall x. Rep BusinessConnection x -> BusinessConnection
Generic, Int -> BusinessConnection -> ShowS
[BusinessConnection] -> ShowS
BusinessConnection -> String
(Int -> BusinessConnection -> ShowS)
-> (BusinessConnection -> String)
-> ([BusinessConnection] -> ShowS)
-> Show BusinessConnection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BusinessConnection -> ShowS
showsPrec :: Int -> BusinessConnection -> ShowS
$cshow :: BusinessConnection -> String
show :: BusinessConnection -> String
$cshowList :: [BusinessConnection] -> ShowS
showList :: [BusinessConnection] -> ShowS
Show)

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