module TD.Data.BotInfo
  (BotInfo(..)) 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.Photo as Photo
import qualified TD.Data.Animation as Animation
import qualified TD.Data.BotMenuButton as BotMenuButton
import qualified TD.Data.BotCommand as BotCommand
import qualified TD.Data.ChatAdministratorRights as ChatAdministratorRights
import qualified TD.Data.InternalLinkType as InternalLinkType

data BotInfo
  = BotInfo -- ^ Contains information about a bot
    { BotInfo -> Maybe Text
short_description                    :: Maybe T.Text                                          -- ^ The text that is shown on the bot's profile page and is sent together with the link when users share the bot
    , BotInfo -> Maybe Text
description                          :: Maybe T.Text                                          -- ^ The text shown in the chat with the bot if the chat is empty
    , BotInfo -> Maybe Photo
photo                                :: Maybe Photo.Photo                                     -- ^ Photo shown in the chat with the bot if the chat is empty; may be null
    , BotInfo -> Maybe Animation
animation                            :: Maybe Animation.Animation                             -- ^ Animation shown in the chat with the bot if the chat is empty; may be null
    , BotInfo -> Maybe BotMenuButton
menu_button                          :: Maybe BotMenuButton.BotMenuButton                     -- ^ Information about a button to show instead of the bot commands menu button; may be null if ordinary bot commands menu must be shown
    , BotInfo -> Maybe [BotCommand]
commands                             :: Maybe [BotCommand.BotCommand]                         -- ^ List of the bot commands
    , BotInfo -> Maybe Text
privacy_policy_url                   :: Maybe T.Text                                          -- ^ The HTTP link to the privacy policy of the bot. If empty, then /privacy command must be used if supported by the bot. If the command isn't supported, then https://telegram.org/privacy-tpa must be opened
    , BotInfo -> Maybe ChatAdministratorRights
default_group_administrator_rights   :: Maybe ChatAdministratorRights.ChatAdministratorRights -- ^ Default administrator rights for adding the bot to basic group and supergroup chats; may be null
    , BotInfo -> Maybe ChatAdministratorRights
default_channel_administrator_rights :: Maybe ChatAdministratorRights.ChatAdministratorRights -- ^ Default administrator rights for adding the bot to channels; may be null
    , BotInfo -> Maybe Bool
has_media_previews                   :: Maybe Bool                                            -- ^ True, if the bot has media previews
    , BotInfo -> Maybe InternalLinkType
edit_commands_link                   :: Maybe InternalLinkType.InternalLinkType               -- ^ The internal link, which can be used to edit bot commands; may be null
    , BotInfo -> Maybe InternalLinkType
edit_description_link                :: Maybe InternalLinkType.InternalLinkType               -- ^ The internal link, which can be used to edit bot description; may be null
    , BotInfo -> Maybe InternalLinkType
edit_description_media_link          :: Maybe InternalLinkType.InternalLinkType               -- ^ The internal link, which can be used to edit the photo or animation shown in the chat with the bot if the chat is empty; may be null
    , BotInfo -> Maybe InternalLinkType
edit_settings_link                   :: Maybe InternalLinkType.InternalLinkType               -- ^ The internal link, which can be used to edit bot settings; may be null
    }
  deriving (BotInfo -> BotInfo -> Bool
(BotInfo -> BotInfo -> Bool)
-> (BotInfo -> BotInfo -> Bool) -> Eq BotInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BotInfo -> BotInfo -> Bool
== :: BotInfo -> BotInfo -> Bool
$c/= :: BotInfo -> BotInfo -> Bool
/= :: BotInfo -> BotInfo -> Bool
Eq, Int -> BotInfo -> ShowS
[BotInfo] -> ShowS
BotInfo -> String
(Int -> BotInfo -> ShowS)
-> (BotInfo -> String) -> ([BotInfo] -> ShowS) -> Show BotInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BotInfo -> ShowS
showsPrec :: Int -> BotInfo -> ShowS
$cshow :: BotInfo -> String
show :: BotInfo -> String
$cshowList :: [BotInfo] -> ShowS
showList :: [BotInfo] -> ShowS
Show)

