"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.OperationCallBuilder = void 0;
var _call_builder = require("./call_builder");
/**
* Creates a new {@link OperationCallBuilder} pointed to server defined by serverUrl.
* Do not create this object directly, use {@link Server#operations}.
*
* @see [All Operations](https://developers.stellar.org/api/resources/operations/)
* @class OperationCallBuilder
* @constructor
* @extends CallBuilder
* @param {string} serverUrl Horizon server URL.
*/
class OperationCallBuilder extends _call_builder.CallBuilder {
constructor(serverUrl) {
super(serverUrl, "operations");
this.url.segment("operations");
}
/**
* The operation details endpoint provides information on a single operation. The operation ID provided in the id
* argument specifies which operation to load.
* @see [Operation Details](https://developers.stellar.org/api/resources/operations/single/)
* @param {number} operationId Operation ID
* @returns {CallBuilder} this OperationCallBuilder instance
*/
operation(operationId) {
const builder = new _call_builder.CallBuilder(this.url.clone());
builder.filter.push([operationId]);
return builder;
}
/**
* This endpoint represents all operations that were included in valid transactions that affected a particular account.
* @see [Operations for Account](https://developers.stellar.org/api/resources/accounts/operations/)
* @param {string} accountId For example: `GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD`
* @returns {OperationCallBuilder} this OperationCallBuilder instance
*/
forAccount(accountId) {
return this.forEndpoint("accounts", accountId);
}
/**
* This endpoint represents all operations that reference a given claimable_balance.
* @see [Operations for Claimable Balance](https://developers.stellar.org/api/resources/claimablebalances/operations/)
* @param {string} claimableBalanceId Claimable Balance ID
* @returns {OperationCallBuilder} this OperationCallBuilder instance
*/
forClaimableBalance(claimableBalanceId) {
return this.forEndpoint("claimable_balances", claimableBalanceId);
}
/**
* This endpoint returns all operations that occurred in a given ledger.
*
* @see [Operations for Ledger](https://developers.stellar.org/api/resources/ledgers/operations/)
* @param {number|string} sequence Ledger sequence
* @returns {OperationCallBuilder} this OperationCallBuilder instance
*/
forLedger(sequence) {
return this.forEndpoint("ledgers", sequence.toString());
}
/**
* This endpoint represents all operations that are part of a given transaction.
* @see [Operations for Transaction](https://developers.stellar.org/api/resources/transactions/operations/)
* @param {string} transactionId Transaction ID
* @returns {OperationCallBuilder} this OperationCallBuilder instance
*/
forTransaction(transactionId) {
return this.forEndpoint("transactions", transactionId);
}
/**
* This endpoint represents all operations involving a particular liquidity pool.
*
* @param {string} poolId liquidity pool ID
* @returns {OperationCallBuilder} this OperationCallBuilder instance
*/
forLiquidityPool(poolId) {
return this.forEndpoint("liquidity_pools", poolId);
}
/**
* Adds a parameter defining whether to include failed transactions.
* By default, only operations of successful transactions are returned.
*
* @param {bool} value Set to `true` to include operations of failed transactions.
* @returns {OperationCallBuilder} this OperationCallBuilder instance
*/
includeFailed(value) {
this.url.setQuery("include_failed", value.toString());
return this;
}
}
exports.OperationCallBuilder = OperationCallBuilder;