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

-- | Confirms QR code authentication on another device. Returns created session on success. Returns 'TD.Data.Session.Session'
data ConfirmQrCodeAuthentication
  = ConfirmQrCodeAuthentication
    { ConfirmQrCodeAuthentication -> Maybe Text
link :: Maybe T.Text -- ^ A link from a QR code. The link must be scanned by the in-app camera
    }
  deriving (ConfirmQrCodeAuthentication -> ConfirmQrCodeAuthentication -> Bool
(ConfirmQrCodeAuthentication
 -> ConfirmQrCodeAuthentication -> Bool)
-> (ConfirmQrCodeAuthentication
    -> ConfirmQrCodeAuthentication -> Bool)
-> Eq ConfirmQrCodeAuthentication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConfirmQrCodeAuthentication -> ConfirmQrCodeAuthentication -> Bool
== :: ConfirmQrCodeAuthentication -> ConfirmQrCodeAuthentication -> Bool
$c/= :: ConfirmQrCodeAuthentication -> ConfirmQrCodeAuthentication -> Bool
/= :: ConfirmQrCodeAuthentication -> ConfirmQrCodeAuthentication -> Bool
Eq, Int -> ConfirmQrCodeAuthentication -> ShowS
[ConfirmQrCodeAuthentication] -> ShowS
ConfirmQrCodeAuthentication -> String
(Int -> ConfirmQrCodeAuthentication -> ShowS)
-> (ConfirmQrCodeAuthentication -> String)
-> ([ConfirmQrCodeAuthentication] -> ShowS)
-> Show ConfirmQrCodeAuthentication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConfirmQrCodeAuthentication -> ShowS
showsPrec :: Int -> ConfirmQrCodeAuthentication -> ShowS
$cshow :: ConfirmQrCodeAuthentication -> String
show :: ConfirmQrCodeAuthentication -> String
$cshowList :: [ConfirmQrCodeAuthentication] -> ShowS
showList :: [ConfirmQrCodeAuthentication] -> ShowS
Show)

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

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