module TD.Data.ChatBoostFeatures
  (ChatBoostFeatures(..)) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.ChatBoostLevelFeatures as ChatBoostLevelFeatures

data ChatBoostFeatures
  = ChatBoostFeatures -- ^ Contains a list of features available on the first chat boost levels
    { ChatBoostFeatures -> Maybe [ChatBoostLevelFeatures]
features                                        :: Maybe [ChatBoostLevelFeatures.ChatBoostLevelFeatures] -- ^ The list of features
    , ChatBoostFeatures -> Maybe Int
min_profile_background_custom_emoji_boost_level :: Maybe Int                                             -- ^ The minimum boost level required to set custom emoji for profile background
    , ChatBoostFeatures -> Maybe Int
min_background_custom_emoji_boost_level         :: Maybe Int                                             -- ^ The minimum boost level required to set custom emoji for reply header and link preview background; for channel chats only
    , ChatBoostFeatures -> Maybe Int
min_emoji_status_boost_level                    :: Maybe Int                                             -- ^ The minimum boost level required to set emoji status
    , ChatBoostFeatures -> Maybe Int
min_chat_theme_background_boost_level           :: Maybe Int                                             -- ^ The minimum boost level required to set a chat theme background as chat background
    , ChatBoostFeatures -> Maybe Int
min_custom_background_boost_level               :: Maybe Int                                             -- ^ The minimum boost level required to set custom chat background
    , ChatBoostFeatures -> Maybe Int
min_custom_emoji_sticker_set_boost_level        :: Maybe Int                                             -- ^ The minimum boost level required to set custom emoji sticker set for the chat; for supergroup chats only
    , ChatBoostFeatures -> Maybe Int
min_speech_recognition_boost_level              :: Maybe Int                                             -- ^ The minimum boost level allowing to recognize speech in video note and voice note messages for non-Premium users; for supergroup chats only
    , ChatBoostFeatures -> Maybe Int
min_sponsored_message_disable_boost_level       :: Maybe Int                                             -- ^ The minimum boost level allowing to disable sponsored messages in the chat; for channel chats only
    }
  deriving (ChatBoostFeatures -> ChatBoostFeatures -> Bool
(ChatBoostFeatures -> ChatBoostFeatures -> Bool)
-> (ChatBoostFeatures -> ChatBoostFeatures -> Bool)
-> Eq ChatBoostFeatures
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatBoostFeatures -> ChatBoostFeatures -> Bool
== :: ChatBoostFeatures -> ChatBoostFeatures -> Bool
$c/= :: ChatBoostFeatures -> ChatBoostFeatures -> Bool
/= :: ChatBoostFeatures -> ChatBoostFeatures -> Bool
Eq, Int -> ChatBoostFeatures -> ShowS
[ChatBoostFeatures] -> ShowS
ChatBoostFeatures -> String
(Int -> ChatBoostFeatures -> ShowS)
-> (ChatBoostFeatures -> String)
-> ([ChatBoostFeatures] -> ShowS)
-> Show ChatBoostFeatures
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatBoostFeatures -> ShowS
showsPrec :: Int -> ChatBoostFeatures -> ShowS
$cshow :: ChatBoostFeatures -> String
show :: ChatBoostFeatures -> String
$cshowList :: [ChatBoostFeatures] -> ShowS
showList :: [ChatBoostFeatures] -> ShowS
Show)

instance I.ShortShow ChatBoostFeatures where
  shortShow :: ChatBoostFeatures -> String
shortShow ChatBoostFeatures
    { features :: ChatBoostFeatures -> Maybe [ChatBoostLevelFeatures]
features                                        = Maybe [ChatBoostLevelFeatures]
features_
    , min_profile_background_custom_emoji_boost_level :: ChatBoostFeatures -> Maybe Int
min_profile_background_custom_emoji_boost_level = Maybe Int
min_profile_background_custom_emoji_boost_level_
    , min_background_custom_emoji_boost_level :: ChatBoostFeatures -> Maybe Int
min_background_custom_emoji_boost_level         = Maybe Int
min_background_custom_emoji_boost_level_
    , min_emoji_status_boost_level :: ChatBoostFeatures -> Maybe Int
min_emoji_status_boost_level                    = Maybe Int
min_emoji_status_boost_level_
    , min_chat_theme_background_boost_level :: ChatBoostFeatures -> Maybe Int
min_chat_theme_background_boost_level           = Maybe Int
min_chat_theme_background_boost_level_
    , min_custom_background_boost_level :: ChatBoostFeatures -> Maybe Int
min_custom_background_boost_level               = Maybe Int
min_custom_background_boost_level_
    , min_custom_emoji_sticker_set_boost_level :: ChatBoostFeatures -> Maybe Int
min_custom_emoji_sticker_set_boost_level        = Maybe Int
min_custom_emoji_sticker_set_boost_level_
    , min_speech_recognition_boost_level :: ChatBoostFeatures -> Maybe Int
min_speech_recognition_boost_level              = Maybe Int
min_speech_recognition_boost_level_
    , min_sponsored_message_disable_boost_level :: ChatBoostFeatures -> Maybe Int
min_sponsored_message_disable_boost_level       = Maybe Int
min_sponsored_message_disable_boost_level_
    }
      = String
