module TD.Data.BotSetting
  (BotSetting(..)) 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.BotCallbackQueryMode as BotCallbackQueryMode

-- | Describes a setting of a bot
data BotSetting
  = BotSettingIsInline -- ^ A setting for managing whether the bot supports inline queries
    { BotSetting -> Maybe Bool
is_inline :: Maybe Bool -- ^ True, if the bot supports inline queries
    }
  | BotSettingInlineQueryPlaceholder -- ^ A setting for managing the placeholder for inline queries to the bot
    { BotSetting -> Maybe Text
placeholder :: Maybe T.Text -- ^ Placeholder for inline queries (displayed in the application input field); pass an empty string to use the default placeholder
    }
  | BotSettingNeedLocation -- ^ A setting for managing whether the location of the user is expected to be sent with every inline query to the bot
    { BotSetting -> Maybe Bool
need_location :: Maybe Bool -- ^ True, if the location of the user is expected to be sent with every inline query to the bot
    }
  | BotSettingInlineFeedback -- ^ A setting for managing the share of chosen inline query results that are received by the bot in updateNewChosenInlineResult
    { BotSetting -> Maybe Int
share_denominator :: Maybe Int -- ^ Denominator of the share of chosen inline query results that are received by the bot; the bot receives 1 out of share_denominator chosen results. Must be one of 1, 10, 100, or 1000; pass 0 to stop receiving chosen inline query results
    }
  | BotSettingCanJoinGroups -- ^ A setting for managing whether the bot can be invited to basic group and supergroup chats
    { BotSetting -> Maybe Bool
can_join_groups :: Maybe Bool -- ^ True, if the bot can be invited to basic group and supergroup chats
    }
  | BotSettingCanReadAllGroupMessages -- ^ A setting for managing whether the bot can read all messages in basic group or supergroup chats and not just those addressed to the bot
    { BotSetting -> Maybe Bool
can_read_all_group_messages :: Maybe Bool -- ^ True, if the bot can read all messages in basic group or supergroup chats and not just those addressed to the bot
    }
  | BotSettingCanConnectToBusiness -- ^ A setting for managing whether the bot supports connection to user accounts for chat automation
    { BotSetting -> Maybe Bool
can_connect_to_business :: Maybe Bool -- ^ True, if the bot supports connection to user accounts for chat automation
    }
  | BotSettingCanManageBots -- ^ A setting for managing whether the bot can manage other bots
    { BotSetting -> Maybe Bool
can_manage_bots :: Maybe Bool -- ^ True, if the bot can manage other bots
    }
  | BotSettingSupportsGuestQueries -- ^ A setting for managing whether the bot can be queried by username from any non-secret chat
    { BotSetting -> Maybe Bool
supports_guest_queries :: Maybe Bool -- ^ True, if the bot can be queried by username from any non-secret chat
    }
  | BotSettingIsGuard -- ^ A setting for managing whether the bot can be set as a guard bot in supergroup chats
    { BotSetting -> Maybe Bool
is_guard :: Maybe Bool -- ^ True, if the bot can be set as a guard bot in supergroup chats
    }
  | BotSettingHasTopics -- ^ A setting for managing whether the bot has topics
    { BotSetting -> Maybe Bool
has_topics :: Maybe Bool -- ^ True, if the bot has topics
    }
  | BotSettingAllowsUsersToCreateTopics -- ^ A setting for managing whether users can create and delete topics in the chat with the bot
    { BotSetting -> Maybe Bool
allows_users_to_create_topics :: Maybe Bool -- ^ True, if users can create and delete topics in the chat with the bot
    }
  | BotSettingHasTopicSidebar -- ^ A setting for managing whether topics of the bot are shown in a sidebar
    { BotSetting -> Maybe Bool
has_topic_sidebar :: Maybe Bool -- ^ True, if the bot has topics, which are shown in a sidebar
    }
  | BotSettingCanCommunicateWithBots -- ^ A setting for managing whether the bot can communicate with other bots in groups, private chats, and through business accounts
    { BotSetting -> Maybe Bool
can_communicate_with_bots :: Maybe Bool -- ^ True, if the bot can communicate with other bots in groups, private chats, and through business accounts
    }
  | BotSettingCallbackQueryMode -- ^ A setting for managing how callback queries are received by the bot
    { BotSetting -> Maybe BotCallbackQueryMode
mode :: Maybe BotCallbackQueryMode.BotCallbackQueryMode -- ^ The new mode
    }
  deriving (BotSetting -> BotSetting -> Bool
(BotSetting -> BotSetting -> Bool)
-> (BotSetting -> BotSetting -> Bool) -> Eq BotSetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BotSetting -> BotSetting -> Bool
== :: BotSetting -> BotSetting -> Bool
$c/= :: BotSetting -> BotSetting -> Bool
/= :: BotSetting -> BotSetting -> Bool
Eq, Int -> BotSetting -> ShowS
[BotSetting] -> ShowS
BotSetting -> String
(Int -> BotSetting -> ShowS)
-> (BotSetting -> String)
-> ([BotSetting] -> ShowS)
-> Show BotSetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BotSetting -> ShowS
showsPrec :: Int -> BotSetting -> ShowS
$cshow :: BotSetting -> String
show :: BotSetting -> String
$cshowList :: [BotSetting] -> ShowS
showList :: [BotSetting] -> ShowS
Show)

