@gaiot/apis
Version:
aiot apis
137 lines (136 loc) • 3.37 kB
JavaScript
var s = (o, t, e) => new Promise((a, n) => {
var p = (r) => {
try {
i(e.next(r));
} catch (c) {
n(c);
}
}, u = (r) => {
try {
i(e.throw(r));
} catch (c) {
n(c);
}
}, i = (r) => r.done ? a(r.value) : Promise.resolve(r.value).then(p, u);
i((e = e.apply(o, t)).next());
});
import d from "axios";
import { BaseApi as w } from "../base/index.mjs";
class k extends w {
constructor(t, e) {
super(t != null ? t : d.create(), e);
}
static parseApiToken(t) {
const e = window.atob(t.split(".")[1]);
return JSON.parse(e);
}
static loadApiToken(t, e, a) {
return s(this, null, function* () {
return fetch(`${t}${e}/viewtoken/${a}/create_apitoken`, {
method: "POST"
}).then((n) => {
if (n.status !== 200)
throw console.error(n), Error(JSON.stringify(n));
return n.json();
}).then((n) => {
if (n.code !== 200)
throw Error(JSON.stringify(n));
return n.data.apiToken;
});
});
}
listRecord(t) {
return s(this, null, function* () {
return this.listPaged("/spacetwins", t);
});
}
postRecord(t) {
return s(this, null, function* () {
return this.post("/spacetwins", t);
});
}
getRecordOverview(t) {
return s(this, null, function* () {
return this.get(`/spacetwins/${t}`);
});
}
getRecordViewtoken(t) {
return s(this, null, function* () {
return this.get(`/spacetwins/${t}/viewtoken`);
});
}
listScene(t) {
return s(this, null, function* () {
return this.list(`/spacetwins/${t}/scenes`);
});
}
getScenesByTimestamp(t, e) {
return s(this, null, function* () {
return this.list(`/spacetwins/${t}/scenes_timestamp`, {
timestamp: e
});
});
}
recomputeTrack(t, e) {
return s(this, null, function* () {
return this.patch(`/spacetwins/${t}/track`, {
points: e
});
});
}
updateRecordUploadStatus(t, e) {
return s(this, null, function* () {
return this.post(`/spacetwins/${t}/update_upload_status`, e);
});
}
getApiToken(t) {
return s(this, null, function* () {
return this.post(`/viewtoken/${t}/create_apitoken`, {});
});
}
getSpacetwins(t) {
return s(this, null, function* () {
return this.listPaged("/spacetwins", t);
});
}
postSpacetwins(t) {
return s(this, null, function* () {
return this.post("/spacetwins", t);
});
}
updateInspection(t, e) {
return s(this, null, function* () {
return this.patch(`/patrolInspection/${t}`, e);
});
}
getSpacetwinsIdViewtoken(t) {
return s(this, null, function* () {
return this.get(`/spacetwins/${t}/viewtoken`);
});
}
postSpacetwinsIdUpdateUploadStatus(t, e) {
return s(this, null, function* () {
return this.post(`/spacetwins/${t}/update_upload_status`, e);
});
}
postUploadTicket(t) {
return s(this, null, function* () {
return this.post("/upload/ticket", t);
});
}
getDownloadUrl(t) {
return s(this, null, function* () {
return this.get(`/download/url?isv=${t.isv}&key=${t.key}`);
});
}
listTrack(t, e) {
return s(this, null, function* () {
return this.list(`/spacetwins/${t}/track`, {
type: e
});
});
}
}
export {
k as PanoramaApi
};