all files / src/ effect_call_builder.js

98.57% Statements 69/70
96.88% Branches 31/32
100% Functions 12/12
92.86% Lines 13/14
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70                                                                                                                   
import {CallBuilder} from "./call_builder";
 
/**
 * @class EffectCallBuilder
 * @extends CallBuilder
 */
export class EffectCallBuilder extends CallBuilder {
    /*
     * Creates a new {@link EffectCallBuilder} pointed to server defined by serverUrl.
     *
     * Do not create this object directly, use {@link Server#effects}.
     * @see [All Effects](https://www.stellar.org/developers/horizon/reference/effects-all.html)
     * @constructor
     * @param {string} serverUrl Horizon server URL.
     */
    constructor(serverUrl) {
        super(serverUrl);
        this.url.segment('effects');
    }
 
    /**
     * This endpoint represents all effects that changed a given account. It will return relevant effects from the creation of the account to the current ledger.
     * @see [Effects for Account](https://www.stellar.org/developers/horizon/reference/effects-for-account.html)
     * @param {string} accountId For example: `GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD`
     * @returns {EffectCallBuilder}
     */
    forAccount(accountId) {
        this.filter.push(['accounts', accountId, 'effects']);
        return this;
    }
 
    /**
     * Effects are the specific ways that the ledger was changed by any operation.
     *
     * This endpoint represents all effects that occurred in the given ledger.
     * @see [Effects for Ledger](https://www.stellar.org/developers/horizon/reference/effects-for-ledger.html)
     * @param {number|string} sequence Ledger sequence
     * @returns {EffectCallBuilder}
     */
    forLedger(sequence) {
        Iif (typeof sequence == 'number') {
            sequence = sequence.toString();
        }
        this.filter.push(['ledgers', sequence, 'effects']);
        return this;
    }
 
    /**
     * This endpoint represents all effects that occurred as a result of a given transaction.
     * @see [Effects for Transaction](https://www.stellar.org/developers/horizon/reference/effects-for-transaction.html)
     * @param {string} transactionId Transaction ID
     * @returns {EffectCallBuilder}
     */
    forTransaction(transactionId) {
        this.filter.push(['transactions', transactionId, 'effects']);
        return this;
    }
 
    /**
     * This endpoint represents all effects that occurred as a result of a given operation.
     * @see [Effects for Operation](https://www.stellar.org/developers/horizon/reference/effects-for-operation.html)
     * @param {number} operationId Operation ID
     * @returns {EffectCallBuilder}
     */
    forOperation(operationId) {
        this.filter.push(['operations', operationId, 'effects']);
        return this;
    }
}