instance I.ShortShow BotSetting where
  shortShow :: BotSetting -> String
shortShow BotSettingIsInline
    { is_inline :: BotSetting -> Maybe Bool
is_inline = Maybe Bool
is_inline_
    }
      = String
"BotSettingIsInline"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"is_inline" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_inline_
        ]
  shortShow BotSettingInlineQueryPlaceholder
    { placeholder :: BotSetting -> Maybe Text
placeholder = Maybe Text
placeholder_
    }
      = String
"BotSettingInlineQueryPlaceholder"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"placeholder" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
placeholder_
        ]
  shortShow BotSettingNeedLocation
    { need_location :: BotSetting -> Maybe Bool
need_location = Maybe Bool
need_location_
    }
      = String
"BotSettingNeedLocation"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"need_location" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
need_location_
        ]
  shortShow BotSettingInlineFeedback
    { share_denominator :: BotSetting -> Maybe Int
share_denominator = Maybe Int
share_denominator_
    }
      = String
"BotSettingInlineFeedback"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"share_denominator" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
share_denominator_
        ]
  shortShow BotSettingCanJoinGroups
    { can_join_groups :: BotSetting -> Maybe Bool
can_join_groups = Maybe Bool
can_join_groups_
    }
      = String
"BotSettingCanJoinGroups"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"can_join_groups" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_join_groups_
        ]
  shortShow BotSettingCanReadAllGroupMessages
    { can_read_all_group_messages :: BotSetting -> Maybe Bool
can_read_all_group_messages = Maybe Bool
can_read_all_group_messages_
    }
      = String
"BotSettingCanReadAllGroupMessages"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"can_read_all_group_messages" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_read_all_group_messages_
        ]
  shortShow BotSettingCanConnectToBusiness
    { can_connect_to_business :: BotSetting -> Maybe Bool
can_connect_to_business = Maybe Bool
can_connect_to_business_
    }
      = String
"BotSettingCanConnectToBusiness"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"can_connect_to_business" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_connect_to_business_
        ]
  shortShow BotSettingCanManageBots
    { can_manage_bots :: BotSetting -> Maybe Bool
can_manage_bots = Maybe Bool
can_manage_bots_
    }
      = String
"BotSettingCanManageBots"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"can_manage_bots" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_manage_bots_
        ]
  shortShow BotSettingSupportsGuestQueries
    { supports_guest_queries :: BotSetting -> Maybe Bool
supports_guest_queries = Maybe Bool
supports_guest_queries_
    }
      = String
