module TD.Query.SetDefaultBackground
  (SetDefaultBackground(..)
  , defaultSetDefaultBackground
  ) 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.InputBackground as InputBackground
import qualified TD.Data.BackgroundType as BackgroundType

-- | Sets default background for chats; adds the background to the list of installed backgrounds. Returns 'TD.Data.Background.Background'
data SetDefaultBackground
  = SetDefaultBackground
    { SetDefaultBackground -> Maybe InputBackground
background     :: Maybe InputBackground.InputBackground -- ^ The input background to use; pass null to create a new filled background
    , SetDefaultBackground -> Maybe BackgroundType
_type          :: Maybe BackgroundType.BackgroundType   -- ^ Background type; pass null to use the default type of the remote background; backgroundTypeChatTheme isn't supported
    , SetDefaultBackground -> Maybe Bool
for_dark_theme :: Maybe Bool                            -- ^ Pass true if the background is set for a dark theme
    }
  deriving (SetDefaultBackground -> SetDefaultBackground -> Bool
(SetDefaultBackground -> SetDefaultBackground -> Bool)
-> (SetDefaultBackground -> SetDefaultBackground -> Bool)
-> Eq SetDefaultBackground
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetDefaultBackground -> SetDefaultBackground -> Bool
== :: SetDefaultBackground -> SetDefaultBackground -> Bool
$c/= :: SetDefaultBackground -> SetDefaultBackground -> Bool
/= :: SetDefaultBackground -> SetDefaultBackground -> Bool
Eq, Int -> SetDefaultBackground -> ShowS
[SetDefaultBackground] -> ShowS
SetDefaultBackground -> String
(Int -> SetDefaultBackground -> ShowS)
-> (SetDefaultBackground -> String)
-> ([SetDefaultBackground] -> ShowS)
-> Show SetDefaultBackground
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetDefaultBackground -> ShowS
showsPrec :: Int -> SetDefaultBackground -> ShowS
$cshow :: SetDefaultBackground -> String
show :: SetDefaultBackground -> String
$cshowList :: [SetDefaultBackground] -> ShowS
showList :: [SetDefaultBackground] -> ShowS
Show)

instance I.ShortShow SetDefaultBackground where
  shortShow :: SetDefaultBackground -> String
shortShow
    SetDefaultBackground
      { background :: SetDefaultBackground -> Maybe InputBackground
background     = Maybe InputBackground
background_
      , _type :: SetDefaultBackground -> Maybe BackgroundType
_type          = Maybe BackgroundType
_type_
      , for_dark_theme :: SetDefaultBackground -> Maybe Bool
for_dark_theme = Maybe Bool
for_dark_theme_
      }
        = String
"SetDefaultBackground"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"background"     String -> Maybe InputBackground -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputBackground
background_
          , String
"_type"          String -> Maybe BackgroundType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BackgroundType
_type_
          , String
"for_dark_theme" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
for_dark_theme_
          ]

instance AT.ToJSON SetDefaultBackground where
  toJSON :: SetDefaultBackground -> Value
toJSON
    SetDefaultBackground
      { background :: SetDefaultBackground -> Maybe InputBackground
background     = Maybe InputBackground
background_
      , _type :: SetDefaultBackground -> Maybe BackgroundType
_type          = Maybe BackgroundType
_type_
      , for_dark_theme :: SetDefaultBackground -> Maybe Bool
for_dark_theme = Maybe Bool
for_dark_theme_
      }
        = [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
"setDefaultBackground"
          , Key
"background"     Key -> Maybe InputBackground -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputBackground
background_
          , Key
"type"           Key -> Maybe BackgroundType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe BackgroundType
_type_
          , Key
"for_dark_theme" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
for_dark_theme_
          ]

defaultSetDefaultBackground :: SetDefaultBackground
defaultSetDefaultBackground :: SetDefaultBackground
defaultSetDefaultBackground =
  SetDefaultBackground
    { background :: Maybe InputBackground
background     = Maybe InputBackground
forall a. Maybe a
Nothing
    , _type :: Maybe BackgroundType
_type          = Maybe BackgroundType
forall a. Maybe a
Nothing
    , for_dark_theme :: Maybe Bool
for_dark_theme = Maybe Bool
forall a. Maybe a
Nothing
    }