module TD.Query.SendPassportAuthorizationForm
  (SendPassportAuthorizationForm(..)
  , defaultSendPassportAuthorizationForm
  ) where

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

-- | Sends a Telegram Passport authorization form, effectively sharing data with the service. This method must be called after getPassportAuthorizationFormAvailableElements if some previously available elements are going to be reused. Returns 'TD.Data.Ok.Ok'
data SendPassportAuthorizationForm
  = SendPassportAuthorizationForm
    { SendPassportAuthorizationForm -> Maybe Int
authorization_form_id :: Maybe Int                                       -- ^ Authorization form identifier
    , SendPassportAuthorizationForm -> Maybe [PassportElementType]
types                 :: Maybe [PassportElementType.PassportElementType] -- ^ Types of Telegram Passport elements chosen by user to complete the authorization form
    }
  deriving (SendPassportAuthorizationForm
-> SendPassportAuthorizationForm -> Bool
(SendPassportAuthorizationForm
 -> SendPassportAuthorizationForm -> Bool)
-> (SendPassportAuthorizationForm
    -> SendPassportAuthorizationForm -> Bool)
-> Eq SendPassportAuthorizationForm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SendPassportAuthorizationForm
-> SendPassportAuthorizationForm -> Bool
== :: SendPassportAuthorizationForm
-> SendPassportAuthorizationForm -> Bool
$c/= :: SendPassportAuthorizationForm
-> SendPassportAuthorizationForm -> Bool
/= :: SendPassportAuthorizationForm
-> SendPassportAuthorizationForm -> Bool
Eq, Int -> SendPassportAuthorizationForm -> ShowS
[SendPassportAuthorizationForm] -> ShowS
SendPassportAuthorizationForm -> String
(Int -> SendPassportAuthorizationForm -> ShowS)
-> (SendPassportAuthorizationForm -> String)
-> ([SendPassportAuthorizationForm] -> ShowS)
-> Show SendPassportAuthorizationForm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SendPassportAuthorizationForm -> ShowS
showsPrec :: Int -> SendPassportAuthorizationForm -> ShowS
$cshow :: SendPassportAuthorizationForm -> String
show :: SendPassportAuthorizationForm -> String
$cshowList :: [SendPassportAuthorizationForm] -> ShowS
showList :: [SendPassportAuthorizationForm] -> ShowS
Show)

instance I.ShortShow SendPassportAuthorizationForm where
  shortShow :: SendPassportAuthorizationForm -> String
shortShow
    SendPassportAuthorizationForm
      { authorization_form_id :: SendPassportAuthorizationForm -> Maybe Int
authorization_form_id = Maybe Int
authorization_form_id_
      , types :: SendPassportAuthorizationForm -> Maybe [PassportElementType]
types                 = Maybe [PassportElementType]
types_
      }
        = String
"SendPassportAuthorizationForm"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"authorization_form_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
authorization_form_id_
          , String
"types"                 String -> Maybe [PassportElementType] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [PassportElementType]
types_
          ]

instance AT.ToJSON SendPassportAuthorizationForm where
  toJSON :: SendPassportAuthorizationForm -> Value
toJSON
    SendPassportAuthorizationForm
      { authorization_form_id :: SendPassportAuthorizationForm -> Maybe Int
authorization_form_id = Maybe Int
authorization_form_id_
      , types :: SendPassportAuthorizationForm -> Maybe [PassportElementType]
types                 = Maybe [PassportElementType]
types_
      }
        = [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
"sendPassportAuthorizationForm"
          , Key
"authorization_form_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
authorization_form_id_
          , Key
"types"                 Key -> Maybe [PassportElementType] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [PassportElementType]
types_
          ]

defaultSendPassportAuthorizationForm :: SendPassportAuthorizationForm
defaultSendPassportAuthorizationForm :: SendPassportAuthorizationForm
defaultSendPassportAuthorizationForm =
  SendPassportAuthorizationForm
    { authorization_form_id :: Maybe Int
authorization_form_id = Maybe Int
forall a. Maybe a
Nothing
    , types :: Maybe [PassportElementType]
types                 = Maybe [PassportElementType]
forall a. Maybe a
Nothing
    }