module TD.Query.InviteUsersToBot
  (InviteUsersToBot(..)
  , defaultInviteUsersToBot
  ) where

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

-- | Invites users to private chats with a bot owned by the current user. Can be called only if userTypeBot.can_be_edited == true. Each invited user will receive a message of the type messageBotInvite, and the bot will be able to send messages to that user. The request succeeds if at least one user was invited. Returns 'TD.Data.Ok.Ok'
data InviteUsersToBot
  = InviteUsersToBot
    { InviteUsersToBot -> Maybe Int
bot_user_id :: Maybe Int   -- ^ Identifier of the bot
    , InviteUsersToBot -> Maybe [Int]
user_ids    :: Maybe [Int] -- ^ Identifiers of the users to invite; 1-10 different users
    }
  deriving (InviteUsersToBot -> InviteUsersToBot -> Bool
(InviteUsersToBot -> InviteUsersToBot -> Bool)
-> (InviteUsersToBot -> InviteUsersToBot -> Bool)
-> Eq InviteUsersToBot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InviteUsersToBot -> InviteUsersToBot -> Bool
== :: InviteUsersToBot -> InviteUsersToBot -> Bool
$c/= :: InviteUsersToBot -> InviteUsersToBot -> Bool
/= :: InviteUsersToBot -> InviteUsersToBot -> Bool
Eq, Int -> InviteUsersToBot -> ShowS
[InviteUsersToBot] -> ShowS
InviteUsersToBot -> String
(Int -> InviteUsersToBot -> ShowS)
-> (InviteUsersToBot -> String)
-> ([InviteUsersToBot] -> ShowS)
-> Show InviteUsersToBot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InviteUsersToBot -> ShowS
showsPrec :: Int -> InviteUsersToBot -> ShowS
$cshow :: InviteUsersToBot -> String
show :: InviteUsersToBot -> String
$cshowList :: [InviteUsersToBot] -> ShowS
showList :: [InviteUsersToBot] -> ShowS
Show)

instance I.ShortShow InviteUsersToBot where
  shortShow :: InviteUsersToBot -> String
shortShow
    InviteUsersToBot
      { bot_user_id :: InviteUsersToBot -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      , user_ids :: InviteUsersToBot -> Maybe [Int]
user_ids    = Maybe [Int]
user_ids_
      }
        = String
"InviteUsersToBot"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"bot_user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bot_user_id_
          , String
"user_ids"    String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
user_ids_
          ]

instance AT.ToJSON InviteUsersToBot where
  toJSON :: InviteUsersToBot -> Value
toJSON
    InviteUsersToBot
      { bot_user_id :: InviteUsersToBot -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      , user_ids :: InviteUsersToBot -> Maybe [Int]
user_ids    = Maybe [Int]
user_ids_
      }
        = [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
"inviteUsersToBot"
          , Key
"bot_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
bot_user_id_
          , Key
"user_ids"    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_ids_
          ]

defaultInviteUsersToBot :: InviteUsersToBot
defaultInviteUsersToBot :: InviteUsersToBot
defaultInviteUsersToBot =
  InviteUsersToBot
    { bot_user_id :: Maybe Int
bot_user_id = Maybe Int
forall a. Maybe a
Nothing
    , user_ids :: Maybe [Int]
user_ids    = Maybe [Int]
forall a. Maybe a
Nothing
    }