module TD.Query.SetChatBackground
  (SetChatBackground(..)
  , defaultSetChatBackground
  ) 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 the background in a specific chat. Supported only in private and secret chats with non-deleted users, and in chats with sufficient boost level and can_change_info administrator right. Returns 'TD.Data.Ok.Ok'
data SetChatBackground
  = SetChatBackground
    { SetChatBackground -> Maybe Int
chat_id            :: Maybe Int                             -- ^ Chat identifier
    , SetChatBackground -> Maybe InputBackground
background         :: Maybe InputBackground.InputBackground -- ^ The input background to use; pass null to create a new filled or chat theme background
    , SetChatBackground -> Maybe BackgroundType
_type              :: Maybe BackgroundType.BackgroundType   -- ^ Background type; pass null to use default background type for the chosen background; backgroundTypeChatTheme isn't supported for private and secret chats. Use chatBoostLevelFeatures.chat_theme_background_count and chatBoostLevelFeatures.can_set_custom_background to check whether the background type can be set in the boosted chat
    , SetChatBackground -> Maybe Int
dark_theme_dimming :: Maybe Int                             -- ^ Dimming of the background in dark themes, as a percentage; 0-100. Applied only to Wallpaper and Fill types of background
    , SetChatBackground -> Maybe Bool
only_for_self      :: Maybe Bool                            -- ^ Pass true to set background only for self; pass false to set background for all chat users. Always false for backgrounds set in boosted chats. Background can be set for both users only by Telegram Premium users and if set background isn't of the type inputBackgroundPrevious
    }
  deriving (SetChatBackground -> SetChatBackground -> Bool
(SetChatBackground -> SetChatBackground -> Bool)
-> (SetChatBackground -> SetChatBackground -> Bool)
-> Eq SetChatBackground
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetChatBackground -> SetChatBackground -> Bool
== :: SetChatBackground -> SetChatBackground -> Bool
$c/= :: SetChatBackground -> SetChatBackground -> Bool
/= :: SetChatBackground -> SetChatBackground -> Bool
Eq, Int -> SetChatBackground -> ShowS
[SetChatBackground] -> ShowS
SetChatBackground -> String
(Int -> SetChatBackground -> ShowS)
-> (SetChatBackground -> String)
-> ([SetChatBackground] -> ShowS)
-> Show SetChatBackground
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetChatBackground -> ShowS
showsPrec :: Int -> SetChatBackground -> ShowS
$cshow :: SetChatBackground -> String
show :: SetChatBackground -> String
$cshowList :: [SetChatBackground] -> ShowS
showList :: [SetChatBackground] -> ShowS
Show)

instance I.ShortShow SetChatBackground where
  shortShow :: SetChatBackground -> String
shortShow
    SetChatBackground
      { chat_id :: SetChatBackground -> Maybe Int
chat_id            = Maybe Int
chat_id_
      , background :: SetChatBackground -> Maybe InputBackground
background         = Maybe InputBackground
background_
      , _type :: SetChatBackground -> Maybe BackgroundType
_type              = Maybe BackgroundType
_type_
      , dark_theme_dimming :: SetChatBackground -> Maybe Int
dark_theme_dimming = Maybe Int
dark_theme_dimming_
      , only_for_self :: SetChatBackground -> Maybe Bool
only_for_self      = Maybe Bool
only_for_self_
      }
        = String
"SetChatBackground"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id"            String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , 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
"dark_theme_dimming" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
dark_theme_dimming_
          , String
"only_for_self"      String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_for_self_
          ]

instance AT.ToJSON SetChatBackground where
  toJSON :: SetChatBackground -> Value
toJSON
    SetChatBackground
      { chat_id :: SetChatBackground -> Maybe Int
chat_id            = Maybe Int
chat_id_
      , background :: SetChatBackground -> Maybe InputBackground
background         = Maybe InputBackground
background_
      , _type :: SetChatBackground -> Maybe BackgroundType
_type              = Maybe BackgroundType
_type_
      , dark_theme_dimming :: SetChatBackground -> Maybe Int
dark_theme_dimming = Maybe Int
dark_theme_dimming_
      , only_for_self :: SetChatBackground -> Maybe Bool
only_for_self      = Maybe Bool
only_for_self_
      }
        = [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
"setChatBackground"
          , Key
"chat_id"            Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
chat_id_
          , 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
"dark_theme_dimming" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
dark_theme_dimming_
          , Key
"only_for_self"      Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
only_for_self_
          ]

defaultSetChatBackground :: SetChatBackground
defaultSetChatBackground :: SetChatBackground
defaultSetChatBackground =
  SetChatBackground
    { chat_id :: Maybe Int
chat_id            = Maybe Int
forall a. Maybe a
Nothing
    , background :: Maybe InputBackground
background         = Maybe InputBackground
forall a. Maybe a
Nothing
    , _type :: Maybe BackgroundType
_type              = Maybe BackgroundType
forall a. Maybe a
Nothing
    , dark_theme_dimming :: Maybe Int
dark_theme_dimming = Maybe Int
forall a. Maybe a
Nothing
    , only_for_self :: Maybe Bool
only_for_self      = Maybe Bool
forall a. Maybe a
Nothing
    }