module TD.Query.SetBotUpdatesStatus
  (SetBotUpdatesStatus(..)
  , defaultSetBotUpdatesStatus
  ) 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

-- | Informs the server about the number of pending bot updates if they haven't been processed for a long time; for bots only. Returns 'TD.Data.Ok.Ok'
data SetBotUpdatesStatus
  = SetBotUpdatesStatus
    { SetBotUpdatesStatus -> Maybe Int
pending_update_count :: Maybe Int    -- ^ The number of pending updates
    , SetBotUpdatesStatus -> Maybe Text
error_message        :: Maybe T.Text -- ^ The last error message
    }
  deriving (SetBotUpdatesStatus -> SetBotUpdatesStatus -> Bool
(SetBotUpdatesStatus -> SetBotUpdatesStatus -> Bool)
-> (SetBotUpdatesStatus -> SetBotUpdatesStatus -> Bool)
-> Eq SetBotUpdatesStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetBotUpdatesStatus -> SetBotUpdatesStatus -> Bool
== :: SetBotUpdatesStatus -> SetBotUpdatesStatus -> Bool
$c/= :: SetBotUpdatesStatus -> SetBotUpdatesStatus -> Bool
/= :: SetBotUpdatesStatus -> SetBotUpdatesStatus -> Bool
Eq, Int -> SetBotUpdatesStatus -> ShowS
[SetBotUpdatesStatus] -> ShowS
SetBotUpdatesStatus -> String
(Int -> SetBotUpdatesStatus -> ShowS)
-> (SetBotUpdatesStatus -> String)
-> ([SetBotUpdatesStatus] -> ShowS)
-> Show SetBotUpdatesStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetBotUpdatesStatus -> ShowS
showsPrec :: Int -> SetBotUpdatesStatus -> ShowS
$cshow :: SetBotUpdatesStatus -> String
show :: SetBotUpdatesStatus -> String
$cshowList :: [SetBotUpdatesStatus] -> ShowS
showList :: [SetBotUpdatesStatus] -> ShowS
Show)

instance I.ShortShow SetBotUpdatesStatus where
  shortShow :: SetBotUpdatesStatus -> String
shortShow
    SetBotUpdatesStatus
      { pending_update_count :: SetBotUpdatesStatus -> Maybe Int
pending_update_count = Maybe Int
pending_update_count_
      , error_message :: SetBotUpdatesStatus -> Maybe Text
error_message        = Maybe Text
error_message_
      }
        = String
"SetBotUpdatesStatus"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"pending_update_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
pending_update_count_
          , String
"error_message"        String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
error_message_
          ]

instance AT.ToJSON SetBotUpdatesStatus where
  toJSON :: SetBotUpdatesStatus -> Value
toJSON
    SetBotUpdatesStatus
      { pending_update_count :: SetBotUpdatesStatus -> Maybe Int
pending_update_count = Maybe Int
pending_update_count_
      , error_message :: SetBotUpdatesStatus -> Maybe Text
error_message        = Maybe Text
error_message_
      }
        = [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
"setBotUpdatesStatus"
          , Key
"pending_update_count" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
pending_update_count_
          , Key
"error_message"        Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
error_message_
          ]

defaultSetBotUpdatesStatus :: SetBotUpdatesStatus
defaultSetBotUpdatesStatus :: SetBotUpdatesStatus
defaultSetBotUpdatesStatus =
  SetBotUpdatesStatus
    { pending_update_count :: Maybe Int
pending_update_count = Maybe Int
forall a. Maybe a
Nothing
    , error_message :: Maybe Text
error_message        = Maybe Text
forall a. Maybe a
Nothing
    }