module TD.Query.SetChatProfileAccentColor
  (SetChatProfileAccentColor(..)
  , defaultSetChatProfileAccentColor
  ) 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 for profile of a supergroup or channel chat. Requires can_change_info administrator right. Returns 'TD.Data.Ok.Ok'
data SetChatProfileAccentColor
  = SetChatProfileAccentColor
    { SetChatProfileAccentColor -> Maybe Int
chat_id                            :: Maybe Int -- ^ Chat identifier
    , SetChatProfileAccentColor -> Maybe Int
profile_accent_color_id            :: Maybe Int -- ^ Identifier of the accent color to use for profile; pass -1 if none. The chat must have at least profileAccentColor.min_supergroup_chat_boost_level for supergroups or profileAccentColor.min_channel_chat_boost_level for channels boost level to pass the corresponding color
    , SetChatProfileAccentColor -> Maybe Int
profile_background_custom_emoji_id :: Maybe Int -- ^ Identifier of a custom emoji to be shown on the chat's profile photo background; 0 if none. Use chatBoostLevelFeatures.can_set_profile_background_custom_emoji to check whether a custom emoji can be set
    }
  deriving (SetChatProfileAccentColor -> SetChatProfileAccentColor -> Bool
(SetChatProfileAccentColor -> SetChatProfileAccentColor -> Bool)
-> (SetChatProfileAccentColor -> SetChatProfileAccentColor -> Bool)
-> Eq SetChatProfileAccentColor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetChatProfileAccentColor -> SetChatProfileAccentColor -> Bool
== :: SetChatProfileAccentColor -> SetChatProfileAccentColor -> Bool
$c/= :: SetChatProfileAccentColor -> SetChatProfileAccentColor -> Bool
/= :: SetChatProfileAccentColor -> SetChatProfileAccentColor -> Bool
Eq, Int -> SetChatProfileAccentColor -> ShowS
[SetChatProfileAccentColor] -> ShowS
SetChatProfileAccentColor -> String
(Int -> SetChatProfileAccentColor -> ShowS)
-> (SetChatProfileAccentColor -> String)
-> ([SetChatProfileAccentColor] -> ShowS)
-> Show SetChatProfileAccentColor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetChatProfileAccentColor -> ShowS
showsPrec :: Int -> SetChatProfileAccentColor -> ShowS
$cshow :: SetChatProfileAccentColor -> String
show :: SetChatProfileAccentColor -> String
$cshowList :: [SetChatProfileAccentColor] -> ShowS
showList :: [SetChatProfileAccentColor] -> ShowS
Show)

instance I.ShortShow SetChatProfileAccentColor where
  shortShow :: SetChatProfileAccentColor -> String
shortShow
    SetChatProfileAccentColor
      { chat_id :: SetChatProfileAccentColor -> Maybe Int
chat_id                            = Maybe Int
chat_id_
      , profile_accent_color_id :: SetChatProfileAccentColor -> Maybe Int
profile_accent_color_id            = Maybe Int
profile_accent_color_id_
      , profile_background_custom_emoji_id :: SetChatProfileAccentColor -> Maybe Int
profile_background_custom_emoji_id = Maybe Int
profile_background_custom_emoji_id_
      }
        = String
"SetChatProfileAccentColor"
          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
"profile_accent_color_id"            String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
profile_accent_color_id_
          , String
"profile_background_custom_emoji_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
profile_background_custom_emoji_id_
          ]

instance AT.ToJSON SetChatProfileAccentColor where
  toJSON :: SetChatProfileAccentColor -> Value
toJSON
    SetChatProfileAccentColor
      { chat_id :: SetChatProfileAccentColor -> Maybe Int
chat_id                            = Maybe Int
chat_id_
      , profile_accent_color_id :: SetChatProfileAccentColor -> Maybe Int
profile_accent_color_id            = Maybe Int
profile_accent_color_id_
      , profile_background_custom_emoji_id :: SetChatProfileAccentColor -> Maybe Int
profile_background_custom_emoji_id = Maybe Int
profile_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
"setChatProfileAccentColor"
          , 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
"profile_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
profile_accent_color_id_
          , Key
"profile_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
profile_background_custom_emoji_id_
          ]

defaultSetChatProfileAccentColor :: SetChatProfileAccentColor
defaultSetChatProfileAccentColor :: SetChatProfileAccentColor
defaultSetChatProfileAccentColor =
  SetChatProfileAccentColor
    { chat_id :: Maybe Int
chat_id                            = Maybe Int
forall a. Maybe a
Nothing
    , profile_accent_color_id :: Maybe Int
profile_accent_color_id            = Maybe Int
forall a. Maybe a
Nothing
    , profile_background_custom_emoji_id :: Maybe Int
profile_background_custom_emoji_id = Maybe Int
forall a. Maybe a
Nothing
    }