-
Notifications
You must be signed in to change notification settings - Fork 206
/
Copy pathgetApplicationBoxes.ts
61 lines (57 loc) · 1.61 KB
/
getApplicationBoxes.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
57
58
59
60
61
import JSONRequest from '../jsonrequest';
import HTTPClient from '../../client';
import IntDecoding from '../../../types/intDecoding';
import { BoxesResponse } from './models/types';
/**
* Given an application ID, return all the box names associated with the app.
*
* #### Example
* ```typescript
* const index = 60553466;
* const boxesResponse = await algodClient.getApplicationBoxes(index).max(3).do();
* const boxNames = boxesResponse.boxes.map(box => box.name);
* ```
*
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idboxes)
* @param index - The application ID to look up.
* @category GET
*/
export default class GetApplicationBoxes extends JSONRequest<
BoxesResponse,
Record<string, any>
> {
constructor(c: HTTPClient, intDecoding: IntDecoding, private index: number) {
super(c, intDecoding);
this.index = index;
this.query.max = 0;
}
/**
* @returns `/v2/applications/${index}/boxes`
*/
path() {
return `/v2/applications/${this.index}/boxes`;
}
/**
* Limit results for pagination.
*
* #### Example
* ```typescript
* const maxResults = 20;
* const boxesResult = await algodClient
* .GetApplicationBoxes(1234)
* .limit(maxResults)
* .do();
* ```
*
* @param limit - maximum number of results to return.
* @category query
*/
max(max: number) {
this.query.max = max;
return this;
}
// eslint-disable-next-line class-methods-use-this
prepare(body: Record<string, any>): BoxesResponse {
return BoxesResponse.from_obj_for_encoding(body);
}
}