module TD.Query.GetChatBoosts
  (GetChatBoosts(..)
  , defaultGetChatBoosts
  ) where

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

-- | Returns the list of boosts applied to a chat; requires administrator rights in the chat. Returns 'TD.Data.FoundChatBoosts.FoundChatBoosts'
data GetChatBoosts
  = GetChatBoosts
    { GetChatBoosts -> Maybe Int
chat_id         :: Maybe Int    -- ^ Identifier of the chat
    , GetChatBoosts -> Maybe Bool
only_gift_codes :: Maybe Bool   -- ^ Pass true to receive only boosts received from gift codes and giveaways created by the chat
    , GetChatBoosts -> Maybe Text
offset          :: Maybe T.Text -- ^ Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
    , GetChatBoosts -> Maybe Int
limit           :: Maybe Int    -- ^ The maximum number of boosts to be returned; up to 100. For optimal performance, the number of returned boosts can be smaller than the specified limit
    }
  deriving (GetChatBoosts -> GetChatBoosts -> Bool
(GetChatBoosts -> GetChatBoosts -> Bool)
-> (GetChatBoosts -> GetChatBoosts -> Bool) -> Eq GetChatBoosts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatBoosts -> GetChatBoosts -> Bool
== :: GetChatBoosts -> GetChatBoosts -> Bool
$c/= :: GetChatBoosts -> GetChatBoosts -> Bool
/= :: GetChatBoosts -> GetChatBoosts -> Bool
Eq, Int -> GetChatBoosts -> ShowS
[GetChatBoosts] -> ShowS
GetChatBoosts -> String
(Int -> GetChatBoosts -> ShowS)
-> (GetChatBoosts -> String)
-> ([GetChatBoosts] -> ShowS)
-> Show GetChatBoosts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatBoosts -> ShowS
showsPrec :: Int -> GetChatBoosts -> ShowS
$cshow :: GetChatBoosts -> String
show :: GetChatBoosts -> String
$cshowList :: [GetChatBoosts] -> ShowS
showList :: [GetChatBoosts] -> ShowS
Show)

instance I.ShortShow GetChatBoosts where
  shortShow :: GetChatBoosts -> String
shortShow
    GetChatBoosts
      { chat_id :: GetChatBoosts -> Maybe Int
chat_id         = Maybe Int
chat_id_
      , only_gift_codes :: GetChatBoosts -> Maybe Bool
only_gift_codes = Maybe Bool
only_gift_codes_
      , offset :: GetChatBoosts -> Maybe Text
offset          = Maybe Text
offset_
      , limit :: GetChatBoosts -> Maybe Int
limit           = Maybe Int
limit_
      }
        = String
"GetChatBoosts"
          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
"only_gift_codes" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_gift_codes_
          , String
"offset"          String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
offset_
          , String
"limit"           String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetChatBoosts where
  toJSON :: GetChatBoosts -> Value
toJSON
    GetChatBoosts
      { chat_id :: GetChatBoosts -> Maybe Int
chat_id         = Maybe Int
chat_id_
      , only_gift_codes :: GetChatBoosts -> Maybe Bool
only_gift_codes = Maybe Bool
only_gift_codes_
      , offset :: GetChatBoosts -> Maybe Text
offset          = Maybe Text
offset_
      , limit :: GetChatBoosts -> Maybe Int
limit           = Maybe Int
limit_
      }
        = [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
"getChatBoosts"
          , 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
"only_gift_codes" 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_gift_codes_
          , Key
"offset"          Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
offset_
          , Key
"limit"           Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
limit_
          ]

defaultGetChatBoosts :: GetChatBoosts
defaultGetChatBoosts :: GetChatBoosts
defaultGetChatBoosts =
  GetChatBoosts
    { chat_id :: Maybe Int
chat_id         = Maybe Int
forall a. Maybe a
Nothing
    , only_gift_codes :: Maybe Bool
only_gift_codes = Maybe Bool
forall a. Maybe a
Nothing
    , offset :: Maybe Text
offset          = Maybe Text
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit           = Maybe Int
forall a. Maybe a
Nothing
    }