module TD.Query.SetUserPersonalProfilePhoto
  (SetUserPersonalProfilePhoto(..)
  , defaultSetUserPersonalProfilePhoto
  ) 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 a personal profile photo of a contact user. Returns 'TD.Data.Ok.Ok'
data SetUserPersonalProfilePhoto
  = SetUserPersonalProfilePhoto
    { SetUserPersonalProfilePhoto -> Maybe Int
user_id :: Maybe Int                           -- ^ User identifier
    , SetUserPersonalProfilePhoto -> Maybe InputChatPhoto
photo   :: Maybe InputChatPhoto.InputChatPhoto -- ^ Profile photo to set; pass null to delete the photo; inputChatPhotoPrevious isn't supported in this function
    }
  deriving (SetUserPersonalProfilePhoto -> SetUserPersonalProfilePhoto -> Bool
(SetUserPersonalProfilePhoto
 -> SetUserPersonalProfilePhoto -> Bool)
-> (SetUserPersonalProfilePhoto
    -> SetUserPersonalProfilePhoto -> Bool)
-> Eq SetUserPersonalProfilePhoto
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetUserPersonalProfilePhoto -> SetUserPersonalProfilePhoto -> Bool
== :: SetUserPersonalProfilePhoto -> SetUserPersonalProfilePhoto -> Bool
$c/= :: SetUserPersonalProfilePhoto -> SetUserPersonalProfilePhoto -> Bool
/= :: SetUserPersonalProfilePhoto -> SetUserPersonalProfilePhoto -> Bool
Eq, Int -> SetUserPersonalProfilePhoto -> ShowS
[SetUserPersonalProfilePhoto] -> ShowS
SetUserPersonalProfilePhoto -> String
(Int -> SetUserPersonalProfilePhoto -> ShowS)
-> (SetUserPersonalProfilePhoto -> String)
-> ([SetUserPersonalProfilePhoto] -> ShowS)
-> Show SetUserPersonalProfilePhoto
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetUserPersonalProfilePhoto -> ShowS
showsPrec :: Int -> SetUserPersonalProfilePhoto -> ShowS
$cshow :: SetUserPersonalProfilePhoto -> String
show :: SetUserPersonalProfilePhoto -> String
$cshowList :: [SetUserPersonalProfilePhoto] -> ShowS
showList :: [SetUserPersonalProfilePhoto] -> ShowS
Show)

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

instance AT.ToJSON SetUserPersonalProfilePhoto where
  toJSON :: SetUserPersonalProfilePhoto -> Value
toJSON
    SetUserPersonalProfilePhoto
      { user_id :: SetUserPersonalProfilePhoto -> Maybe Int
user_id = Maybe Int
user_id_
      , photo :: SetUserPersonalProfilePhoto -> 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
"setUserPersonalProfilePhoto"
          , Key
"user_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
user_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_
          ]

defaultSetUserPersonalProfilePhoto :: SetUserPersonalProfilePhoto
defaultSetUserPersonalProfilePhoto :: SetUserPersonalProfilePhoto
defaultSetUserPersonalProfilePhoto =
  SetUserPersonalProfilePhoto
    { user_id :: Maybe Int
user_id = Maybe Int
forall a. Maybe a
Nothing
    , photo :: Maybe InputChatPhoto
photo   = Maybe InputChatPhoto
forall a. Maybe a
Nothing
    }