module TD.Query.SetAuthenticationEmailAddress
  (SetAuthenticationEmailAddress(..)
  ) where

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

-- | Sets the email address of the user and sends an authentication code to the email address. Works only when the current authorization state is authorizationStateWaitEmailAddress. Returns 'TD.Data.Ok.Ok'
data SetAuthenticationEmailAddress
  = SetAuthenticationEmailAddress
    { SetAuthenticationEmailAddress -> Maybe Text
email_address :: Maybe T.Text -- ^ The email address of the user
    }
  deriving (SetAuthenticationEmailAddress
-> SetAuthenticationEmailAddress -> Bool
(SetAuthenticationEmailAddress
 -> SetAuthenticationEmailAddress -> Bool)
-> (SetAuthenticationEmailAddress
    -> SetAuthenticationEmailAddress -> Bool)
-> Eq SetAuthenticationEmailAddress
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetAuthenticationEmailAddress
-> SetAuthenticationEmailAddress -> Bool
== :: SetAuthenticationEmailAddress
-> SetAuthenticationEmailAddress -> Bool
$c/= :: SetAuthenticationEmailAddress
-> SetAuthenticationEmailAddress -> Bool
/= :: SetAuthenticationEmailAddress
-> SetAuthenticationEmailAddress -> Bool
Eq, Int -> SetAuthenticationEmailAddress -> ShowS
[SetAuthenticationEmailAddress] -> ShowS
SetAuthenticationEmailAddress -> String
(Int -> SetAuthenticationEmailAddress -> ShowS)
-> (SetAuthenticationEmailAddress -> String)
-> ([SetAuthenticationEmailAddress] -> ShowS)
-> Show SetAuthenticationEmailAddress
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetAuthenticationEmailAddress -> ShowS
showsPrec :: Int -> SetAuthenticationEmailAddress -> ShowS
$cshow :: SetAuthenticationEmailAddress -> String
show :: SetAuthenticationEmailAddress -> String
$cshowList :: [SetAuthenticationEmailAddress] -> ShowS
showList :: [SetAuthenticationEmailAddress] -> ShowS
Show)

instance I.ShortShow SetAuthenticationEmailAddress where
  shortShow :: SetAuthenticationEmailAddress -> String
shortShow
    SetAuthenticationEmailAddress
      { email_address :: SetAuthenticationEmailAddress -> Maybe Text
email_address = Maybe Text
email_address_
      }
        = String
"SetAuthenticationEmailAddress"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"email_address" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
email_address_
          ]

instance AT.ToJSON SetAuthenticationEmailAddress where
  toJSON :: SetAuthenticationEmailAddress -> Value
toJSON
    SetAuthenticationEmailAddress
      { email_address :: SetAuthenticationEmailAddress -> Maybe Text
email_address = Maybe Text
email_address_
      }
        = [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
"setAuthenticationEmailAddress"
          , Key
"email_address" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
email_address_
          ]