UNPKG

paradigm-core

Version:
94 lines (79 loc) 2.58 kB
class TestAPI { constructor(server) { this.server = server } async get(orgId, appId, docId) { return await this.server .get(`/api/${process.env.API_VERSION}/documents/${docId}`) .set('organizationid', orgId) .set('applicationid', appId) } async getAll(orgId, appId, query={}) { return await this.server .get(`/api/${process.env.API_VERSION}/documents`) .set('organizationid', orgId) .set('applicationid', appId) .query(query) } async getAllByUser(orgId, appId, userId, query={}) { return await this.server .get(`/api/${process.env.API_VERSION}/documents/user/${userId}`) .set('organizationid', orgId) .set('applicationid', appId) .query(query) } async create(orgId, appId, pkg) { return await this.server .post(`/api/${process.env.API_VERSION}/documents`) .set('organizationid', orgId) .set('applicationid', appId) .send(pkg) } async update(orgId, appId, docId, pkg={}) { return await this.server .patch(`/api/${process.env.API_VERSION}/documents/${docId}`) .set('organizationid', orgId) .set('applicationid', appId) .send(pkg) } async updateMany(orgId, appId, pkg=[]) { return await this.server .patch(`/api/${process.env.API_VERSION}/documents`) .set('organizationid', orgId) .set('applicationid', appId) .send(pkg) } async publish(orgId, appId, docId) { return await this.server .post(`/api/${process.env.API_VERSION}/documents/${docId}/publish`) .set('organizationid', orgId) .set('applicationid', appId) .send() } async unpublish(orgId, appId, docId) { return await this.server .post(`/api/${process.env.API_VERSION}/documents/${docId}/unpublish`) .set('organizationid', orgId) .set('applicationid', appId) .send() } async delete(orgId, appId, docId) { return await this.server .delete(`/api/${process.env.API_VERSION}/documents/${docId}`) .set('organizationid', orgId) .set('applicationid', appId) } async purge(orgId, appId, docId) { return await this.server .post(`/api/${process.env.API_VERSION}/documents/${docId}/purge`) .set('organizationid', orgId) .set('applicationid', appId) } async existence(orgId, appId, key, value) { return await this.server .get(`/api/${process.env.API_VERSION}/documents/existence/${key}/${value}`) .set('organizationid', orgId) .set('applicationid', appId) } } module.exports = TestAPI