1 | const Joi = require('@hapi/joi');
|
2 | const { validate, prepare } = require('../../utils/options');
|
3 |
|
4 |
|
5 | const _unix_time = Joi.number().positive();
|
6 |
|
7 |
|
8 | module.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 |
|
17 |
|
18 |
|
19 |
|
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 | };
|