testrail-modern-client
Version:
A modern TypeScript client for TestRail API
55 lines (54 loc) • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TemplateService = void 0;
const base_1 = require("./base");
/**
* Service for interacting with TestRail templates (field layouts).
* @since TestRail 5.2
*/
class TemplateService extends base_1.BaseService {
/**
* Returns a list of available templates for a project.
* @param projectId - The ID of the project
* @param offset - Optional pagination offset
* @param limit - Optional pagination limit
* @returns List of templates
* @throws {Error} - If the project is invalid or unknown (400)
* @throws {Error} - If there is no access to the project (403)
* @throws {Error} - If too many requests are made (429) - TestRail Cloud only
*/
async list(projectId) {
const response = await this.client.get(`/get_templates/${projectId}`);
return response.data;
}
/**
* Returns an existing template.
* @param templateId - The ID of the template
* @returns The requested template
*/
async get(templateId) {
const response = await this.client.get(`/templates/${templateId}`);
return response.data;
}
/**
* Creates a new template.
*/
async add(projectId, template) {
const response = await this.client.post(`/projects/${projectId}/templates`, template);
return response.data;
}
/**
* Updates an existing template.
*/
async update(templateId, template) {
const response = await this.client.post(`/templates/${templateId}`, template);
return response.data;
}
/**
* Deletes an existing template.
*/
async delete(templateId) {
await this.client.post(`/templates/${templateId}`);
}
}
exports.TemplateService = TemplateService;