module TD.Query.GetForumTopicLink
  (GetForumTopicLink(..)
  , defaultGetForumTopicLink
  ) where

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

-- | Returns an HTTPS link to a topic in a forum chat. This is an offline request. Returns 'TD.Data.MessageLink.MessageLink'
data GetForumTopicLink
  = GetForumTopicLink
    { GetForumTopicLink -> Maybe Int
chat_id           :: Maybe Int -- ^ Identifier of the chat
    , GetForumTopicLink -> Maybe Int
message_thread_id :: Maybe Int -- ^ Message thread identifier of the forum topic
    }
  deriving (GetForumTopicLink -> GetForumTopicLink -> Bool
(GetForumTopicLink -> GetForumTopicLink -> Bool)
-> (GetForumTopicLink -> GetForumTopicLink -> Bool)
-> Eq GetForumTopicLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetForumTopicLink -> GetForumTopicLink -> Bool
== :: GetForumTopicLink -> GetForumTopicLink -> Bool
$c/= :: GetForumTopicLink -> GetForumTopicLink -> Bool
/= :: GetForumTopicLink -> GetForumTopicLink -> Bool
Eq, Int -> GetForumTopicLink -> ShowS
[GetForumTopicLink] -> ShowS
GetForumTopicLink -> String
(Int -> GetForumTopicLink -> ShowS)
-> (GetForumTopicLink -> String)
-> ([GetForumTopicLink] -> ShowS)
-> Show GetForumTopicLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetForumTopicLink -> ShowS
showsPrec :: Int -> GetForumTopicLink -> ShowS
$cshow :: GetForumTopicLink -> String
show :: GetForumTopicLink -> String
$cshowList :: [GetForumTopicLink] -> ShowS
showList :: [GetForumTopicLink] -> ShowS
Show)

instance I.ShortShow GetForumTopicLink where
  shortShow :: GetForumTopicLink -> String
shortShow
    GetForumTopicLink
      { chat_id :: GetForumTopicLink -> Maybe Int
chat_id           = Maybe Int
chat_id_
      , message_thread_id :: GetForumTopicLink -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
      }
        = String
"GetForumTopicLink"
          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_thread_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_thread_id_
          ]

instance AT.ToJSON GetForumTopicLink where
  toJSON :: GetForumTopicLink -> Value
toJSON
    GetForumTopicLink
      { chat_id :: GetForumTopicLink -> Maybe Int
chat_id           = Maybe Int
chat_id_
      , message_thread_id :: GetForumTopicLink -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
      }
        = [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
"getForumTopicLink"
          , 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_thread_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_thread_id_
          ]

defaultGetForumTopicLink :: GetForumTopicLink
defaultGetForumTopicLink :: GetForumTopicLink
defaultGetForumTopicLink =
  GetForumTopicLink
    { chat_id :: Maybe Int
chat_id           = Maybe Int
forall a. Maybe a
Nothing
    , message_thread_id :: Maybe Int
message_thread_id = Maybe Int
forall a. Maybe a
Nothing
    }