snapshot.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.SnapshotClient = void 0;
  4. const guards_1 = require("../guards");
  5. const http_1 = require("./http");
  6. class 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 (!(0, guards_1.isSnapshotResponse)(res)) {
  18. throw (0, 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. }
  33. exports.SnapshotClient = SnapshotClient;