module TD.Query.ShareUsersWithBot
  (ShareUsersWithBot(..)
  , defaultShareUsersWithBot
  ) where

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

-- | Shares users after pressing a keyboardButtonTypeRequestUsers button with the bot. Returns 'TD.Data.Ok.Ok'
data ShareUsersWithBot
  = ShareUsersWithBot
    { ShareUsersWithBot -> Maybe Int
chat_id         :: Maybe Int   -- ^ Identifier of the chat with the bot
    , ShareUsersWithBot -> Maybe Int
message_id      :: Maybe Int   -- ^ Identifier of the message with the button
    , ShareUsersWithBot -> Maybe Int
button_id       :: Maybe Int   -- ^ Identifier of the button
    , ShareUsersWithBot -> Maybe [Int]
shared_user_ids :: Maybe [Int] -- ^ Identifiers of the shared users
    , ShareUsersWithBot -> Maybe Bool
only_check      :: Maybe Bool  -- ^ Pass true to check that the users can be shared by the button instead of actually sharing them
    }
  deriving (ShareUsersWithBot -> ShareUsersWithBot -> Bool
(ShareUsersWithBot -> ShareUsersWithBot -> Bool)
-> (ShareUsersWithBot -> ShareUsersWithBot -> Bool)
-> Eq ShareUsersWithBot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ShareUsersWithBot -> ShareUsersWithBot -> Bool
== :: ShareUsersWithBot -> ShareUsersWithBot -> Bool
$c/= :: ShareUsersWithBot -> ShareUsersWithBot -> Bool
/= :: ShareUsersWithBot -> ShareUsersWithBot -> Bool
Eq, Int -> ShareUsersWithBot -> ShowS
[ShareUsersWithBot] -> ShowS
ShareUsersWithBot -> String
(Int -> ShareUsersWithBot -> ShowS)
-> (ShareUsersWithBot -> String)
-> ([ShareUsersWithBot] -> ShowS)
-> Show ShareUsersWithBot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ShareUsersWithBot -> ShowS
showsPrec :: Int -> ShareUsersWithBot -> ShowS
$cshow :: ShareUsersWithBot -> String
show :: ShareUsersWithBot -> String
$cshowList :: [ShareUsersWithBot] -> ShowS
showList :: [ShareUsersWithBot] -> ShowS
Show)

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

instance AT.ToJSON ShareUsersWithBot where
  toJSON :: ShareUsersWithBot -> Value
toJSON
    ShareUsersWithBot
      { chat_id :: ShareUsersWithBot -> Maybe Int
chat_id         = Maybe Int
chat_id_
      , message_id :: ShareUsersWithBot -> Maybe Int
message_id      = Maybe Int
message_id_
      , button_id :: ShareUsersWithBot -> Maybe Int
button_id       = Maybe Int
button_id_
      , shared_user_ids :: ShareUsersWithBot -> Maybe [Int]
shared_user_ids = Maybe [Int]
shared_user_ids_
      , only_check :: ShareUsersWithBot -> 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
"shareUsersWithBot"
          , 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_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]
shared_user_ids_
          , 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_
          ]

defaultShareUsersWithBot :: ShareUsersWithBot
defaultShareUsersWithBot :: ShareUsersWithBot
defaultShareUsersWithBot =
  ShareUsersWithBot
    { 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_user_ids :: Maybe [Int]
shared_user_ids = Maybe [Int]
forall a. Maybe a
Nothing
    , only_check :: Maybe Bool
only_check      = Maybe Bool
forall a. Maybe a
Nothing
    }