{-# LANGUAGE DeriveGeneric #-}
module Telegram.Bot.API.Types.EncryptedCredentials where

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Text (Text)
import GHC.Generics (Generic)

import Telegram.Bot.API.Internal.Utils

-- ** 'EncryptedCredentials'

-- | Contains data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes.
data EncryptedCredentials = EncryptedCredentials
  { EncryptedCredentials -> Text
encryptedCredentialsData   :: Text -- ^ Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication.
  , EncryptedCredentials -> Text
encryptedCredentialsHash   :: Text -- ^ Base64-encoded data hash for data authentication.
  , EncryptedCredentials -> Text
encryptedCredentialsSecret :: Text -- ^ Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption
  }
  deriving (forall x. Rep EncryptedCredentials x -> EncryptedCredentials
forall x. EncryptedCredentials -> Rep EncryptedCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptedCredentials x -> EncryptedCredentials
$cfrom :: forall x. EncryptedCredentials -> Rep EncryptedCredentials x
Generic, Int -> EncryptedCredentials -> ShowS
[EncryptedCredentials] -> ShowS
EncryptedCredentials -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptedCredentials] -> ShowS
$cshowList :: [EncryptedCredentials] -> ShowS
show :: EncryptedCredentials -> String
$cshow :: EncryptedCredentials -> String
showsPrec :: Int -> EncryptedCredentials -> ShowS
$cshowsPrec :: Int -> EncryptedCredentials -> ShowS
Show)

instance ToJSON   EncryptedCredentials where toJSON :: EncryptedCredentials -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
instance FromJSON EncryptedCredentials where parseJSON :: Value -> Parser EncryptedCredentials
parseJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON