module TD.Query.ShareChatWithBot
  (ShareChatWithBot(..)
  , defaultShareChatWithBot
  ) where

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

-- | Shares a chat after pressing a keyboardButtonTypeRequestChat button with the bot. Returns 'TD.Data.Ok.Ok'
data ShareChatWithBot
  = ShareChatWithBot
    { ShareChatWithBot -> Maybe Int
chat_id        :: Maybe Int  -- ^ Identifier of the chat with the bot
    , ShareChatWithBot -> Maybe Int
message_id     :: Maybe Int  -- ^ Identifier of the message with the button
    , ShareChatWithBot -> Maybe Int
button_id      :: Maybe Int  -- ^ Identifier of the button
    , ShareChatWithBot -> Maybe Int
shared_chat_id :: Maybe Int  -- ^ Identifier of the shared chat
    , ShareChatWithBot -> Maybe Bool
only_check     :: Maybe Bool -- ^ Pass true to check that the chat can be shared by the button instead of actually sharing it. Doesn't check bot_is_member and bot_administrator_rights restrictions. If the bot must be a member, then all chats from getGroupsInCommon and all chats, where the user can add the bot, are suitable. In the latter case the bot will be automatically added to the chat. If the bot must be an administrator, then all chats, where the bot already has requested rights or can be added to administrators by the user, are suitable. In the latter case the bot will be automatically granted requested rights
    }
  deriving (ShareChatWithBot -> ShareChatWithBot -> Bool
(ShareChatWithBot -> ShareChatWithBot -> Bool)
-> (ShareChatWithBot -> ShareChatWithBot -> Bool)
-> Eq ShareChatWithBot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ShareChatWithBot -> ShareChatWithBot -> Bool
== :: ShareChatWithBot -> ShareChatWithBot -> Bool
$c/= :: ShareChatWithBot -> ShareChatWithBot -> Bool
/= :: ShareChatWithBot -> ShareChatWithBot -> Bool
Eq, Int -> ShareChatWithBot -> ShowS
[ShareChatWithBot] -> ShowS
ShareChatWithBot -> String
(Int -> ShareChatWithBot -> ShowS)
-> (ShareChatWithBot -> String)
-> ([ShareChatWithBot] -> ShowS)
-> Show ShareChatWithBot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ShareChatWithBot -> ShowS
showsPrec :: Int -> ShareChatWithBot -> ShowS
$cshow :: ShareChatWithBot -> String
show :: ShareChatWithBot -> String
$cshowList :: [ShareChatWithBot] -> ShowS
showList :: [ShareChatWithBot] -> ShowS
Show)

instance I.ShortShow ShareChatWithBot where
  shortShow :: ShareChatWithBot -> String
shortShow
    ShareChatWithBot
      { chat_id :: ShareChatWithBot -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , message_id :: ShareChatWithBot -> Maybe Int
message_id     = Maybe Int
message_id_
      , button_id :: ShareChatWithBot -> Maybe Int
button_id      = Maybe Int
button_id_
      , shared_chat_id :: ShareChatWithBot -> Maybe Int
shared_chat_id = Maybe Int
shared_chat_id_
      , only_check :: ShareChatWithBot -> Maybe Bool
only_check     = Maybe Bool
only_check_
      }
        = String
"ShareChatWithBot"
          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
"button_id"      String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
button_id_
          , String
"shared_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
shared_chat_id_
          , String
"only_check"     String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_check_
          ]

instance AT.ToJSON ShareChatWithBot where
  toJSON :: ShareChatWithBot -> Value
toJSON
    ShareChatWithBot
      { chat_id :: ShareChatWithBot -> Maybe Int
chat_id        = Maybe Int
chat_id_
      , message_id :: ShareChatWithBot -> Maybe Int
message_id     = Maybe Int
message_id_
      , button_id :: ShareChatWithBot -> Maybe Int
button_id      = Maybe Int
button_id_
      , shared_chat_id :: ShareChatWithBot -> Maybe Int
shared_chat_id = Maybe Int
shared_chat_id_
      , only_check :: ShareChatWithBot -> Maybe Bool
only_check     = Maybe Bool
only_check_
      }
        = [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
"shareChatWithBot"
          , 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
"button_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
button_id_
          , Key
"shared_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
shared_chat_id_
          , Key
"only_check"     Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
only_check_
          ]

defaultShareChatWithBot :: ShareChatWithBot
defaultShareChatWithBot :: ShareChatWithBot
defaultShareChatWithBot =
  ShareChatWithBot
    { 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
    , button_id :: Maybe Int
button_id      = Maybe Int
forall a. Maybe a
Nothing
    , shared_chat_id :: Maybe Int
shared_chat_id = Maybe Int
forall a. Maybe a
Nothing
    , only_check :: Maybe Bool
only_check     = Maybe Bool
forall a. Maybe a
Nothing
    }