{-# 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. EncryptedCredentials -> Rep EncryptedCredentials x)
-> (forall x. Rep EncryptedCredentials x -> EncryptedCredentials)
-> Generic EncryptedCredentials
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
$cfrom :: forall x. EncryptedCredentials -> Rep EncryptedCredentials x
from :: forall x. EncryptedCredentials -> Rep EncryptedCredentials x
$cto :: forall x. Rep EncryptedCredentials x -> EncryptedCredentials
to :: forall x. Rep EncryptedCredentials x -> EncryptedCredentials
Generic, Int -> EncryptedCredentials -> ShowS
[EncryptedCredentials] -> ShowS
EncryptedCredentials -> String
(Int -> EncryptedCredentials -> ShowS)
-> (EncryptedCredentials -> String)
-> ([EncryptedCredentials] -> ShowS)
-> Show EncryptedCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EncryptedCredentials -> ShowS
showsPrec :: Int -> EncryptedCredentials -> ShowS
$cshow :: EncryptedCredentials -> String
show :: EncryptedCredentials -> String
$cshowList :: [EncryptedCredentials] -> ShowS
showList :: [EncryptedCredentials] -> ShowS
Show)

instance ToJSON   EncryptedCredentials where toJSON :: EncryptedCredentials -> Value
toJSON = EncryptedCredentials -> Value
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 = Value -> Parser EncryptedCredentials
forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON