UNPKG

quip-api-typescript

Version:

This is the unofficial and incomplete, but TypeScript-compatible and promise-based library to access the [Quip Automation API](https://quip.com/api/).

106 lines (91 loc) 3.65 kB
import axios from 'axios'; /** @internal */ var addMembersToThreadOrAddThreadToFolders = function (post) { return function (props) { // REQUEST BODY SCHEMA: application/x-www-form-urlencoded var body = props.body; return post("1/threads/add-members", new URLSearchParams(body)); }; }; /** @internal */ var copyADocumentOrTemplateV2 = function (post) { return function (props) { // REQUEST BODY SCHEMA: application/json var threadIdOrSecretPath = props.threadIdOrSecretPath, body = props.body; return post("2/threads/".concat(threadIdOrSecretPath, "/copy"), body); }; }; /** @internal */ var createADocumentOrSpreadsheet = function (post) { return function (props) { // REQUEST BODY SCHEMA: application/x-www-form-urlencoded var body = props.body; return post("1/threads/new-document", new URLSearchParams(body)); }; }; /** @internal */ var editADocument = function (post) { return function (props) { // REQUEST BODY SCHEMA: application/x-www-form-urlencoded var body = props.body; return post("1/threads/edit-document", new URLSearchParams(body)); }; }; /** @internal */ var getThreadHtmlV2 = function (get) { return function (props) { var id = props.id; return get("2/threads/".concat(id, "/html")); }; }; /** @internal */ var getThreadMembersV2 = function (get) { return function (props) { var threadIdOrSecretPath = props.threadIdOrSecretPath; // TODO: implement query parameters return get("2/threads/".concat(threadIdOrSecretPath, "/members")); }; }; /** @internal */ var getThreadV2 = function (get) { return function (props) { var id = props.id; return get("2/threads/".concat(id)); }; }; var ThreadsAPI = /** @class */ (function () { /** @internal */ function ThreadsAPI(get, post) { this.addMembersToThreadOrAddThreadToFolders = addMembersToThreadOrAddThreadToFolders(post); this.copyADocumentOrTemplateV2 = copyADocumentOrTemplateV2(post); this.createADocumentOrSpreadsheet = createADocumentOrSpreadsheet(post); this.editADocument = editADocument(post); this.getThreadHtmlV2 = getThreadHtmlV2(get); this.getThreadMembersV2 = getThreadMembersV2(get); this.getThreadV2 = getThreadV2(get); } return ThreadsAPI; }()); /** @internal */ var getUser = function (get) { return function (props) { var id = props.id; return get("1/users/".concat(id)); }; }; var UsersAPI = /** @class */ (function () { /** @internal */ function UsersAPI(get) { this.getUser = getUser(get); } return UsersAPI; }()); /** @internal */ var getFolder = function (get) { return function (props) { var id = props.id; return get("1/folders/".concat(id)); }; }; var FoldersAPI = /** @class */ (function () { /** @internal */ function FoldersAPI(get) { this.getFolder = getFolder(get); } return FoldersAPI; }()); var QuipClient = /** @class */ (function () { function QuipClient(accessToken, urlBase) { if (urlBase === void 0) { urlBase = 'https://platform.quip.com/'; } var axiosConfig = { headers: { Authorization: 'Bearer ' + accessToken } }; var get = function (path) { return axios.get(urlBase + path, axiosConfig).then(function (response) { return response.data; }); }; var post = function (path, data) { return axios.post(urlBase + path, data, axiosConfig).then(function (response) { return response.data; }); }; this.threads = new ThreadsAPI(get, post); this.users = new UsersAPI(get); this.folders = new FoldersAPI(get); } return QuipClient; }()); export { QuipClient };