UNPKG

@point-api/js-sdk

Version:

Javascript SDK for Point API

30 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** Class to keep track of api credentials and make requests to the custom suggestions api */ class SnippetApiModule { constructor(api) { this.url = "/snippets"; this.api = api; } /** Get custom suggestions and hotkeys */ async get() { return this.authFetch("GET"); } /** Delete a custom suggestion or hotkey */ async delete(snippetId) { return this.authFetch("DELETE", { snippetId }); } async edit(snippetId, newContent, newName, labels) { return this.authFetch("PUT", { snippetId, newContent, newName, labels }); } /** Add a custom suggestion or hotkey */ async add(content, name, labels) { return this.authFetch("POST", { name, content, labels }); } /** Make authenticated request to custom suggestions api */ async authFetch(method, data) { return (await this.api.authFetch(method, this.url, data)).json(); } } exports.default = SnippetApiModule; //# sourceMappingURL=snippets.js.map