1 | const Joi = require('@hapi/joi');
|
2 | const { validate, prepare } = require('../../utils/options');
|
3 |
|
4 |
|
5 | const _id = 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: () => {
|
22 |
|
23 | return {
|
24 | method: 'GET',
|
25 | url: `${url}/api/v2/target_failures.json`,
|
26 | headers
|
27 | };
|
28 | },
|
29 |
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | show: (options = {}) => {
|
37 | const { error } = Joi.object({
|
38 | id: _id.required()
|
39 | }).validate(options);
|
40 | if (error) throw new Error(error.details[0].message);
|
41 |
|
42 | const { id } = options;
|
43 | return {
|
44 | method: 'GET',
|
45 | url: `${url}/api/v2/target_failures/${id}.json`,
|
46 | headers
|
47 | };
|
48 | }
|
49 | };
|
50 | };
|