module TD.Query.SetChatPhoto
  (SetChatPhoto(..)
  , defaultSetChatPhoto
  ) 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.InputChatPhoto as InputChatPhoto

-- | Changes the photo of a chat. Supported only for basic groups, supergroups and channels. Requires can_change_info member right. Returns 'TD.Data.Ok.Ok'
data SetChatPhoto
  = SetChatPhoto
    { SetChatPhoto -> Maybe Int
chat_id :: Maybe Int                           -- ^ Chat identifier
    , SetChatPhoto -> Maybe InputChatPhoto
photo   :: Maybe InputChatPhoto.InputChatPhoto -- ^ New chat photo; pass null to delete the chat photo
    }
  deriving (SetChatPhoto -> SetChatPhoto -> Bool
(SetChatPhoto -> SetChatPhoto -> Bool)
-> (SetChatPhoto -> SetChatPhoto -> Bool) -> Eq SetChatPhoto
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetChatPhoto -> SetChatPhoto -> Bool
== :: SetChatPhoto -> SetChatPhoto -> Bool
$c/= :: SetChatPhoto -> SetChatPhoto -> Bool
/= :: SetChatPhoto -> SetChatPhoto -> Bool
Eq, Int -> SetChatPhoto -> ShowS
[SetChatPhoto] -> ShowS
SetChatPhoto -> String
(Int -> SetChatPhoto -> ShowS)
-> (SetChatPhoto -> String)
-> ([SetChatPhoto] -> ShowS)
-> Show SetChatPhoto
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetChatPhoto -> ShowS
showsPrec :: Int -> SetChatPhoto -> ShowS
$cshow :: SetChatPhoto -> String
show :: SetChatPhoto -> String
$cshowList :: [SetChatPhoto] -> ShowS
showList :: [SetChatPhoto] -> ShowS
Show)

instance I.ShortShow SetChatPhoto where
  shortShow :: SetChatPhoto -> String
shortShow
    SetChatPhoto
      { chat_id :: SetChatPhoto -> Maybe Int
chat_id = Maybe Int
chat_id_
      , photo :: SetChatPhoto -> Maybe InputChatPhoto
photo   = Maybe InputChatPhoto
photo_
      }
        = String
"SetChatPhoto"
          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
"photo"   String -> Maybe InputChatPhoto -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputChatPhoto
photo_
          ]

instance AT.ToJSON SetChatPhoto where
  toJSON :: SetChatPhoto -> Value
toJSON
    SetChatPhoto
      { chat_id :: SetChatPhoto -> Maybe Int
chat_id = Maybe Int
chat_id_
      , photo :: SetChatPhoto -> Maybe InputChatPhoto
photo   = Maybe InputChatPhoto
photo_
      }
        = [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
"setChatPhoto"
          , 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
"photo"   Key -> Maybe InputChatPhoto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputChatPhoto
photo_
          ]

defaultSetChatPhoto :: SetChatPhoto
defaultSetChatPhoto :: SetChatPhoto
defaultSetChatPhoto =
  SetChatPhoto
    { chat_id :: Maybe Int
chat_id = Maybe Int
forall a. Maybe a
Nothing
    , photo :: Maybe InputChatPhoto
photo   = Maybe InputChatPhoto
forall a. Maybe a
Nothing
    }