1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const guards_1 = require("../guards");
|
4 | const http_1 = require("./http");
|
5 | class SnapshotClient extends http_1.ResourceClient {
|
6 | constructor({ client, app, token }) {
|
7 | super();
|
8 | this.client = client;
|
9 | this.token = token;
|
10 | this.app = app;
|
11 | }
|
12 | async load(id) {
|
13 | const { req } = await this.client.make('GET', `/apps/${this.app.id}/snapshots/${id}`);
|
14 | this.applyAuthentication(req, this.token);
|
15 | const res = await this.client.do(req);
|
16 | if (!guards_1.isSnapshotResponse(res)) {
|
17 | throw http_1.createFatalAPIFormat(req, res);
|
18 | }
|
19 | return res.data;
|
20 | }
|
21 | paginate(args = {}) {
|
22 | return this.client.paginate({
|
23 | reqgen: async () => {
|
24 | const { req } = await this.client.make('GET', `/apps/${this.app.id}/snapshots`);
|
25 | this.applyAuthentication(req, this.token);
|
26 | return { req };
|
27 | },
|
28 | guard: guards_1.isSnapshotListResponse,
|
29 | });
|
30 | }
|
31 | }
|
32 | exports.SnapshotClient = SnapshotClient;
|