"BotSettingSupportsGuestQueries"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"supports_guest_queries" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
supports_guest_queries_
        ]
  shortShow BotSettingIsGuard
    { is_guard :: BotSetting -> Maybe Bool
is_guard = Maybe Bool
is_guard_
    }
      = String
"BotSettingIsGuard"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"is_guard" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_guard_
        ]
  shortShow BotSettingHasTopics
    { has_topics :: BotSetting -> Maybe Bool
has_topics = Maybe Bool
has_topics_
    }
      = String
"BotSettingHasTopics"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"has_topics" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_topics_
        ]
  shortShow BotSettingAllowsUsersToCreateTopics
    { allows_users_to_create_topics :: BotSetting -> Maybe Bool
allows_users_to_create_topics = Maybe Bool
allows_users_to_create_topics_
    }
      = String
"BotSettingAllowsUsersToCreateTopics"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"allows_users_to_create_topics" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
allows_users_to_create_topics_
        ]
  shortShow BotSettingHasTopicSidebar
    { has_topic_sidebar :: BotSetting -> Maybe Bool
has_topic_sidebar = Maybe Bool
has_topic_sidebar_
    }
      = String
"BotSettingHasTopicSidebar"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"has_topic_sidebar" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_topic_sidebar_
        ]
  shortShow BotSettingCanCommunicateWithBots
    { can_communicate_with_bots :: BotSetting -> Maybe Bool
can_communicate_with_bots = Maybe Bool
can_communicate_with_bots_
    }
      = String
"BotSettingCanCommunicateWithBots"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"can_communicate_with_bots" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_communicate_with_bots_
        ]
  shortShow BotSettingCallbackQueryMode
    { mode :: BotSetting -> Maybe BotCallbackQueryMode
mode = Maybe BotCallbackQueryMode
mode_
    }
      = String
"BotSettingCallbackQueryMode"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"mode" String -> Maybe BotCallbackQueryMode -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BotCallbackQueryMode
mode_
        ]

instance AT.FromJSON BotSetting where
  parseJSON :: Value -> Parser BotSetting
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
"botSettingIsInline"                  -> Value -> Parser BotSetting
parseBotSettingIsInline Value
v
      String
"botSettingInlineQueryPlaceholder"    -> Value -> Parser BotSetting
parseBotSettingInlineQueryPlaceholder Value
v
      String
"botSettingNeedLocation"              -> Value -> Parser BotSetting
parseBotSettingNeedLocation Value
v
      String
"botSettingInlineFeedback"            -> Value -> Parser BotSetting
parseBotSettingInlineFeedback Value
v
      String
"botSettingCanJoinGroups"             -> Value -> Parser BotSetting
parseBotSettingCanJoinGroups Value
v
      String
"botSettingCanReadAllGroupMessages"   -> Value -> Parser BotSetting
parseBotSettingCanReadAllGroupMessages Value
v
      String
"botSettingCanConnectToBusiness"      -> Value -> Parser BotSetting
parseBotSettingCanConnectToBusiness Value
v
      String
"botSettingCanManageBots"             -> Value -> Parser BotSetting
parseBotSettingCanManageBots Value
v
      String
"botSettingSupportsGuestQueries"      -> Value -> Parser BotSetting
parseBotSettingSupportsGuestQueries Value
v
      String
"botSettingIsGuard"                   -> Value -> Parser BotSetting
parseBotSettingIsGuard Value
v
      String
"botSettingHasTopics"                 -> Value -> Parser BotSetting
parseBotSettingHasTopics Value
v
      String
"botSettingAllowsUsersToCreateTopics" -> Value -> Parser BotSetting
parseBotSettingAllowsUsersToCreateTopics Value
v
      String
"botSettingHasTopicSidebar"           -> Value -> Parser BotSetting
parseBotSettingHasTopicSidebar Value
v
      String
"botSettingCanCommunicateWithBots"    -> Value -> Parser BotSetting
parseBotSettingCanCommunicateWithBots Value
v
      String
