module TD.Data.ChatBoostStatus
  (ChatBoostStatus(..)) 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.PrepaidGiveaway as PrepaidGiveaway

data ChatBoostStatus
  = ChatBoostStatus -- ^ Describes current boost status of a chat
    { ChatBoostStatus -> Maybe Text
boost_url                 :: Maybe T.Text                            -- ^ An HTTP URL, which can be used to boost the chat
    , ChatBoostStatus -> Maybe [Int]
applied_slot_ids          :: Maybe [Int]                             -- ^ Identifiers of boost slots of the current user applied to the chat
    , ChatBoostStatus -> Maybe Int
level                     :: Maybe Int                               -- ^ Current boost level of the chat
    , ChatBoostStatus -> Maybe Int
gift_code_boost_count     :: Maybe Int                               -- ^ The number of boosts received by the chat from created Telegram Premium gift codes and giveaways; always 0 if the current user isn't an administrator in the chat
    , ChatBoostStatus -> Maybe Int
boost_count               :: Maybe Int                               -- ^ The number of boosts received by the chat
    , ChatBoostStatus -> Maybe Int
current_level_boost_count :: Maybe Int                               -- ^ The number of boosts added to reach the current level
    , ChatBoostStatus -> Maybe Int
next_level_boost_count    :: Maybe Int                               -- ^ The number of boosts needed to reach the next level; 0 if the next level isn't available
    , ChatBoostStatus -> Maybe Int
premium_member_count      :: Maybe Int                               -- ^ Approximate number of Telegram Premium subscribers joined the chat; always 0 if the current user isn't an administrator in the chat
    , ChatBoostStatus -> Maybe Double
premium_member_percentage :: Maybe Double                            -- ^ A percentage of Telegram Premium subscribers joined the chat; always 0 if the current user isn't an administrator in the chat
    , ChatBoostStatus -> Maybe [PrepaidGiveaway]
prepaid_giveaways         :: Maybe [PrepaidGiveaway.PrepaidGiveaway] -- ^ The list of prepaid giveaways available for the chat; only for chat administrators
    }
  deriving (ChatBoostStatus -> ChatBoostStatus -> Bool
(ChatBoostStatus -> ChatBoostStatus -> Bool)
-> (ChatBoostStatus -> ChatBoostStatus -> Bool)
-> Eq ChatBoostStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatBoostStatus -> ChatBoostStatus -> Bool
== :: ChatBoostStatus -> ChatBoostStatus -> Bool
$c/= :: ChatBoostStatus -> ChatBoostStatus -> Bool
/= :: ChatBoostStatus -> ChatBoostStatus -> Bool
Eq, Int -> ChatBoostStatus -> ShowS
[ChatBoostStatus] -> ShowS
ChatBoostStatus -> String
(Int -> ChatBoostStatus -> ShowS)
-> (ChatBoostStatus -> String)
-> ([ChatBoostStatus] -> ShowS)
-> Show ChatBoostStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatBoostStatus -> ShowS
showsPrec :: Int -> ChatBoostStatus -> ShowS
$cshow :: ChatBoostStatus -> String
show :: ChatBoostStatus -> String
$cshowList :: [ChatBoostStatus] -> ShowS
showList :: [ChatBoostStatus] -> ShowS
Show)

instance I.ShortShow ChatBoostStatus where
  shortShow :: ChatBoostStatus -> String
shortShow ChatBoostStatus
    { boost_url :: ChatBoostStatus -> Maybe Text
boost_url                 = Maybe Text
boost_url_
    , applied_slot_ids :: ChatBoostStatus -> Maybe [Int]
applied_slot_ids          = Maybe [Int]
applied_slot_ids_
    , level :: ChatBoostStatus -> Maybe Int
level                     = Maybe Int
level_
    , gift_code_boost_count :: ChatBoostStatus -> Maybe Int
gift_code_boost_count     = Maybe Int
gift_code_boost_count_
    , boost_count :: ChatBoostStatus -> Maybe Int
boost_count               = Maybe Int
boost_count_
    , current_level_boost_count :: ChatBoostStatus -> Maybe Int
current_level_boost_count = Maybe Int
current_level_boost_count_
    , next_level_boost_count :: ChatBoostStatus -> Maybe Int
next_level_boost_count    = Maybe Int
next_level_boost_count_
    , premium_member_count :: ChatBoostStatus -> Maybe Int
premium_member_count      = Maybe Int
premium_member_count_
    , premium_member_percentage :: ChatBoostStatus -> Maybe Double
premium_member_percentage = Maybe Double
premium_member_percentage_
    , prepaid_giveaways :: ChatBoostStatus -> Maybe [PrepaidGiveaway]
prepaid_giveaways         = Maybe [PrepaidGiveaway]
prepaid_giveaways_
    }
      = String
