All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ledger.transaction.kt Maven / Gradle / Ivy

package ledger

import getObjectFrom
import model.request.CreateTransaction
import model.request.TransactionFilter
import model.response.ledger.Transaction
import postObjectTo

/**
 * For more details, see Tatum API documentation
 */
fun getTransactionsByReference(reference: String): Array =
    getObjectFrom("/ledger/transaction/reference/$reference")

/**
 * For more details, see Tatum API documentation
 */
fun storeTransaction(transaction: CreateTransaction): String {
    val storedTransaction: Transaction = postObjectTo(
        endpoint = "/ledger/transaction",
        payload = transaction,
    )
    return storedTransaction.reference
}

/**
 * For more details, see Tatum API documentation
 */
fun getTransactionsByAccount(filter: TransactionFilter, pageSize: Long = 50, offset: Long = 0): Array =
    postObjectTo(
        endpoint = "/ledger/transaction/account",
        params = mapOf("pageSize" to pageSize.toString(), "offset" to offset.toString()),
        payload = filter,
    )

/**
 * For more details, see Tatum API documentation
 */
fun getTransactionsByCustomer(filter: TransactionFilter, pageSize: Long = 50, offset: Long = 0): Array =
    postObjectTo(
        endpoint = "/ledger/transaction/customer",
        params = mapOf("pageSize" to pageSize.toString(), "offset" to offset.toString()),
        payload = filter,
    )

/**
 * For more details, see Tatum API documentation
 */
fun getTransactionsByLedger(filter: TransactionFilter, pageSize: Long = 50, offset: Long = 0): Array =
    postObjectTo(
        endpoint = "/ledger/transaction/ledger",
        params = mapOf("pageSize" to pageSize.toString(), "offset" to offset.toString()),
        payload = filter,
    )

/**
 * For more details, see Tatum API documentation
 */
fun countTransactionsByAccount(filter: TransactionFilter): Array =
    postObjectTo(
        endpoint = "/ledger/transaction/account",
        params = mapOf("count" to true.toString()),
        payload = filter,
    )

/**
 * For more details, see Tatum API documentation
 */
fun countTransactionsByCustomer(filter: TransactionFilter): Array =
    postObjectTo(
        endpoint = "/ledger/transaction/customer",
        params = mapOf("count" to true.toString()),
        payload = filter,
    )

/**
 * For more details, see Tatum API documentation
 */
fun countTransactionsByLedger(filter: TransactionFilter): Array =
    postObjectTo(
        endpoint = "/ledger/transaction/ledger",
        params = mapOf("count" to true.toString()),
        payload = filter,
    )




© 2015 - 2025 Weber Informatics LLC | Privacy Policy