module TD.Query.SetLoginEmailAddress
  (SetLoginEmailAddress(..)
  ) 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

-- | Changes the login email address of the user. The email address can be changed only if the current user already has login email and passwordState.login_email_address_pattern is non-empty. The change will not be applied until the new login email address is confirmed with checkLoginEmailAddressCode. To use Apple ID/Google ID instead of an email address, call checkLoginEmailAddressCode directly. Returns 'TD.Data.EmailAddressAuthenticationCodeInfo.EmailAddressAuthenticationCodeInfo'
data SetLoginEmailAddress
  = SetLoginEmailAddress
    { SetLoginEmailAddress -> Maybe Text
new_login_email_address :: Maybe T.Text -- ^ New login email address
    }
  deriving (SetLoginEmailAddress -> SetLoginEmailAddress -> Bool
(SetLoginEmailAddress -> SetLoginEmailAddress -> Bool)
-> (SetLoginEmailAddress -> SetLoginEmailAddress -> Bool)
-> Eq SetLoginEmailAddress
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetLoginEmailAddress -> SetLoginEmailAddress -> Bool
== :: SetLoginEmailAddress -> SetLoginEmailAddress -> Bool
$c/= :: SetLoginEmailAddress -> SetLoginEmailAddress -> Bool
/= :: SetLoginEmailAddress -> SetLoginEmailAddress -> Bool
Eq, Int -> SetLoginEmailAddress -> ShowS
[SetLoginEmailAddress] -> ShowS
SetLoginEmailAddress -> String
(Int -> SetLoginEmailAddress -> ShowS)
-> (SetLoginEmailAddress -> String)
-> ([SetLoginEmailAddress] -> ShowS)
-> Show SetLoginEmailAddress
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetLoginEmailAddress -> ShowS
showsPrec :: Int -> SetLoginEmailAddress -> ShowS
$cshow :: SetLoginEmailAddress -> String
show :: SetLoginEmailAddress -> String
$cshowList :: [SetLoginEmailAddress] -> ShowS
showList :: [SetLoginEmailAddress] -> ShowS
Show)

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

instance AT.ToJSON SetLoginEmailAddress where
  toJSON :: SetLoginEmailAddress -> Value
toJSON
    SetLoginEmailAddress
      { new_login_email_address :: SetLoginEmailAddress -> Maybe Text
new_login_email_address = Maybe Text
new_login_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
"setLoginEmailAddress"
          , Key
"new_login_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
new_login_email_address_
          ]