module TD.Data.BusinessBotManageBar
  (BusinessBotManageBar(..)) 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

data BusinessBotManageBar
  = BusinessBotManageBar -- ^ Contains information about a business bot that manages the chat
    { BusinessBotManageBar -> Maybe Int
bot_user_id   :: Maybe Int    -- ^ User identifier of the bot
    , BusinessBotManageBar -> Maybe Text
manage_url    :: Maybe T.Text -- ^ URL to be opened to manage the bot
    , BusinessBotManageBar -> Maybe Bool
is_bot_paused :: Maybe Bool   -- ^ True, if the bot is paused. Use toggleBusinessConnectedBotChatIsPaused to change the value of the field
    , BusinessBotManageBar -> Maybe Bool
can_bot_reply :: Maybe Bool   -- ^ True, if the bot can reply
    }
  deriving (BusinessBotManageBar -> BusinessBotManageBar -> Bool
(BusinessBotManageBar -> BusinessBotManageBar -> Bool)
-> (BusinessBotManageBar -> BusinessBotManageBar -> Bool)
-> Eq BusinessBotManageBar
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BusinessBotManageBar -> BusinessBotManageBar -> Bool
== :: BusinessBotManageBar -> BusinessBotManageBar -> Bool
$c/= :: BusinessBotManageBar -> BusinessBotManageBar -> Bool
/= :: BusinessBotManageBar -> BusinessBotManageBar -> Bool
Eq, Int -> BusinessBotManageBar -> ShowS
[BusinessBotManageBar] -> ShowS
BusinessBotManageBar -> String
(Int -> BusinessBotManageBar -> ShowS)
-> (BusinessBotManageBar -> String)
-> ([BusinessBotManageBar] -> ShowS)
-> Show BusinessBotManageBar
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BusinessBotManageBar -> ShowS
showsPrec :: Int -> BusinessBotManageBar -> ShowS
$cshow :: BusinessBotManageBar -> String
show :: BusinessBotManageBar -> String
$cshowList :: [BusinessBotManageBar] -> ShowS
showList :: [BusinessBotManageBar] -> ShowS
Show)

instance I.ShortShow BusinessBotManageBar where
  shortShow :: BusinessBotManageBar -> String
shortShow BusinessBotManageBar
    { bot_user_id :: BusinessBotManageBar -> Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
    , manage_url :: BusinessBotManageBar -> Maybe Text
manage_url    = Maybe Text
manage_url_
    , is_bot_paused :: BusinessBotManageBar -> Maybe Bool
is_bot_paused = Maybe Bool
is_bot_paused_
    , can_bot_reply :: BusinessBotManageBar -> Maybe Bool
can_bot_reply = Maybe Bool
can_bot_reply_
    }
      = String
"BusinessBotManageBar"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"bot_user_id"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bot_user_id_
        , String
"manage_url"    String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
manage_url_
        , String
"is_bot_paused" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_bot_paused_
        , String
"can_bot_reply" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_bot_reply_
        ]

instance AT.FromJSON BusinessBotManageBar where
  parseJSON :: Value -> Parser BusinessBotManageBar
parseJSON v :: Value
v@(AT.Object Object
obj) = do
    String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String

    case String
t of
      String
"businessBotManageBar" -> Value -> Parser BusinessBotManageBar
parseBusinessBotManageBar Value
v
      String
_                      -> Parser BusinessBotManageBar
forall a. Monoid a => a
mempty
    
    where
      parseBusinessBotManageBar :: A.Value -> AT.Parser BusinessBotManageBar
      parseBusinessBotManageBar :: Value -> Parser BusinessBotManageBar
parseBusinessBotManageBar = String
-> (Object -> Parser BusinessBotManageBar)
-> Value
-> Parser BusinessBotManageBar
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BusinessBotManageBar" ((Object -> Parser BusinessBotManageBar)
 -> Value -> Parser BusinessBotManageBar)
-> (Object -> Parser BusinessBotManageBar)
-> Value
-> Parser BusinessBotManageBar
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
bot_user_id_   <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"bot_user_id"
        Maybe Text
manage_url_    <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"manage_url"
        Maybe Bool
is_bot_paused_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_bot_paused"
        Maybe Bool
can_bot_reply_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_bot_reply"
        BusinessBotManageBar -> Parser BusinessBotManageBar
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BusinessBotManageBar -> Parser BusinessBotManageBar)
-> BusinessBotManageBar -> Parser BusinessBotManageBar
forall a b. (a -> b) -> a -> b
$ BusinessBotManageBar
          { bot_user_id :: Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
          , manage_url :: Maybe Text
manage_url    = Maybe Text
manage_url_
          , is_bot_paused :: Maybe Bool
is_bot_paused = Maybe Bool
is_bot_paused_
          , can_bot_reply :: Maybe Bool
can_bot_reply = Maybe Bool
can_bot_reply_
          }
  parseJSON Value
_ = Parser BusinessBotManageBar
forall a. Monoid a => a
mempty