"botSettingCallbackQueryMode"         -> Value -> Parser BotSetting
parseBotSettingCallbackQueryMode Value
v
      String
_                                     -> Parser BotSetting
forall a. Monoid a => a
mempty
    
    where
      parseBotSettingIsInline :: A.Value -> AT.Parser BotSetting
      parseBotSettingIsInline :: Value -> Parser BotSetting
parseBotSettingIsInline = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingIsInline" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
is_inline_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_inline"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingIsInline
          { is_inline :: Maybe Bool
is_inline = Maybe Bool
is_inline_
          }
      parseBotSettingInlineQueryPlaceholder :: A.Value -> AT.Parser BotSetting
      parseBotSettingInlineQueryPlaceholder :: Value -> Parser BotSetting
parseBotSettingInlineQueryPlaceholder = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingInlineQueryPlaceholder" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Text
placeholder_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"placeholder"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingInlineQueryPlaceholder
          { placeholder :: Maybe Text
placeholder = Maybe Text
placeholder_
          }
      parseBotSettingNeedLocation :: A.Value -> AT.Parser BotSetting
      parseBotSettingNeedLocation :: Value -> Parser BotSetting
parseBotSettingNeedLocation = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingNeedLocation" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
need_location_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"need_location"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingNeedLocation
          { need_location :: Maybe Bool
need_location = Maybe Bool
need_location_
          }
      parseBotSettingInlineFeedback :: A.Value -> AT.Parser BotSetting
      parseBotSettingInlineFeedback :: Value -> Parser BotSetting
parseBotSettingInlineFeedback = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingInlineFeedback" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
share_denominator_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"share_denominator"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingInlineFeedback
          { share_denominator :: Maybe Int
share_denominator = Maybe Int
share_denominator_
          }
      parseBotSettingCanJoinGroups :: A.Value -> AT.Parser BotSetting
      parseBotSettingCanJoinGroups :: Value -> Parser BotSetting
parseBotSettingCanJoinGroups = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingCanJoinGroups" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
can_join_groups_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_join_groups"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingCanJoinGroups
          { can_join_groups :: Maybe Bool
can_join_groups = Maybe Bool
can_join_groups_
          }
      parseBotSettingCanReadAllGroupMessages :: A.Value -> AT.Parser BotSetting
      parseBotSettingCanReadAllGroupMessages :: Value -> Parser BotSetting
parseBotSettingCanReadAllGroupMessages = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingCanReadAllGroupMessages" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
can_read_all_group_messages_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_read_all_group_messages"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingCanReadAllGroupMessages
          { can_read_all_group_messages :: Maybe Bool
can_read_all_group_messages = Maybe Bool
can_read_all_group_messages_
          }
      parseBotSettingCanConnectToBusiness :: A.Value -> AT.Parser BotSetting
      parseBotSettingCanConnectToBusiness :: Value -> Parser BotSetting
parseBotSettingCanConnectToBusiness = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingCanConnectToBusiness" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
can_connect_to_business_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_connect_to_business"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingCanConnectToBusiness
          { can_connect_to_business :: Maybe Bool
can_connect_to_business = Maybe Bool
can_connect_to_business_
          }
      parseBotSettingCanManageBots :: A.Value -> AT.Parser BotSetting
      parseBotSettingCanManageBots :: Value -> Parser BotSetting
parseBotSettingCanManageBots = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingCanManageBots" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
can_manage_bots_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_manage_bots"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingCanManageBots
          { can_manage_bots :: Maybe Bool
can_manage_bots = Maybe Bool
can_manage_bots_
          }
      parseBotSettingSupportsGuestQueries :: A.Value -> AT.Parser BotSetting
      parseBotSettingSupportsGuestQueries :: Value -> Parser BotSetting
parseBotSettingSupportsGuestQueries = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingSupportsGuestQueries" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
supports_guest_queries_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"supports_guest_queries"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingSupportsGuestQueries
          { supports_guest_queries :: Maybe Bool
supports_guest_queries = Maybe Bool
supports_guest_queries_
          }
      parseBotSettingIsGuard :: A.Value -> AT.Parser BotSetting
      parseBotSettingIsGuard :: Value -> Parser BotSetting
