UNPKG

draaft

Version:

A CLI to pull content from https://pilot.pm content collaboration platform and feed your static site generator with markdown files

72 lines (71 loc) 2.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const axios_1 = require("axios"); //https://github.com/matt-major/do-wrapper/blob/3bb0d1dbfaa7dc1188a3567321c7def40a8df74a/src/do-wrapper.js#L271 //https://github.com/matt-major/do-wrapper/blob/3bb0d1dbfaa7dc1188a3567321c7def40a8df74a/src/request-helper.js#L19 class DraaftAPI { /** * Draaft API Wrapper * @param config - Draaft configuration */ constructor(config) { this.config = config; this.httpclient = axios_1.default.create({ baseURL: config.apiBaseUrl, headers: { Authorization: `Token ${config.apiToken}`, }, }); } async get(endpoint, query) { let response = await this.httpclient({ url: endpoint, method: "GET", params: query, }); return response.data; } /** * Get all channels * Info {@link https://www.draaft.io/documentation/api/beta/#channels channels} */ channelsGetAll(query) { return this.get("channels", query); } /** * Get one channel by id * Info {@link https://www.draaft.io/documentation/api/beta/#channels channels} */ channelsGetOne(id, query) { return this.get(`channels/${id}`, query); } /** * Get items list * Info {@link https://www.draaft.io/documentation/api/beta/#items items} */ itemsGetAll(query) { return this.get("items", query); } /** * Get wokflow states list * Info {@link https://www.draaft.io/documentation/api/beta/#workflow workflow} */ workflowGetAll(query) { return this.get("workflow_states", query); } /** * Get item types list * Info {@link https://www.draaft.io/documentation/api/beta/#types types} */ typesGetAll(query) { return this.get("item_types", query); } /** * Get one item type by id * Info {@link https://www.draaft.io/documentation/api/beta/#types types} */ typesGetOne(id, query) { return this.get(`item_types/${id}`, query); } } exports.default = DraaftAPI;