module TD.Query.SetPassportElementErrors
  (SetPassportElementErrors(..)
  , defaultSetPassportElementErrors
  ) 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.InputPassportElementError as InputPassportElementError

-- | Informs the user that some of the elements in their Telegram Passport contain errors; for bots only. The user will not be able to resend the elements, until the errors are fixed. Returns 'TD.Data.Ok.Ok'
data SetPassportElementErrors
  = SetPassportElementErrors
    { SetPassportElementErrors -> Maybe Int
user_id :: Maybe Int                                                   -- ^ User identifier
    , SetPassportElementErrors -> Maybe [InputPassportElementError]
errors  :: Maybe [InputPassportElementError.InputPassportElementError] -- ^ The errors
    }
  deriving (SetPassportElementErrors -> SetPassportElementErrors -> Bool
(SetPassportElementErrors -> SetPassportElementErrors -> Bool)
-> (SetPassportElementErrors -> SetPassportElementErrors -> Bool)
-> Eq SetPassportElementErrors
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetPassportElementErrors -> SetPassportElementErrors -> Bool
== :: SetPassportElementErrors -> SetPassportElementErrors -> Bool
$c/= :: SetPassportElementErrors -> SetPassportElementErrors -> Bool
/= :: SetPassportElementErrors -> SetPassportElementErrors -> Bool
Eq, Int -> SetPassportElementErrors -> ShowS
[SetPassportElementErrors] -> ShowS
SetPassportElementErrors -> String
(Int -> SetPassportElementErrors -> ShowS)
-> (SetPassportElementErrors -> String)
-> ([SetPassportElementErrors] -> ShowS)
-> Show SetPassportElementErrors
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetPassportElementErrors -> ShowS
showsPrec :: Int -> SetPassportElementErrors -> ShowS
$cshow :: SetPassportElementErrors -> String
show :: SetPassportElementErrors -> String
$cshowList :: [SetPassportElementErrors] -> ShowS
showList :: [SetPassportElementErrors] -> ShowS
Show)

instance I.ShortShow SetPassportElementErrors where
  shortShow :: SetPassportElementErrors -> String
shortShow
    SetPassportElementErrors
      { user_id :: SetPassportElementErrors -> Maybe Int
user_id = Maybe Int
user_id_
      , errors :: SetPassportElementErrors -> Maybe [InputPassportElementError]
errors  = Maybe [InputPassportElementError]
errors_
      }
        = String
"SetPassportElementErrors"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"errors"  String -> Maybe [InputPassportElementError] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [InputPassportElementError]
errors_
          ]

instance AT.ToJSON SetPassportElementErrors where
  toJSON :: SetPassportElementErrors -> Value
toJSON
    SetPassportElementErrors
      { user_id :: SetPassportElementErrors -> Maybe Int
user_id = Maybe Int
user_id_
      , errors :: SetPassportElementErrors -> Maybe [InputPassportElementError]
errors  = Maybe [InputPassportElementError]
errors_
      }
        = [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
"setPassportElementErrors"
          , Key
"user_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
user_id_
          , Key
"errors"  Key -> Maybe [InputPassportElementError] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [InputPassportElementError]
errors_
          ]

defaultSetPassportElementErrors :: SetPassportElementErrors
defaultSetPassportElementErrors :: SetPassportElementErrors
defaultSetPassportElementErrors =
  SetPassportElementErrors
    { user_id :: Maybe Int
user_id = Maybe Int
forall a. Maybe a
Nothing
    , errors :: Maybe [InputPassportElementError]
errors  = Maybe [InputPassportElementError]
forall a. Maybe a
Nothing
    }