"ChatBoostFeatures"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"features"                                        String -> Maybe [ChatBoostLevelFeatures] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ChatBoostLevelFeatures]
features_
        , String
"min_profile_background_custom_emoji_boost_level" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_profile_background_custom_emoji_boost_level_
        , String
"min_background_custom_emoji_boost_level"         String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_background_custom_emoji_boost_level_
        , String
"min_emoji_status_boost_level"                    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_emoji_status_boost_level_
        , String
"min_chat_theme_background_boost_level"           String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_chat_theme_background_boost_level_
        , String
"min_custom_background_boost_level"               String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_custom_background_boost_level_
        , String
"min_custom_emoji_sticker_set_boost_level"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_custom_emoji_sticker_set_boost_level_
        , String
"min_speech_recognition_boost_level"              String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_speech_recognition_boost_level_
        , String
"min_sponsored_message_disable_boost_level"       String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_sponsored_message_disable_boost_level_
        ]

instance AT.FromJSON ChatBoostFeatures where
  parseJSON :: Value -> Parser ChatBoostFeatures
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
"chatBoostFeatures" -> Value -> Parser ChatBoostFeatures
parseChatBoostFeatures Value
v
      String
_                   -> Parser ChatBoostFeatures
forall a. Monoid a => a
mempty
    
    where
      parseChatBoostFeatures :: A.Value -> AT.Parser ChatBoostFeatures
      parseChatBoostFeatures :: Value -> Parser ChatBoostFeatures
parseChatBoostFeatures = String
-> (Object -> Parser ChatBoostFeatures)
-> Value
-> Parser ChatBoostFeatures
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatBoostFeatures" ((Object -> Parser ChatBoostFeatures)
 -> Value -> Parser ChatBoostFeatures)
-> (Object -> Parser ChatBoostFeatures)
-> Value
-> Parser ChatBoostFeatures
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe [ChatBoostLevelFeatures]
features_                                        <- Object
o Object -> Key -> Parser (Maybe [ChatBoostLevelFeatures])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"features"
        Maybe Int
min_profile_background_custom_emoji_boost_level_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"min_profile_background_custom_emoji_boost_level"
        Maybe Int
min_background_custom_emoji_boost_level_         <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"min_background_custom_emoji_boost_level"
        Maybe Int
min_emoji_status_boost_level_                    <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"min_emoji_status_boost_level"
        Maybe Int
min_chat_theme_background_boost_level_           <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"min_chat_theme_background_boost_level"
        Maybe Int
min_custom_background_boost_level_               <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"min_custom_background_boost_level"
        Maybe Int
min_custom_emoji_sticker_set_boost_level_        <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"min_custom_emoji_sticker_set_boost_level"
        Maybe Int
min_speech_recognition_boost_level_              <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"min_speech_recognition_boost_level"
        Maybe Int
min_sponsored_message_disable_boost_level_       <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"min_sponsored_message_disable_boost_level"
        ChatBoostFeatures -> Parser ChatBoostFeatures
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatBoostFeatures -> Parser ChatBoostFeatures)
-> ChatBoostFeatures -> Parser ChatBoostFeatures
forall a b. (a -> b) -> a -> b
$ ChatBoostFeatures
          { features :: Maybe [ChatBoostLevelFeatures]
features                                        = Maybe [ChatBoostLevelFeatures]
features_
          , min_profile_background_custom_emoji_boost_level :: Maybe Int
min_profile_background_custom_emoji_boost_level = Maybe Int
min_profile_background_custom_emoji_boost_level_
          , min_background_custom_emoji_boost_level :: Maybe Int
min_background_custom_emoji_boost_level         = Maybe Int
min_background_custom_emoji_boost_level_
          , min_emoji_status_boost_level :: Maybe Int
min_emoji_status_boost_level                    = Maybe Int
min_emoji_status_boost_level_
          , min_chat_theme_background_boost_level :: Maybe Int
min_chat_theme_background_boost_level           = Maybe Int
min_chat_theme_background_boost_level_
          , min_custom_background_boost_level :: Maybe Int
min_custom_background_boost_level               = Maybe Int
min_custom_background_boost_level_
          , min_custom_emoji_sticker_set_boost_level :: Maybe Int
min_custom_emoji_sticker_set_boost_level        = Maybe Int
min_custom_emoji_sticker_set_boost_level_
          , min_speech_recognition_boost_level :: Maybe Int
min_speech_recognition_boost_level              = Maybe Int
min_speech_recognition_boost_level_
          , min_sponsored_message_disable_boost_level :: Maybe Int
min_sponsored_message_disable_boost_level       = Maybe Int
min_sponsored_message_disable_boost_level_
          }
  parseJSON Value
_ = Parser ChatBoostFeatures
forall a. Monoid a => a
mempty