parseBotSettingIsGuard = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingIsGuard" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
is_guard_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"is_guard"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingIsGuard
          { is_guard :: Maybe Bool
is_guard = Maybe Bool
is_guard_
          }
      parseBotSettingHasTopics :: A.Value -> AT.Parser BotSetting
      parseBotSettingHasTopics :: Value -> Parser BotSetting
parseBotSettingHasTopics = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingHasTopics" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
has_topics_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_topics"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingHasTopics
          { has_topics :: Maybe Bool
has_topics = Maybe Bool
has_topics_
          }
      parseBotSettingAllowsUsersToCreateTopics :: A.Value -> AT.Parser BotSetting
      parseBotSettingAllowsUsersToCreateTopics :: Value -> Parser BotSetting
parseBotSettingAllowsUsersToCreateTopics = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingAllowsUsersToCreateTopics" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
allows_users_to_create_topics_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"allows_users_to_create_topics"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingAllowsUsersToCreateTopics
          { allows_users_to_create_topics :: Maybe Bool
allows_users_to_create_topics = Maybe Bool
allows_users_to_create_topics_
          }
      parseBotSettingHasTopicSidebar :: A.Value -> AT.Parser BotSetting
      parseBotSettingHasTopicSidebar :: Value -> Parser BotSetting
parseBotSettingHasTopicSidebar = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingHasTopicSidebar" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
has_topic_sidebar_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_topic_sidebar"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingHasTopicSidebar
          { has_topic_sidebar :: Maybe Bool
has_topic_sidebar = Maybe Bool
has_topic_sidebar_
          }
      parseBotSettingCanCommunicateWithBots :: A.Value -> AT.Parser BotSetting
      parseBotSettingCanCommunicateWithBots :: Value -> Parser BotSetting
parseBotSettingCanCommunicateWithBots = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingCanCommunicateWithBots" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
can_communicate_with_bots_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"can_communicate_with_bots"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingCanCommunicateWithBots
          { can_communicate_with_bots :: Maybe Bool
can_communicate_with_bots = Maybe Bool
can_communicate_with_bots_
          }
      parseBotSettingCallbackQueryMode :: A.Value -> AT.Parser BotSetting
      parseBotSettingCallbackQueryMode :: Value -> Parser BotSetting
parseBotSettingCallbackQueryMode = String
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BotSettingCallbackQueryMode" ((Object -> Parser BotSetting) -> Value -> Parser BotSetting)
-> (Object -> Parser BotSetting) -> Value -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe BotCallbackQueryMode
mode_ <- Object
o Object -> Key -> Parser (Maybe BotCallbackQueryMode)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"mode"
        BotSetting -> Parser BotSetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BotSetting -> Parser BotSetting)
-> BotSetting -> Parser BotSetting
forall a b. (a -> b) -> a -> b
$ BotSettingCallbackQueryMode
          { mode :: Maybe BotCallbackQueryMode
mode = Maybe BotCallbackQueryMode
mode_
          }
  parseJSON Value
_ = Parser BotSetting
forall a. Monoid a => a
mempty

instance AT.ToJSON BotSetting where
  toJSON :: BotSetting -> Value
