forked from stellar/js-stellar-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount_call_builder.ts
56 lines (52 loc) · 2.12 KB
/
account_call_builder.ts
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
import { Asset } from "stellar-base";
import { CallBuilder } from "./call_builder";
import { ServerApi } from "./server_api";
/**
* Creates a new {@link AccountCallBuilder} pointed to server defined by serverUrl.
* Do not create this object directly, use {@link Server#accounts}.
*
* @see [All Accounts](https://www.stellar.org/developers/horizon/reference/resources/account.html)
* @class AccountCallBuilder
* @extends CallBuilder
* @constructor
* @param {string} serverUrl Horizon server URL.
*/
export class AccountCallBuilder extends CallBuilder<ServerApi.AccountRecord> {
constructor(serverUrl: uri.URI) {
super(serverUrl);
this.url.segment("accounts");
}
/**
* Returns information and links relating to a single account.
* The balances section in the returned JSON will also list all the trust lines this account has set up.
*
* @see [Account Details](https://www.stellar.org/developers/horizon/reference/endpoints/accounts-single.html)
* @param {string} id For example: `GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD`
* @returns {AccountCallBuilder} current AccountCallBuilder instance
*/
public accountId(id: string): this {
this.filter.push(["accounts", id]);
return this;
}
/**
* This endpoint filters accounts by signer account.
* @see [Accounts](https://www.stellar.org/developers/horizon/reference/endpoints/accounts.html)
* @param {string} value For example: `GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD`
* @returns {AccountCallBuilder} current AccountCallBuilder instance
*/
public forSigner(id: string) {
this.url.setQuery("signer", id);
return this;
}
/**
* This endpoint filters all accounts who are trustees to an asset.
* @see [Accounts](https://www.stellar.org/developers/horizon/reference/endpoints/accounts.html)
* @see Asset
* @param {Asset} value For example: `new Asset('USD','GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD')`
* @returns {AccountCallBuilder} current AccountCallBuilder instance
*/
public forAsset(asset: Asset) {
this.url.setQuery("asset", `${asset}`);
return this;
}
}