module TD.Query.ApproveSuggestedPost
  (ApproveSuggestedPost(..)
  , defaultApproveSuggestedPost
  ) where

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

-- | Approves a suggested post in a channel direct messages chat. Returns 'TD.Data.Ok.Ok'
data ApproveSuggestedPost
  = ApproveSuggestedPost
    { ApproveSuggestedPost -> Maybe Int
chat_id    :: Maybe Int -- ^ Chat identifier of the channel direct messages chat
    , ApproveSuggestedPost -> Maybe Int
message_id :: Maybe Int -- ^ Identifier of the message with the suggested post. Use messageProperties.can_be_approved to check whether the suggested post can be approved
    , ApproveSuggestedPost -> Maybe Int
send_date  :: Maybe Int -- ^ Point in time (Unix timestamp) when the post is expected to be published; pass 0 if the date has already been chosen. If specified, then the date must be in the future, but at most getOption("suggested_post_send_delay_max") seconds in the future
    }
  deriving (ApproveSuggestedPost -> ApproveSuggestedPost -> Bool
(ApproveSuggestedPost -> ApproveSuggestedPost -> Bool)
-> (ApproveSuggestedPost -> ApproveSuggestedPost -> Bool)
-> Eq ApproveSuggestedPost
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ApproveSuggestedPost -> ApproveSuggestedPost -> Bool
== :: ApproveSuggestedPost -> ApproveSuggestedPost -> Bool
$c/= :: ApproveSuggestedPost -> ApproveSuggestedPost -> Bool
/= :: ApproveSuggestedPost -> ApproveSuggestedPost -> Bool
Eq, Int -> ApproveSuggestedPost -> ShowS
[ApproveSuggestedPost] -> ShowS
ApproveSuggestedPost -> String
(Int -> ApproveSuggestedPost -> ShowS)
-> (ApproveSuggestedPost -> String)
-> ([ApproveSuggestedPost] -> ShowS)
-> Show ApproveSuggestedPost
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ApproveSuggestedPost -> ShowS
showsPrec :: Int -> ApproveSuggestedPost -> ShowS
$cshow :: ApproveSuggestedPost -> String
show :: ApproveSuggestedPost -> String
$cshowList :: [ApproveSuggestedPost] -> ShowS
showList :: [ApproveSuggestedPost] -> ShowS
Show)

instance I.ShortShow ApproveSuggestedPost where
  shortShow :: ApproveSuggestedPost -> String
shortShow
    ApproveSuggestedPost
      { chat_id :: ApproveSuggestedPost -> Maybe Int
chat_id    = Maybe Int
chat_id_
      , message_id :: ApproveSuggestedPost -> Maybe Int
message_id = Maybe Int
message_id_
      , send_date :: ApproveSuggestedPost -> Maybe Int
send_date  = Maybe Int
send_date_
      }
        = String
"ApproveSuggestedPost"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id"    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"message_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_id_
          , String
"send_date"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
send_date_
          ]

instance AT.ToJSON ApproveSuggestedPost where
  toJSON :: ApproveSuggestedPost -> Value
toJSON
    ApproveSuggestedPost
      { chat_id :: ApproveSuggestedPost -> Maybe Int
chat_id    = Maybe Int
chat_id_
      , message_id :: ApproveSuggestedPost -> Maybe Int
message_id = Maybe Int
message_id_
      , send_date :: ApproveSuggestedPost -> Maybe Int
send_date  = Maybe Int
send_date_
      }
        = [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
"approveSuggestedPost"
          , Key
"chat_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
chat_id_
          , Key
"message_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
message_id_
          , Key
"send_date"  Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
send_date_
          ]

defaultApproveSuggestedPost :: ApproveSuggestedPost
defaultApproveSuggestedPost :: ApproveSuggestedPost
defaultApproveSuggestedPost =
  ApproveSuggestedPost
    { chat_id :: Maybe Int
chat_id    = Maybe Int
forall a. Maybe a
Nothing
    , message_id :: Maybe Int
message_id = Maybe Int
forall a. Maybe a
Nothing
    , send_date :: Maybe Int
send_date  = Maybe Int
forall a. Maybe a
Nothing
    }