module TD.Data.AttachmentMenuBotColor
  (AttachmentMenuBotColor(..)) where

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

data AttachmentMenuBotColor
  = AttachmentMenuBotColor -- ^ Describes a color to highlight a bot added to attachment menu
    { AttachmentMenuBotColor -> Maybe Int
light_color :: Maybe Int -- ^ Color in the RGB format for light themes
    , AttachmentMenuBotColor -> Maybe Int
dark_color  :: Maybe Int -- ^ Color in the RGB format for dark themes
    }
  deriving (AttachmentMenuBotColor -> AttachmentMenuBotColor -> Bool
(AttachmentMenuBotColor -> AttachmentMenuBotColor -> Bool)
-> (AttachmentMenuBotColor -> AttachmentMenuBotColor -> Bool)
-> Eq AttachmentMenuBotColor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AttachmentMenuBotColor -> AttachmentMenuBotColor -> Bool
== :: AttachmentMenuBotColor -> AttachmentMenuBotColor -> Bool
$c/= :: AttachmentMenuBotColor -> AttachmentMenuBotColor -> Bool
/= :: AttachmentMenuBotColor -> AttachmentMenuBotColor -> Bool
Eq, Int -> AttachmentMenuBotColor -> ShowS
[AttachmentMenuBotColor] -> ShowS
AttachmentMenuBotColor -> String
(Int -> AttachmentMenuBotColor -> ShowS)
-> (AttachmentMenuBotColor -> String)
-> ([AttachmentMenuBotColor] -> ShowS)
-> Show AttachmentMenuBotColor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AttachmentMenuBotColor -> ShowS
showsPrec :: Int -> AttachmentMenuBotColor -> ShowS
$cshow :: AttachmentMenuBotColor -> String
show :: AttachmentMenuBotColor -> String
$cshowList :: [AttachmentMenuBotColor] -> ShowS
showList :: [AttachmentMenuBotColor] -> ShowS
Show)

instance I.ShortShow AttachmentMenuBotColor where
  shortShow :: AttachmentMenuBotColor -> String
shortShow AttachmentMenuBotColor
    { light_color :: AttachmentMenuBotColor -> Maybe Int
light_color = Maybe Int
light_color_
    , dark_color :: AttachmentMenuBotColor -> Maybe Int
dark_color  = Maybe Int
dark_color_
    }
      = String
"AttachmentMenuBotColor"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"light_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
light_color_
        , String
"dark_color"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
dark_color_
        ]

instance AT.FromJSON AttachmentMenuBotColor where
  parseJSON :: Value -> Parser AttachmentMenuBotColor
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
"attachmentMenuBotColor" -> Value -> Parser AttachmentMenuBotColor
parseAttachmentMenuBotColor Value
v
      String
_                        -> Parser AttachmentMenuBotColor
forall a. Monoid a => a
mempty
    
    where
      parseAttachmentMenuBotColor :: A.Value -> AT.Parser AttachmentMenuBotColor
      parseAttachmentMenuBotColor :: Value -> Parser AttachmentMenuBotColor
parseAttachmentMenuBotColor = String
-> (Object -> Parser AttachmentMenuBotColor)
-> Value
-> Parser AttachmentMenuBotColor
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AttachmentMenuBotColor" ((Object -> Parser AttachmentMenuBotColor)
 -> Value -> Parser AttachmentMenuBotColor)
-> (Object -> Parser AttachmentMenuBotColor)
-> Value
-> Parser AttachmentMenuBotColor
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Int
light_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"light_color"
        Maybe Int
dark_color_  <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"dark_color"
        AttachmentMenuBotColor -> Parser AttachmentMenuBotColor
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AttachmentMenuBotColor -> Parser AttachmentMenuBotColor)
-> AttachmentMenuBotColor -> Parser AttachmentMenuBotColor
forall a b. (a -> b) -> a -> b
$ AttachmentMenuBotColor
          { light_color :: Maybe Int
light_color = Maybe Int
light_color_
          , dark_color :: Maybe Int
dark_color  = Maybe Int
dark_color_
          }
  parseJSON Value
_ = Parser AttachmentMenuBotColor
forall a. Monoid a => a
mempty