UNPKG

2.36 kBJavaScriptView Raw
1const Joi = require('@hapi/joi');
2const { validate, prepare } = require('../../utils/options');
3
4// Validation
5const _params = Joi.string().min(1);
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 * Incremental Attributes Export
17 *
18 * GET /api/v2/incremental/routing/attributes.json
19 * https://developer.zendesk.com/rest_api/docs/support/incremental_skill_based_routing#incremental-attributes-export
20 */
21 attributes: (options = {}) => {
22 const { error } = Joi.object({
23 params: _params
24 }).validate(options);
25 if (error) throw new Error(error.details[0].message);
26
27 const { params = '' } = options;
28 return {
29 method: 'GET',
30 url: `${url}/api/v2/incremental/routing/attributes.json${
31 params ? `?${params}` : ''
32 }`,
33 headers
34 };
35 },
36
37 /**
38 * Incremental Attribute Values Export
39 *
40 * GET /api/v2/incremental/routing/attribute_values.json
41 * https://developer.zendesk.com/rest_api/docs/support/incremental_skill_based_routing#incremental-attribute-values-export
42 */
43 attribute_values: (options = {}) => {
44 const { error } = Joi.object({
45 params: _params
46 }).validate(options);
47 if (error) throw new Error(error.details[0].message);
48
49 const { params = '' } = options;
50 return {
51 method: 'GET',
52 url: `${url}/api/v2/incremental/routing/attribute_values.json${
53 params ? `?${params}` : ''
54 }`,
55 headers
56 };
57 },
58
59 /**
60 * Incremental Instance Values Export
61 *
62 * GET /api/v2/incremental/routing/instance_values.json
63 * https://developer.zendesk.com/rest_api/docs/support/incremental_skill_based_routing#incremental-instance-values-export
64 */
65 instance_values: (options = {}) => {
66 const { error } = Joi.object({
67 params: _params
68 }).validate(options);
69 if (error) throw new Error(error.details[0].message);
70
71 const { params = '' } = options;
72 return {
73 method: 'GET',
74 url: `${url}/api/v2/incremental/routing/instance_values.json${
75 params ? `?${params}` : ''
76 }`,
77 headers
78 };
79 }
80 };
81};