module TD.Query.RequestQrCodeAuthentication
  (RequestQrCodeAuthentication(..)
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Requests QR code authentication by scanning a QR code on another logged in device. Works only when the current authorization state is authorizationStateWaitPhoneNumber, or if there is no pending authentication query and the current authorization state is authorizationStateWaitEmailAddress, authorizationStateWaitEmailCode, authorizationStateWaitCode, authorizationStateWaitRegistration, or authorizationStateWaitPassword. Returns 'TD.Data.Ok.Ok'
data RequestQrCodeAuthentication
  = RequestQrCodeAuthentication
    { RequestQrCodeAuthentication -> Maybe [Int]
other_user_ids :: Maybe [Int] -- ^ List of user identifiers of other users currently using the application
    }
  deriving (RequestQrCodeAuthentication -> RequestQrCodeAuthentication -> Bool
(RequestQrCodeAuthentication
 -> RequestQrCodeAuthentication -> Bool)
-> (RequestQrCodeAuthentication
    -> RequestQrCodeAuthentication -> Bool)
-> Eq RequestQrCodeAuthentication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RequestQrCodeAuthentication -> RequestQrCodeAuthentication -> Bool
== :: RequestQrCodeAuthentication -> RequestQrCodeAuthentication -> Bool
$c/= :: RequestQrCodeAuthentication -> RequestQrCodeAuthentication -> Bool
/= :: RequestQrCodeAuthentication -> RequestQrCodeAuthentication -> Bool
Eq, Int -> RequestQrCodeAuthentication -> ShowS
[RequestQrCodeAuthentication] -> ShowS
RequestQrCodeAuthentication -> String
(Int -> RequestQrCodeAuthentication -> ShowS)
-> (RequestQrCodeAuthentication -> String)
-> ([RequestQrCodeAuthentication] -> ShowS)
-> Show RequestQrCodeAuthentication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RequestQrCodeAuthentication -> ShowS
showsPrec :: Int -> RequestQrCodeAuthentication -> ShowS
$cshow :: RequestQrCodeAuthentication -> String
show :: RequestQrCodeAuthentication -> String
$cshowList :: [RequestQrCodeAuthentication] -> ShowS
showList :: [RequestQrCodeAuthentication] -> ShowS
Show)

instance I.ShortShow RequestQrCodeAuthentication where
  shortShow :: RequestQrCodeAuthentication -> String
shortShow
    RequestQrCodeAuthentication
      { other_user_ids :: RequestQrCodeAuthentication -> Maybe [Int]
other_user_ids = Maybe [Int]
other_user_ids_
      }
        = String
"RequestQrCodeAuthentication"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"other_user_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
other_user_ids_
          ]

instance AT.ToJSON RequestQrCodeAuthentication where
  toJSON :: RequestQrCodeAuthentication -> Value
toJSON
    RequestQrCodeAuthentication
      { other_user_ids :: RequestQrCodeAuthentication -> Maybe [Int]
other_user_ids = Maybe [Int]
other_user_ids_
      }
        = [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
"requestQrCodeAuthentication"
          , Key
"other_user_ids" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
other_user_ids_
          ]