UNPKG

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