module TD.Data.GroupCallMessageLevel
  (GroupCallMessageLevel(..)) where

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

data GroupCallMessageLevel
  = GroupCallMessageLevel -- ^ Represents a level of features for a message sent in a live story group call
    { GroupCallMessageLevel -> Maybe Int
min_star_count         :: Maybe Int -- ^ The minimum number of Telegram Stars required to get features of the level
    , GroupCallMessageLevel -> Maybe Int
pin_duration           :: Maybe Int -- ^ The amount of time the message of this level will be pinned, in seconds
    , GroupCallMessageLevel -> Maybe Int
max_text_length        :: Maybe Int -- ^ The maximum allowed length of the message text
    , GroupCallMessageLevel -> Maybe Int
max_custom_emoji_count :: Maybe Int -- ^ The maximum allowed number of custom emoji in the message text
    , GroupCallMessageLevel -> Maybe Int
first_color            :: Maybe Int -- ^ The first color used to show the message text in the RGB format
    , GroupCallMessageLevel -> Maybe Int
second_color           :: Maybe Int -- ^ The second color used to show the message text in the RGB format
    , GroupCallMessageLevel -> Maybe Int
background_color       :: Maybe Int -- ^ Background color for the message the RGB format
    }
  deriving (GroupCallMessageLevel -> GroupCallMessageLevel -> Bool
(GroupCallMessageLevel -> GroupCallMessageLevel -> Bool)
-> (GroupCallMessageLevel -> GroupCallMessageLevel -> Bool)
-> Eq GroupCallMessageLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GroupCallMessageLevel -> GroupCallMessageLevel -> Bool
== :: GroupCallMessageLevel -> GroupCallMessageLevel -> Bool
$c/= :: GroupCallMessageLevel -> GroupCallMessageLevel -> Bool
/= :: GroupCallMessageLevel -> GroupCallMessageLevel -> Bool
Eq, Int -> GroupCallMessageLevel -> ShowS
[GroupCallMessageLevel] -> ShowS
GroupCallMessageLevel -> String
(Int -> GroupCallMessageLevel -> ShowS)
-> (GroupCallMessageLevel -> String)
-> ([GroupCallMessageLevel] -> ShowS)
-> Show GroupCallMessageLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GroupCallMessageLevel -> ShowS
showsPrec :: Int -> GroupCallMessageLevel -> ShowS
$cshow :: GroupCallMessageLevel -> String
show :: GroupCallMessageLevel -> String
$cshowList :: [GroupCallMessageLevel] -> ShowS
showList :: [GroupCallMessageLevel] -> ShowS
Show)

instance I.ShortShow GroupCallMessageLevel where
  shortShow :: GroupCallMessageLevel -> String
shortShow GroupCallMessageLevel
    { min_star_count :: GroupCallMessageLevel -> Maybe Int
min_star_count         = Maybe Int
min_star_count_
    , pin_duration :: GroupCallMessageLevel -> Maybe Int
pin_duration           = Maybe Int
pin_duration_
    , max_text_length :: GroupCallMessageLevel -> Maybe Int
max_text_length        = Maybe Int
max_text_length_
    , max_custom_emoji_count :: GroupCallMessageLevel -> Maybe Int
max_custom_emoji_count = Maybe Int
max_custom_emoji_count_
    , first_color :: GroupCallMessageLevel -> Maybe Int
first_color            = Maybe Int
first_color_
    , second_color :: GroupCallMessageLevel -> Maybe Int
second_color           = Maybe Int
second_color_
    , background_color :: GroupCallMessageLevel -> Maybe Int
background_color       = Maybe Int
background_color_
    }
      = String
"GroupCallMessageLevel"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"min_star_count"         String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
min_star_count_
        , String
"pin_duration"           String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
pin_duration_
        , String
"max_text_length"        String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
max_text_length_
        , String
"max_custom_emoji_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
max_custom_emoji_count_
        , String
"first_color"            String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
first_color_
        , String
"second_color"           String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
second_color_
        , String
"background_color"       String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
background_color_
        ]

instance AT.FromJSON GroupCallMessageLevel where
  parseJSON :: Value -> Parser GroupCallMessageLevel
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
"groupCallMessageLevel" -> Value -> Parser GroupCallMessageLevel
parseGroupCallMessageLevel Value
v
      String
_                       -> Parser GroupCallMessageLevel
forall a. Monoid a => a
mempty
    
    where
      parseGroupCallMessageLevel :: A.Value -> AT.Parser GroupCallMessageLevel
      parseGroupCallMessageLevel :: Value -> Parser GroupCallMessageLevel
parseGroupCallMessageLevel = String
-> (Object -> Parser GroupCallMessageLevel)
-> Value
-> Parser GroupCallMessageLevel
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GroupCallMessageLevel" ((Object -> Parser GroupCallMessageLevel)
 -> Value -> Parser GroupCallMessageLevel)
-> (Object -> Parser GroupCallMessageLevel)
-> Value
-> Parser GroupCallMessageLevel
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
min_star_count_         <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"min_star_count"
        Maybe Int
pin_duration_           <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"pin_duration"
        Maybe Int
max_text_length_        <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"max_text_length"
        Maybe Int
max_custom_emoji_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"max_custom_emoji_count"
        Maybe Int
first_color_            <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"first_color"
        Maybe Int
second_color_           <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"second_color"
        Maybe Int
background_color_       <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"background_color"
        GroupCallMessageLevel -> Parser GroupCallMessageLevel
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GroupCallMessageLevel -> Parser GroupCallMessageLevel)
-> GroupCallMessageLevel -> Parser GroupCallMessageLevel
forall a b. (a -> b) -> a -> b
$ GroupCallMessageLevel
          { min_star_count :: Maybe Int
min_star_count         = Maybe Int
min_star_count_
          , pin_duration :: Maybe Int
pin_duration           = Maybe Int
pin_duration_
          , max_text_length :: Maybe Int
max_text_length        = Maybe Int
max_text_length_
          , max_custom_emoji_count :: Maybe Int
max_custom_emoji_count = Maybe Int
max_custom_emoji_count_
          , first_color :: Maybe Int
first_color            = Maybe Int
first_color_
          , second_color :: Maybe Int
second_color           = Maybe Int
second_color_
          , background_color :: Maybe Int
background_color       = Maybe Int
background_color_
          }
  parseJSON Value
_ = Parser GroupCallMessageLevel
forall a. Monoid a => a
mempty