module TD.Query.SetBirthdate
  (SetBirthdate(..)
  ) 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.Birthdate as Birthdate

-- | Changes the birthdate of the current user. Returns 'TD.Data.Ok.Ok'
data SetBirthdate
  = SetBirthdate
    { SetBirthdate -> Maybe Birthdate
birthdate :: Maybe Birthdate.Birthdate -- ^ The new value of the current user's birthdate; pass null to remove the birthdate
    }
  deriving (SetBirthdate -> SetBirthdate -> Bool
(SetBirthdate -> SetBirthdate -> Bool)
-> (SetBirthdate -> SetBirthdate -> Bool) -> Eq SetBirthdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetBirthdate -> SetBirthdate -> Bool
== :: SetBirthdate -> SetBirthdate -> Bool
$c/= :: SetBirthdate -> SetBirthdate -> Bool
/= :: SetBirthdate -> SetBirthdate -> Bool
Eq, Int -> SetBirthdate -> ShowS
[SetBirthdate] -> ShowS
SetBirthdate -> String
(Int -> SetBirthdate -> ShowS)
-> (SetBirthdate -> String)
-> ([SetBirthdate] -> ShowS)
-> Show SetBirthdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetBirthdate -> ShowS
showsPrec :: Int -> SetBirthdate -> ShowS
$cshow :: SetBirthdate -> String
show :: SetBirthdate -> String
$cshowList :: [SetBirthdate] -> ShowS
showList :: [SetBirthdate] -> ShowS
Show)

instance I.ShortShow SetBirthdate where
  shortShow :: SetBirthdate -> String
shortShow
    SetBirthdate
      { birthdate :: SetBirthdate -> Maybe Birthdate
birthdate = Maybe Birthdate
birthdate_
      }
        = String
"SetBirthdate"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"birthdate" String -> Maybe Birthdate -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Birthdate
birthdate_
          ]

instance AT.ToJSON SetBirthdate where
  toJSON :: SetBirthdate -> Value
toJSON
    SetBirthdate
      { birthdate :: SetBirthdate -> Maybe Birthdate
birthdate = Maybe Birthdate
birthdate_
      }
        = [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
"setBirthdate"
          , Key
"birthdate" Key -> Maybe Birthdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Birthdate
birthdate_
          ]