module TD.Query.ToggleChatGiftNotifications
  (ToggleChatGiftNotifications(..)
  , defaultToggleChatGiftNotifications
  ) where

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

-- | Toggles whether notifications for new gifts received by a channel chat are sent to the current user; requires can_post_messages administrator right in the chat. Returns 'TD.Data.Ok.Ok'
data ToggleChatGiftNotifications
  = ToggleChatGiftNotifications
    { ToggleChatGiftNotifications -> Maybe Int
chat_id     :: Maybe Int  -- ^ Identifier of the channel chat
    , ToggleChatGiftNotifications -> Maybe Bool
are_enabled :: Maybe Bool -- ^ Pass true to enable notifications about new gifts owned by the channel chat; pass false to disable the notifications
    }
  deriving (ToggleChatGiftNotifications -> ToggleChatGiftNotifications -> Bool
(ToggleChatGiftNotifications
 -> ToggleChatGiftNotifications -> Bool)
-> (ToggleChatGiftNotifications
    -> ToggleChatGiftNotifications -> Bool)
-> Eq ToggleChatGiftNotifications
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ToggleChatGiftNotifications -> ToggleChatGiftNotifications -> Bool
== :: ToggleChatGiftNotifications -> ToggleChatGiftNotifications -> Bool
$c/= :: ToggleChatGiftNotifications -> ToggleChatGiftNotifications -> Bool
/= :: ToggleChatGiftNotifications -> ToggleChatGiftNotifications -> Bool
Eq, Int -> ToggleChatGiftNotifications -> ShowS
[ToggleChatGiftNotifications] -> ShowS
ToggleChatGiftNotifications -> String
(Int -> ToggleChatGiftNotifications -> ShowS)
-> (ToggleChatGiftNotifications -> String)
-> ([ToggleChatGiftNotifications] -> ShowS)
-> Show ToggleChatGiftNotifications
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ToggleChatGiftNotifications -> ShowS
showsPrec :: Int -> ToggleChatGiftNotifications -> ShowS
$cshow :: ToggleChatGiftNotifications -> String
show :: ToggleChatGiftNotifications -> String
$cshowList :: [ToggleChatGiftNotifications] -> ShowS
showList :: [ToggleChatGiftNotifications] -> ShowS
Show)

instance I.ShortShow ToggleChatGiftNotifications where
  shortShow :: ToggleChatGiftNotifications -> String
shortShow
    ToggleChatGiftNotifications
      { chat_id :: ToggleChatGiftNotifications -> Maybe Int
chat_id     = Maybe Int
chat_id_
      , are_enabled :: ToggleChatGiftNotifications -> Maybe Bool
are_enabled = Maybe Bool
are_enabled_
      }
        = String
"ToggleChatGiftNotifications"
          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
"are_enabled" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
are_enabled_
          ]

instance AT.ToJSON ToggleChatGiftNotifications where
  toJSON :: ToggleChatGiftNotifications -> Value
toJSON
    ToggleChatGiftNotifications
      { chat_id :: ToggleChatGiftNotifications -> Maybe Int
chat_id     = Maybe Int
chat_id_
      , are_enabled :: ToggleChatGiftNotifications -> Maybe Bool
are_enabled = Maybe Bool
are_enabled_
      }
        = [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
"toggleChatGiftNotifications"
          , 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
"are_enabled" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
are_enabled_
          ]

defaultToggleChatGiftNotifications :: ToggleChatGiftNotifications
defaultToggleChatGiftNotifications :: ToggleChatGiftNotifications
defaultToggleChatGiftNotifications =
  ToggleChatGiftNotifications
    { chat_id :: Maybe Int
chat_id     = Maybe Int
forall a. Maybe a
Nothing
    , are_enabled :: Maybe Bool
are_enabled = Maybe Bool
forall a. Maybe a
Nothing
    }