module TD.Query.GetChatRevenueWithdrawalUrl
  (GetChatRevenueWithdrawalUrl(..)
  , defaultGetChatRevenueWithdrawalUrl
  ) 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 a URL for chat revenue withdrawal; requires owner privileges in the chat. Currently, this method can be used only for channels if supergroupFullInfo.can_get_revenue_statistics == true and getOption("can_withdraw_chat_revenue"). Returns 'TD.Data.HttpUrl.HttpUrl'
data GetChatRevenueWithdrawalUrl
  = GetChatRevenueWithdrawalUrl
    { GetChatRevenueWithdrawalUrl -> Maybe Int
chat_id  :: Maybe Int    -- ^ Chat identifier
    , GetChatRevenueWithdrawalUrl -> Maybe Text
password :: Maybe T.Text -- ^ The 2-step verification password of the current user
    }
  deriving (GetChatRevenueWithdrawalUrl -> GetChatRevenueWithdrawalUrl -> Bool
(GetChatRevenueWithdrawalUrl
 -> GetChatRevenueWithdrawalUrl -> Bool)
-> (GetChatRevenueWithdrawalUrl
    -> GetChatRevenueWithdrawalUrl -> Bool)
-> Eq GetChatRevenueWithdrawalUrl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetChatRevenueWithdrawalUrl -> GetChatRevenueWithdrawalUrl -> Bool
== :: GetChatRevenueWithdrawalUrl -> GetChatRevenueWithdrawalUrl -> Bool
$c/= :: GetChatRevenueWithdrawalUrl -> GetChatRevenueWithdrawalUrl -> Bool
/= :: GetChatRevenueWithdrawalUrl -> GetChatRevenueWithdrawalUrl -> Bool
Eq, Int -> GetChatRevenueWithdrawalUrl -> ShowS
[GetChatRevenueWithdrawalUrl] -> ShowS
GetChatRevenueWithdrawalUrl -> String
(Int -> GetChatRevenueWithdrawalUrl -> ShowS)
-> (GetChatRevenueWithdrawalUrl -> String)
-> ([GetChatRevenueWithdrawalUrl] -> ShowS)
-> Show GetChatRevenueWithdrawalUrl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetChatRevenueWithdrawalUrl -> ShowS
showsPrec :: Int -> GetChatRevenueWithdrawalUrl -> ShowS
$cshow :: GetChatRevenueWithdrawalUrl -> String
show :: GetChatRevenueWithdrawalUrl -> String
$cshowList :: [GetChatRevenueWithdrawalUrl] -> ShowS
showList :: [GetChatRevenueWithdrawalUrl] -> ShowS
Show)

instance I.ShortShow GetChatRevenueWithdrawalUrl where
  shortShow :: GetChatRevenueWithdrawalUrl -> String
shortShow
    GetChatRevenueWithdrawalUrl
      { chat_id :: GetChatRevenueWithdrawalUrl -> Maybe Int
chat_id  = Maybe Int
chat_id_
      , password :: GetChatRevenueWithdrawalUrl -> Maybe Text
password = Maybe Text
password_
      }
        = String
"GetChatRevenueWithdrawalUrl"
          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
"password" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
password_
          ]

instance AT.ToJSON GetChatRevenueWithdrawalUrl where
  toJSON :: GetChatRevenueWithdrawalUrl -> Value
toJSON
    GetChatRevenueWithdrawalUrl
      { chat_id :: GetChatRevenueWithdrawalUrl -> Maybe Int
chat_id  = Maybe Int
chat_id_
      , password :: GetChatRevenueWithdrawalUrl -> Maybe Text
password = Maybe Text
password_
      }
        = [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
"getChatRevenueWithdrawalUrl"
          , 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
"password" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
password_
          ]

defaultGetChatRevenueWithdrawalUrl :: GetChatRevenueWithdrawalUrl
defaultGetChatRevenueWithdrawalUrl :: GetChatRevenueWithdrawalUrl
defaultGetChatRevenueWithdrawalUrl =
  GetChatRevenueWithdrawalUrl
    { chat_id :: Maybe Int
chat_id  = Maybe Int
forall a. Maybe a
Nothing
    , password :: Maybe Text
password = Maybe Text
forall a. Maybe a
Nothing
    }