all files / src/ payment_call_builder.js

98.53% Statements 67/68
96.88% Branches 31/32
100% Functions 11/11
91.67% Lines 11/12
17 statements, 15 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                                                                                       
import {CallBuilder} from "./call_builder";
 
export class PaymentCallBuilder extends CallBuilder {
    /**
     * Creates a new {@link PaymentCallBuilder} pointed to server defined by serverUrl.
     *
     * Do not create this object directly, use {@link Server#payments}.
     * @see [All Payments](https://www.stellar.org/developers/horizon/reference/payments-all.html)
     * @constructor
     * @extends CallBuilder
     * @param {string} serverUrl Horizon server URL.
     */
    constructor(serverUrl) {
        super(serverUrl);
        this.url.segment('payments');
    }
 
    /**
     * This endpoint responds with a collection of Payment operations where the given account was either the sender or receiver.
     * @see [Payments for Account](https://www.stellar.org/developers/horizon/reference/payments-for-account.html)
     * @param {string} accountId For example: `GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD`
     * @returns {PaymentCallBuilder}
     */
    forAccount(accountId) {
        this.filter.push(['accounts', accountId, 'payments']);
        return this;
    }
 
    /**
     * This endpoint represents all payment operations that are part of a valid transactions in a given ledger.
     * @see [Payments for Ledger](https://www.stellar.org/developers/horizon/reference/payments-for-ledger.html)
     * @param {number|string} sequence Ledger sequence
     * @returns {PaymentCallBuilder}
     */
    forLedger(sequence) {
        Iif (typeof sequence == 'number') {
            sequence = sequence.toString();
        }
        this.filter.push(['ledgers', sequence, 'payments']);
        return this;
    }
 
    /**
     * This endpoint represents all payment operations that are part of a given transaction.
     * @see [Payments for Transaction](https://www.stellar.org/developers/horizon/reference/payments-for-transaction.html)
     * @param {string} transactionId Transaction ID
     * @returns {PaymentCallBuilder}
     */
    forTransaction(transactionId) {
        this.filter.push(['transactions', transactionId, 'payments']);
        return this;
    }
}