const axios = require("axios"); function WopiAPI() {} WopiAPI.prototype.getPassports = function(resourceID, contentType) { const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers; const requestConfig = { url: `${window.WOPI_URL}getPassports`, method: "POST", headers: { publicKey, uuid, token, deviceHash, resourceID: encodeURI(resourceID), contentType: encodeURI(contentType) } }; return axios(requestConfig); }; WopiAPI.prototype.putDocument = function(resourceID, accessToken, file) { const { publicKey, uuid, token, deviceHash } = window.viamApi.getConfig().headers; resourceID = encodeURI(resourceID); const requestConfig = { url: `${window.WOPI_URL}files/${resourceID}/contents`, method: "POST", headers: { publicKey, uuid, token, deviceHash }, params: { access_token: accessToken }, data: file }; return axios(requestConfig); }; module.exports = WopiAPI;