instance I.ShortShow BotInfo where
  shortShow :: BotInfo -> String
shortShow BotInfo
    { short_description :: BotInfo -> Maybe Text
short_description                    = Maybe Text
short_description_
    , description :: BotInfo -> Maybe Text
description                          = Maybe Text
description_
    , photo :: BotInfo -> Maybe Photo
photo                                = Maybe Photo
photo_
    , animation :: BotInfo -> Maybe Animation
animation                            = Maybe Animation
animation_
    , menu_button :: BotInfo -> Maybe BotMenuButton
menu_button                          = Maybe BotMenuButton
menu_button_
    , commands :: BotInfo -> Maybe [BotCommand]
commands                             = Maybe [BotCommand]
commands_
    , privacy_policy_url :: BotInfo -> Maybe Text
privacy_policy_url                   = Maybe Text
privacy_policy_url_
    , default_group_administrator_rights :: BotInfo -> Maybe ChatAdministratorRights
default_group_administrator_rights   = Maybe ChatAdministratorRights
default_group_administrator_rights_
    , default_channel_administrator_rights :: BotInfo -> Maybe ChatAdministratorRights
default_channel_administrator_rights = Maybe ChatAdministratorRights
default_channel_administrator_rights_
    , has_media_previews :: BotInfo -> Maybe Bool
has_media_previews                   = Maybe Bool
has_media_previews_
    , edit_commands_link :: BotInfo -> Maybe InternalLinkType
edit_commands_link                   = Maybe InternalLinkType
edit_commands_link_
    , edit_description_link :: BotInfo -> Maybe InternalLinkType
edit_description_link                = Maybe InternalLinkType
edit_description_link_
    , edit_description_media_link :: BotInfo -> Maybe InternalLinkType
edit_description_media_link          = Maybe InternalLinkType
edit_description_media_link_
    , edit_settings_link :: BotInfo -> Maybe InternalLinkType
edit_settings_link                   = Maybe InternalLinkType
edit_settings_link_
    }
      = String
"BotInfo"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"short_description"                    String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
short_description_
        , String
"description"                          String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
description_
        , String
"photo"                                String -> Maybe Photo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Photo
photo_
        , String
"animation"                            String -> Maybe Animation -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Animation
animation_
        , String
"menu_button"                          String -> Maybe BotMenuButton -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BotMenuButton
menu_button_
        , String
"commands"                             String -> Maybe [BotCommand] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [BotCommand]
commands_
        , String
"privacy_policy_url"                   String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
privacy_policy_url_
        , String
"default_group_administrator_rights"   String -> Maybe ChatAdministratorRights -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatAdministratorRights
default_group_administrator_rights_
        , String
"default_channel_administrator_rights" String -> Maybe ChatAdministratorRights -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatAdministratorRights
default_channel_administrator_rights_
        , String
"has_media_previews"                   String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_media_previews_
        , String
"edit_commands_link"                   String -> Maybe InternalLinkType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InternalLinkType
edit_commands_link_
        , String
"edit_description_link"                String -> Maybe InternalLinkType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InternalLinkType
edit_description_link_
        , String
"edit_description_media_link"          String -> Maybe InternalLinkType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InternalLinkType
edit_description_media_link_
        , String
"edit_settings_link"                   String -> Maybe InternalLinkType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InternalLinkType
edit_settings_link_
        ]

instance AT.FromJSON BotInfo where
  parseJSON :: Value -> Parser BotInfo
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
"botInfo" -> Value -> Parser BotInfo
parseBotInfo Value
v
      String
_         -> Parser BotInfo
forall a. Monoid a => a
mempty
    
    where
      parseBotInfo :: A.Value -> AT.Parser BotInfo
      parseBotInfo :: Value -> Parser BotInfo
