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

-- | Sends a code to verify an email address to be added to a user's Telegram Passport. Returns 'TD.Data.EmailAddressAuthenticationCodeInfo.EmailAddressAuthenticationCodeInfo'
data SendEmailAddressVerificationCode
  = SendEmailAddressVerificationCode
    { SendEmailAddressVerificationCode -> Maybe Text
email_address :: Maybe T.Text -- ^ Email address
    }
  deriving (SendEmailAddressVerificationCode
-> SendEmailAddressVerificationCode -> Bool
(SendEmailAddressVerificationCode
 -> SendEmailAddressVerificationCode -> Bool)
-> (SendEmailAddressVerificationCode
    -> SendEmailAddressVerificationCode -> Bool)
-> Eq SendEmailAddressVerificationCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SendEmailAddressVerificationCode
-> SendEmailAddressVerificationCode -> Bool
== :: SendEmailAddressVerificationCode
-> SendEmailAddressVerificationCode -> Bool
$c/= :: SendEmailAddressVerificationCode
-> SendEmailAddressVerificationCode -> Bool
/= :: SendEmailAddressVerificationCode
-> SendEmailAddressVerificationCode -> Bool
Eq, Int -> SendEmailAddressVerificationCode -> ShowS
[SendEmailAddressVerificationCode] -> ShowS
SendEmailAddressVerificationCode -> String
(Int -> SendEmailAddressVerificationCode -> ShowS)
-> (SendEmailAddressVerificationCode -> String)
-> ([SendEmailAddressVerificationCode] -> ShowS)
-> Show SendEmailAddressVerificationCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SendEmailAddressVerificationCode -> ShowS
showsPrec :: Int -> SendEmailAddressVerificationCode -> ShowS
$cshow :: SendEmailAddressVerificationCode -> String
show :: SendEmailAddressVerificationCode -> String
$cshowList :: [SendEmailAddressVerificationCode] -> ShowS
showList :: [SendEmailAddressVerificationCode] -> ShowS
Show)

instance I.ShortShow SendEmailAddressVerificationCode where
  shortShow :: SendEmailAddressVerificationCode -> String
shortShow
    SendEmailAddressVerificationCode
      { email_address :: SendEmailAddressVerificationCode -> Maybe Text
email_address = Maybe Text
email_address_
      }
        = String
"SendEmailAddressVerificationCode"
          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 SendEmailAddressVerificationCode where
  toJSON :: SendEmailAddressVerificationCode -> Value
toJSON
    SendEmailAddressVerificationCode
      { email_address :: SendEmailAddressVerificationCode -> 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
"sendEmailAddressVerificationCode"
          , 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_
          ]