toJSON BotSettingIsInline
    { is_inline :: BotSetting -> Maybe Bool
is_inline = Maybe Bool
is_inline_
    }
      = [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
"botSettingIsInline"
        , Key
"is_inline" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_inline_
        ]
  toJSON BotSettingInlineQueryPlaceholder
    { placeholder :: BotSetting -> Maybe Text
placeholder = Maybe Text
placeholder_
    }
      = [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
"botSettingInlineQueryPlaceholder"
        , Key
"placeholder" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
placeholder_
        ]
  toJSON BotSettingNeedLocation
    { need_location :: BotSetting -> Maybe Bool
need_location = Maybe Bool
need_location_
    }
      = [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
"botSettingNeedLocation"
        , Key
"need_location" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
need_location_
        ]
  toJSON BotSettingInlineFeedback
    { share_denominator :: BotSetting -> Maybe Int
share_denominator = Maybe Int
share_denominator_
    }
      = [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
"botSettingInlineFeedback"
        , Key
"share_denominator" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
share_denominator_
        ]
  toJSON BotSettingCanJoinGroups
    { can_join_groups :: BotSetting -> Maybe Bool
can_join_groups = Maybe Bool
can_join_groups_
    }
      = [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
"botSettingCanJoinGroups"
        , Key
"can_join_groups" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_join_groups_
        ]
  toJSON BotSettingCanReadAllGroupMessages
    { can_read_all_group_messages :: BotSetting -> Maybe Bool
can_read_all_group_messages = Maybe Bool
can_read_all_group_messages_
    }
      = [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
"botSettingCanReadAllGroupMessages"
        , Key
"can_read_all_group_messages" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_read_all_group_messages_
        ]
  toJSON BotSettingCanConnectToBusiness
    { can_connect_to_business :: BotSetting -> Maybe Bool
can_connect_to_business = Maybe Bool
can_connect_to_business_
    }
      = [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
"botSettingCanConnectToBusiness"
        , Key
"can_connect_to_business" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_connect_to_business_
        ]
  toJSON BotSettingCanManageBots
    { can_manage_bots :: BotSetting -> Maybe Bool
can_manage_bots = Maybe Bool
can_manage_bots_
    }
      = [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
"botSettingCanManageBots"
        , Key
"can_manage_bots" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_manage_bots_
        ]
  toJSON BotSettingSupportsGuestQueries
    { supports_guest_queries :: BotSetting -> Maybe Bool
supports_guest_queries = Maybe Bool
supports_guest_queries_
    }
      = [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
"botSettingSupportsGuestQueries"
        , Key
"supports_guest_queries" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
supports_guest_queries_
        ]
  toJSON BotSettingIsGuard
    { is_guard :: BotSetting -> Maybe Bool
is_guard = Maybe Bool
is_guard_
    }
      = [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
"botSettingIsGuard"
        , Key
"is_guard" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_guard_
        ]
  toJSON BotSettingHasTopics
    { has_topics :: BotSetting -> Maybe Bool
has_topics = Maybe Bool
has_topics_
    }
      = [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
"botSettingHasTopics"
        , Key
"has_topics" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
has_topics_
        ]
  toJSON BotSettingAllowsUsersToCreateTopics
    { allows_users_to_create_topics :: BotSetting -> Maybe Bool
allows_users_to_create_topics = Maybe Bool
allows_users_to_create_topics_
    }
      = [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
"botSettingAllowsUsersToCreateTopics"
        , Key
"allows_users_to_create_topics" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
allows_users_to_create_topics_
        ]
  toJSON BotSettingHasTopicSidebar
    { has_topic_sidebar :: BotSetting -> Maybe Bool
has_topic_sidebar = Maybe Bool
has_topic_sidebar_
    }
      = [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
"botSettingHasTopicSidebar"
        , Key
"has_topic_sidebar" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
has_topic_sidebar_
        ]
  toJSON BotSettingCanCommunicateWithBots
    { can_communicate_with_bots :: BotSetting -> Maybe Bool
can_communicate_with_bots = Maybe Bool
can_communicate_with_bots_
    }
      = [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
"botSettingCanCommunicateWithBots"
        , Key
"can_communicate_with_bots" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_communicate_with_bots_
        ]
  toJSON BotSettingCallbackQueryMode
    { mode :: BotSetting -> Maybe BotCallbackQueryMode
mode = Maybe BotCallbackQueryMode
mode_
    }
      = [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
"botSettingCallbackQueryMode"
        , Key
"mode"  Key -> Maybe BotCallbackQueryMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe BotCallbackQueryMode
mode_
        ]