motionlink-cli
Version:
Making it easy to use Notion as a Content Management system for personal websites, portfolios, blogs, business homepages, and other kinds of static websites.
44 lines • 1.65 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = __importDefault(require("axios"));
class MotionLinkApi {
getNotionTokenForLink(linkAccessKey) {
const accessKeyAsToken = {
token: linkAccessKey,
};
return this.callHttpFunction('getNotionTokenForLink', accessKeyAsToken);
}
async getNotionDatabaseIdForLink(linkAccessKey) {
const accessKeyAsToken = {
token: linkAccessKey,
};
const response = await this.callHttpFunction('getNotionDatabaseIdForLink', accessKeyAsToken);
return response.value;
}
async callHttpFunction(name, body) {
const endpoint = `https://us-central1-motionlink-aec23.cloudfunctions.net/cli_tool_service-api/${name}`;
try {
const response = await axios_1.default.post(endpoint, { data: body });
return response.data.data;
}
catch (e) {
const error = e;
if (error.response && error.response.status === 500) {
// Server reports all errors with 500 status code
throw new Error(`${error.response.data.message}`);
}
else {
throw e;
}
}
}
static get instance() {
var _a;
return (_a = this._instance) !== null && _a !== void 0 ? _a : (this._instance = new MotionLinkApi());
}
}
exports.default = MotionLinkApi;
//# sourceMappingURL=motion_link_api.js.map