41 lines
1 KiB
JavaScript
41 lines
1 KiB
JavaScript
|
import SwaggerClient from "swagger-client";
|
||
|
|
||
|
const url = String(new URL("/api/", document.baseURI));
|
||
|
|
||
|
const api = new SwaggerClient(url);
|
||
|
|
||
|
api.then(
|
||
|
(client) => (window.client = client),
|
||
|
(reason) => console.error("Failed to load OpenAPI spec: " + reason)
|
||
|
);
|
||
|
|
||
|
function getScene(uuid) {
|
||
|
return api
|
||
|
.then(
|
||
|
(client) => client.apis.tours.tours_api_scenes_retrieve({ id: uuid }),
|
||
|
(reason) => console.error("Failed to load OpenAPI spec: " + reason)
|
||
|
)
|
||
|
.then(
|
||
|
(result) => result,
|
||
|
(reason) => console.error("Failed to execute API call: " + reason)
|
||
|
);
|
||
|
}
|
||
|
|
||
|
function getSceneElement(scene_uuid, uuid) {
|
||
|
return api
|
||
|
.then(
|
||
|
(client) =>
|
||
|
client.apis.tours.tours_api_scene_elements_retrieve({
|
||
|
scene: scene_uuid,
|
||
|
id: uuid,
|
||
|
}),
|
||
|
(reason) => console.error("Failed to load OpenAPI spec: " + reason)
|
||
|
)
|
||
|
.then(
|
||
|
(result) => result,
|
||
|
(reason) => console.error("Failed to execute API call: " + reason)
|
||
|
);
|
||
|
}
|
||
|
|
||
|
export { getScene, getSceneElement };
|