module TD.Query.GetStarTransactions
  (GetStarTransactions(..)
  , defaultGetStarTransactions
  ) where

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

-- | Returns the list of Telegram Star transactions for the specified owner. Returns 'TD.Data.StarTransactions.StarTransactions'
data GetStarTransactions
  = GetStarTransactions
    { GetStarTransactions -> Maybe MessageSender
owner_id        :: Maybe MessageSender.MessageSender                       -- ^ Identifier of the owner of the Telegram Stars; can be the identifier of the current user, identifier of an owned bot, or identifier of a channel chat with supergroupFullInfo.can_get_star_revenue_statistics == true
    , GetStarTransactions -> Maybe Text
subscription_id :: Maybe T.Text                                            -- ^ If non-empty, only transactions related to the Star Subscription will be returned
    , GetStarTransactions -> Maybe StarTransactionDirection
direction       :: Maybe StarTransactionDirection.StarTransactionDirection -- ^ Direction of the transactions to receive; pass null to get all transactions
    , GetStarTransactions -> Maybe Text
offset          :: Maybe T.Text                                            -- ^ Offset of the first transaction to return as received from the previous request; use empty string to get the first chunk of results
    , GetStarTransactions -> Maybe Int
limit           :: Maybe Int                                               -- ^ The maximum number of transactions to return
    }
  deriving (GetStarTransactions -> GetStarTransactions -> Bool
(GetStarTransactions -> GetStarTransactions -> Bool)
-> (GetStarTransactions -> GetStarTransactions -> Bool)
-> Eq GetStarTransactions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetStarTransactions -> GetStarTransactions -> Bool
== :: GetStarTransactions -> GetStarTransactions -> Bool
$c/= :: GetStarTransactions -> GetStarTransactions -> Bool
/= :: GetStarTransactions -> GetStarTransactions -> Bool
Eq, Int -> GetStarTransactions -> ShowS
[GetStarTransactions] -> ShowS
GetStarTransactions -> String
(Int -> GetStarTransactions -> ShowS)
-> (GetStarTransactions -> String)
-> ([GetStarTransactions] -> ShowS)
-> Show GetStarTransactions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetStarTransactions -> ShowS
showsPrec :: Int -> GetStarTransactions -> ShowS
$cshow :: GetStarTransactions -> String
show :: GetStarTransactions -> String
$cshowList :: [GetStarTransactions] -> ShowS
showList :: [GetStarTransactions] -> ShowS
Show)

instance I.ShortShow GetStarTransactions where
  shortShow :: GetStarTransactions -> String
shortShow
    GetStarTransactions
      { owner_id :: GetStarTransactions -> Maybe MessageSender
owner_id        = Maybe MessageSender
owner_id_
      , subscription_id :: GetStarTransactions -> Maybe Text
subscription_id = Maybe Text
subscription_id_
      , direction :: GetStarTransactions -> Maybe StarTransactionDirection
direction       = Maybe StarTransactionDirection
direction_
      , offset :: GetStarTransactions -> Maybe Text
offset          = Maybe Text
offset_
      , limit :: GetStarTransactions -> Maybe Int
limit           = Maybe Int
limit_
      }
        = String
"GetStarTransactions"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"owner_id"        String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
owner_id_
          , String
"subscription_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
subscription_id_
          , String
"direction"       String -> Maybe StarTransactionDirection -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StarTransactionDirection
direction_
          , 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 GetStarTransactions where
  toJSON :: GetStarTransactions -> Value
toJSON
    GetStarTransactions
      { owner_id :: GetStarTransactions -> Maybe MessageSender
owner_id        = Maybe MessageSender
owner_id_
      , subscription_id :: GetStarTransactions -> Maybe Text
subscription_id = Maybe Text
subscription_id_
      , direction :: GetStarTransactions -> Maybe StarTransactionDirection
direction       = Maybe StarTransactionDirection
direction_
      , offset :: GetStarTransactions -> Maybe Text
offset          = Maybe Text
offset_
      , limit :: GetStarTransactions -> 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
"getStarTransactions"
          , Key
"owner_id"        Key -> Maybe MessageSender -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe MessageSender
owner_id_
          , Key
"subscription_id" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
subscription_id_
          , Key
"direction"       Key -> Maybe StarTransactionDirection -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe StarTransactionDirection
direction_
          , 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_
          ]

defaultGetStarTransactions :: GetStarTransactions
defaultGetStarTransactions :: GetStarTransactions
defaultGetStarTransactions =
  GetStarTransactions
    { owner_id :: Maybe MessageSender
owner_id        = Maybe MessageSender
forall a. Maybe a
Nothing
    , subscription_id :: Maybe Text
subscription_id = Maybe Text
forall a. Maybe a
Nothing
    , direction :: Maybe StarTransactionDirection
direction       = Maybe StarTransactionDirection
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
    }