@cocalc/server
Version:
CoCalc server functionality: functions used by either the hub and the next.js server
26 lines • 1.09 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const zendesk_client_1 = __importDefault(require("./zendesk-client"));
const misc_1 = require("@cocalc/util/misc");
const util_1 = require("./util");
async function getTickets(account_id) {
if (!(0, misc_1.is_valid_uuid_string)(account_id)) {
return [];
}
const client = await (0, zendesk_client_1.default)();
// See https://developer.zendesk.com/api-reference/ticketing/ticket-management/search/
const query = `type:ticket external_id:${account_id}`;
// @ts-ignore
const result = await client.search.query(query);
for (const ticket of result) {
// ticket url is a JSON object, but we need a nice link that the user can click
// on to interact with the ticket.
ticket.userURL = (0, util_1.urlToUserURL)(ticket.url);
}
return result;
}
exports.default = getTickets;
//# sourceMappingURL=get-tickets.js.map