module TD.Query.GetTonTransactions
  (GetTonTransactions(..)
  , defaultGetTonTransactions
  ) 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.TransactionDirection as TransactionDirection
import qualified Data.Text as T

-- | Returns the list of Toncoin transactions of the current user. Returns 'TD.Data.TonTransactions.TonTransactions'
data GetTonTransactions
  = GetTonTransactions
    { GetTonTransactions -> Maybe TransactionDirection
direction :: Maybe TransactionDirection.TransactionDirection -- ^ Direction of the transactions to receive; pass null to get all transactions
    , GetTonTransactions -> 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
    , GetTonTransactions -> Maybe Int
limit     :: Maybe Int                                       -- ^ The maximum number of transactions to return
    }
  deriving (GetTonTransactions -> GetTonTransactions -> Bool
(GetTonTransactions -> GetTonTransactions -> Bool)
-> (GetTonTransactions -> GetTonTransactions -> Bool)
-> Eq GetTonTransactions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetTonTransactions -> GetTonTransactions -> Bool
== :: GetTonTransactions -> GetTonTransactions -> Bool
$c/= :: GetTonTransactions -> GetTonTransactions -> Bool
/= :: GetTonTransactions -> GetTonTransactions -> Bool
Eq, Int -> GetTonTransactions -> ShowS
[GetTonTransactions] -> ShowS
GetTonTransactions -> String
(Int -> GetTonTransactions -> ShowS)
-> (GetTonTransactions -> String)
-> ([GetTonTransactions] -> ShowS)
-> Show GetTonTransactions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetTonTransactions -> ShowS
showsPrec :: Int -> GetTonTransactions -> ShowS
$cshow :: GetTonTransactions -> String
show :: GetTonTransactions -> String
$cshowList :: [GetTonTransactions] -> ShowS
showList :: [GetTonTransactions] -> ShowS
Show)

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

defaultGetTonTransactions :: GetTonTransactions
defaultGetTonTransactions :: GetTonTransactions
defaultGetTonTransactions =
  GetTonTransactions
    { direction :: Maybe TransactionDirection
direction = Maybe TransactionDirection
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
    }