module TD.Query.SetChatAccentColor
  (SetChatAccentColor(..)
  , defaultSetChatAccentColor
  ) where

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

-- | Changes accent color and background custom emoji of a channel chat. Requires can_change_info administrator right. Returns 'TD.Data.Ok.Ok'
data SetChatAccentColor
  = SetChatAccentColor
    { SetChatAccentColor -> Maybe Int
chat_id                    :: Maybe Int -- ^ Chat identifier
    , SetChatAccentColor -> Maybe Int
accent_color_id            :: Maybe Int -- ^ Identifier of the accent color to use. The chat must have at least accentColor.min_channel_chat_boost_level boost level to pass the corresponding color
    , SetChatAccentColor -> Maybe Int
background_custom_emoji_id :: Maybe Int -- ^ Identifier of a custom emoji to be shown on the reply header and link preview background; 0 if none. Use chatBoostLevelFeatures.can_set_background_custom_emoji to check whether a custom emoji can be set
    }
  deriving (SetChatAccentColor -> SetChatAccentColor -> Bool
(SetChatAccentColor -> SetChatAccentColor -> Bool)
-> (SetChatAccentColor -> SetChatAccentColor -> Bool)
-> Eq SetChatAccentColor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetChatAccentColor -> SetChatAccentColor -> Bool
== :: SetChatAccentColor -> SetChatAccentColor -> Bool
$c/= :: SetChatAccentColor -> SetChatAccentColor -> Bool
/= :: SetChatAccentColor -> SetChatAccentColor -> Bool
Eq, Int -> SetChatAccentColor -> ShowS
[SetChatAccentColor] -> ShowS
SetChatAccentColor -> String
(Int -> SetChatAccentColor -> ShowS)
-> (SetChatAccentColor -> String)
-> ([SetChatAccentColor] -> ShowS)
-> Show SetChatAccentColor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetChatAccentColor -> ShowS
showsPrec :: Int -> SetChatAccentColor -> ShowS
$cshow :: SetChatAccentColor -> String
show :: SetChatAccentColor -> String
$cshowList :: [SetChatAccentColor] -> ShowS
showList :: [SetChatAccentColor] -> ShowS
Show)

instance I.ShortShow SetChatAccentColor where
  shortShow :: SetChatAccentColor -> String
shortShow
    SetChatAccentColor
      { chat_id :: SetChatAccentColor -> Maybe Int
chat_id                    = Maybe Int
chat_id_
      , accent_color_id :: SetChatAccentColor -> Maybe Int
accent_color_id            = Maybe Int
accent_color_id_
      , background_custom_emoji_id :: SetChatAccentColor -> Maybe Int
background_custom_emoji_id = Maybe Int
background_custom_emoji_id_
      }
        = String
"SetChatAccentColor"
          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
"accent_color_id"            String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
accent_color_id_
          , String
"background_custom_emoji_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
background_custom_emoji_id_
          ]

instance AT.ToJSON SetChatAccentColor where
  toJSON :: SetChatAccentColor -> Value
toJSON
    SetChatAccentColor
      { chat_id :: SetChatAccentColor -> Maybe Int
chat_id                    = Maybe Int
chat_id_
      , accent_color_id :: SetChatAccentColor -> Maybe Int
accent_color_id            = Maybe Int
accent_color_id_
      , background_custom_emoji_id :: SetChatAccentColor -> Maybe Int
background_custom_emoji_id = Maybe Int
background_custom_emoji_id_
      }
        = [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
"setChatAccentColor"
          , 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
"accent_color_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
accent_color_id_
          , Key
"background_custom_emoji_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
background_custom_emoji_id_
          ]

defaultSetChatAccentColor :: SetChatAccentColor
defaultSetChatAccentColor :: SetChatAccentColor
defaultSetChatAccentColor =
  SetChatAccentColor
    { chat_id :: Maybe Int
chat_id                    = Maybe Int
forall a. Maybe a
Nothing
    , accent_color_id :: Maybe Int
accent_color_id            = Maybe Int
forall a. Maybe a
Nothing
    , background_custom_emoji_id :: Maybe Int
background_custom_emoji_id = Maybe Int
forall a. Maybe a
Nothing
    }