"ChatBoostStatus"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"boost_url"                 String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
boost_url_
        , String
"applied_slot_ids"          String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
applied_slot_ids_
        , String
"level"                     String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
level_
        , String
"gift_code_boost_count"     String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
gift_code_boost_count_
        , String
"boost_count"               String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
boost_count_
        , String
"current_level_boost_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
current_level_boost_count_
        , String
"next_level_boost_count"    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
next_level_boost_count_
        , String
"premium_member_count"      String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
premium_member_count_
        , String
"premium_member_percentage" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
premium_member_percentage_
        , String
"prepaid_giveaways"         String -> Maybe [PrepaidGiveaway] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [PrepaidGiveaway]
prepaid_giveaways_
        ]

instance AT.FromJSON ChatBoostStatus where
  parseJSON :: Value -> Parser ChatBoostStatus
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
"chatBoostStatus" -> Value -> Parser ChatBoostStatus
parseChatBoostStatus Value
v
      String
_                 -> Parser ChatBoostStatus
forall a. Monoid a => a
mempty
    
    where
      parseChatBoostStatus :: A.Value -> AT.Parser ChatBoostStatus
      parseChatBoostStatus :: Value -> Parser ChatBoostStatus
parseChatBoostStatus = String
-> (Object -> Parser ChatBoostStatus)
-> Value
-> Parser ChatBoostStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatBoostStatus" ((Object -> Parser ChatBoostStatus)
 -> Value -> Parser ChatBoostStatus)
-> (Object -> Parser ChatBoostStatus)
-> Value
-> Parser ChatBoostStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Text
boost_url_                 <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"boost_url"
        Maybe [Int]
applied_slot_ids_          <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"applied_slot_ids"
        Maybe Int
level_                     <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"level"
        Maybe Int
gift_code_boost_count_     <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"gift_code_boost_count"
        Maybe Int
boost_count_               <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"boost_count"
        Maybe Int
current_level_boost_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"current_level_boost_count"
        Maybe Int
next_level_boost_count_    <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"next_level_boost_count"
        Maybe Int
premium_member_count_      <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"premium_member_count"
        Maybe Double
premium_member_percentage_ <- Object
o Object -> Key -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"premium_member_percentage"
        Maybe [PrepaidGiveaway]
prepaid_giveaways_         <- Object
o Object -> Key -> Parser (Maybe [PrepaidGiveaway])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"prepaid_giveaways"
        ChatBoostStatus -> Parser ChatBoostStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatBoostStatus -> Parser ChatBoostStatus)
-> ChatBoostStatus -> Parser ChatBoostStatus
forall a b. (a -> b) -> a -> b
$ ChatBoostStatus
          { boost_url :: Maybe Text
boost_url                 = Maybe Text
boost_url_
          , applied_slot_ids :: Maybe [Int]
applied_slot_ids          = Maybe [Int]
applied_slot_ids_
          , level :: Maybe Int
level                     = Maybe Int
level_
          , gift_code_boost_count :: Maybe Int
gift_code_boost_count     = Maybe Int
gift_code_boost_count_
          , boost_count :: Maybe Int
boost_count               = Maybe Int
boost_count_
          , current_level_boost_count :: Maybe Int
current_level_boost_count = Maybe Int
current_level_boost_count_
          , next_level_boost_count :: Maybe Int
next_level_boost_count    = Maybe Int
next_level_boost_count_
          , premium_member_count :: Maybe Int
premium_member_count      = Maybe Int
premium_member_count_
          , premium_member_percentage :: Maybe Double
premium_member_percentage = Maybe Double
premium_member_percentage_
          , prepaid_giveaways :: Maybe [PrepaidGiveaway]
prepaid_giveaways         = Maybe [PrepaidGiveaway]
prepaid_giveaways_
          }
  parseJSON Value
_ = Parser ChatBoostStatus
forall a. Monoid a => a
mempty