UNPKG

1.01 kBJavaScriptView Raw
1const Joi = require('@hapi/joi');
2const { validate, prepare } = require('../../utils/options');
3
4// Validation
5const _unix_time = Joi.number().positive();
6
7// Initialize Endpoint
8module.exports = (options = {}) => {
9 const { error } = validate(options);
10 if (error) throw new Error(error.details[0].message);
11
12 const { url, headers } = prepare(options);
13
14 return {
15 /**
16 * List ticket metric events
17 *
18 * GET /api/v2/incremental/ticket_metric_events.json?start_time={unix_time}
19 * https://developer.zendesk.com/rest_api/docs/support/ticket_metric_events#list-ticket-metric-events
20 */
21 list: (options = {}) => {
22 const { error } = Joi.object({
23 unix_time: _unix_time.required()
24 }).validate(options);
25 if (error) throw new Error(error.details[0].message);
26
27 const { unix_time } = options;
28 return {
29 method: 'GET',
30 url: `${url}/api/v2/incremental/ticket_metric_events.json?start_time=${unix_time}`,
31 headers
32 };
33 }
34 };
35};