module TD.Query.SetCommunityPhoto
  (SetCommunityPhoto(..)
  , defaultSetCommunityPhoto
  ) 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 community; requires can_change_info administrator right in the community. Returns 'TD.Data.Ok.Ok'
data SetCommunityPhoto
  = SetCommunityPhoto
    { SetCommunityPhoto -> Maybe Int
community_id :: Maybe Int                           -- ^ Identifier of the community
    , SetCommunityPhoto -> Maybe InputChatPhoto
photo        :: Maybe InputChatPhoto.InputChatPhoto -- ^ New community photo; pass null to delete the community photo
    }
  deriving (SetCommunityPhoto -> SetCommunityPhoto -> Bool
(SetCommunityPhoto -> SetCommunityPhoto -> Bool)
-> (SetCommunityPhoto -> SetCommunityPhoto -> Bool)
-> Eq SetCommunityPhoto
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetCommunityPhoto -> SetCommunityPhoto -> Bool
== :: SetCommunityPhoto -> SetCommunityPhoto -> Bool
$c/= :: SetCommunityPhoto -> SetCommunityPhoto -> Bool
/= :: SetCommunityPhoto -> SetCommunityPhoto -> Bool
Eq, Int -> SetCommunityPhoto -> ShowS
[SetCommunityPhoto] -> ShowS
SetCommunityPhoto -> String
(Int -> SetCommunityPhoto -> ShowS)
-> (SetCommunityPhoto -> String)
-> ([SetCommunityPhoto] -> ShowS)
-> Show SetCommunityPhoto
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetCommunityPhoto -> ShowS
showsPrec :: Int -> SetCommunityPhoto -> ShowS
$cshow :: SetCommunityPhoto -> String
show :: SetCommunityPhoto -> String
$cshowList :: [SetCommunityPhoto] -> ShowS
showList :: [SetCommunityPhoto] -> ShowS
Show)

instance I.ShortShow SetCommunityPhoto where
  shortShow :: SetCommunityPhoto -> String
shortShow
    SetCommunityPhoto
      { community_id :: SetCommunityPhoto -> Maybe Int
community_id = Maybe Int
community_id_
      , photo :: SetCommunityPhoto -> Maybe InputChatPhoto
photo        = Maybe InputChatPhoto
photo_
      }
        = String
"SetCommunityPhoto"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"community_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
community_id_
          , String
"photo"        String -> Maybe InputChatPhoto -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputChatPhoto
photo_
          ]

instance AT.ToJSON SetCommunityPhoto where
  toJSON :: SetCommunityPhoto -> Value
toJSON
    SetCommunityPhoto
      { community_id :: SetCommunityPhoto -> Maybe Int
community_id = Maybe Int
community_id_
      , photo :: SetCommunityPhoto -> 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
"setCommunityPhoto"
          , Key
"community_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
community_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_
          ]

defaultSetCommunityPhoto :: SetCommunityPhoto
defaultSetCommunityPhoto :: SetCommunityPhoto
defaultSetCommunityPhoto =
  SetCommunityPhoto
    { community_id :: Maybe Int
community_id = Maybe Int
forall a. Maybe a
Nothing
    , photo :: Maybe InputChatPhoto
photo        = Maybe InputChatPhoto
forall a. Maybe a
Nothing
    }