parseBotInfo = String -> (Object -> Parser BotInfo) -> Value -> Parser BotInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotInfo" ((Object -> Parser BotInfo) -> Value -> Parser BotInfo)
-> (Object -> Parser BotInfo) -> Value -> Parser BotInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Text
short_description_                    <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"short_description"
        Maybe Text
description_                          <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"description"
        Maybe Photo
photo_                                <- Object
o Object -> Key -> Parser (Maybe Photo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"photo"
        Maybe Animation
animation_                            <- Object
o Object -> Key -> Parser (Maybe Animation)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"animation"
        Maybe BotMenuButton
menu_button_                          <- Object
o Object -> Key -> Parser (Maybe BotMenuButton)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"menu_button"
        Maybe [BotCommand]
commands_                             <- Object
o Object -> Key -> Parser (Maybe [BotCommand])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"commands"
        Maybe Text
privacy_policy_url_                   <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"privacy_policy_url"
        Maybe ChatAdministratorRights
default_group_administrator_rights_   <- Object
o Object -> Key -> Parser (Maybe ChatAdministratorRights)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"default_group_administrator_rights"
        Maybe ChatAdministratorRights
default_channel_administrator_rights_ <- Object
o Object -> Key -> Parser (Maybe ChatAdministratorRights)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"default_channel_administrator_rights"
        Maybe Bool
has_media_previews_                   <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_media_previews"
        Maybe InternalLinkType
edit_commands_link_                   <- Object
o Object -> Key -> Parser (Maybe InternalLinkType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"edit_commands_link"
        Maybe InternalLinkType
edit_description_link_                <- Object
o Object -> Key -> Parser (Maybe InternalLinkType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"edit_description_link"
        Maybe InternalLinkType
edit_description_media_link_          <- Object
o Object -> Key -> Parser (Maybe InternalLinkType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"edit_description_media_link"
        Maybe InternalLinkType
edit_settings_link_                   <- Object
o Object -> Key -> Parser (Maybe InternalLinkType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"edit_settings_link"
        BotInfo -> Parser BotInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotInfo -> Parser BotInfo) -> BotInfo -> Parser BotInfo
forall a b. (a -> b) -> a -> b
$ BotInfo
          { short_description :: Maybe Text
short_description                    = Maybe Text
short_description_
          , description :: Maybe Text
description                          = Maybe Text
description_
          , photo :: Maybe Photo
photo                                = Maybe Photo
photo_
          , animation :: Maybe Animation
animation                            = Maybe Animation
animation_
          , menu_button :: Maybe BotMenuButton
menu_button                          = Maybe BotMenuButton
menu_button_
          , commands :: Maybe [BotCommand]
commands                             = Maybe [BotCommand]
commands_
          , privacy_policy_url :: Maybe Text
privacy_policy_url                   = Maybe Text
privacy_policy_url_
          , default_group_administrator_rights :: Maybe ChatAdministratorRights
default_group_administrator_rights   = Maybe ChatAdministratorRights
default_group_administrator_rights_
          , default_channel_administrator_rights :: Maybe ChatAdministratorRights
default_channel_administrator_rights = Maybe ChatAdministratorRights
default_channel_administrator_rights_
          , has_media_previews :: Maybe Bool
has_media_previews                   = Maybe Bool
has_media_previews_
          , edit_commands_link :: Maybe InternalLinkType
edit_commands_link                   = Maybe InternalLinkType
edit_commands_link_
          , edit_description_link :: Maybe InternalLinkType
edit_description_link                = Maybe InternalLinkType
edit_description_link_
          , edit_description_media_link :: Maybe InternalLinkType
edit_description_media_link          = Maybe InternalLinkType
edit_description_media_link_
          , edit_settings_link :: Maybe InternalLinkType
edit_settings_link                   = Maybe InternalLinkType
edit_settings_link_
          }
  parseJSON Value
_ = Parser BotInfo
forall a. Monoid a => a
mempty