UNPKG

1.4 kBJavaScriptView Raw
1const Joi = require('@hapi/joi');
2const { validate, prepare } = require('../../utils/options');
3
4// Validation
5const _data = Joi.object();
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 Location Installations
17 *
18 * GET /api/v2/apps/location_installations.json
19 * https://developer.zendesk.com/rest_api/docs/support/app_location_installations#list-location-installations
20 */
21 list: () => {
22 // Ignore any options
23 return {
24 method: 'GET',
25 url: `${url}/api/v2/apps/location_installations.json`,
26 headers
27 };
28 },
29
30 /**
31 * Reorder App Installations For Location
32 *
33 * POST /api/v2/apps/location_installations/reorder.json
34 * https://developer.zendesk.com/rest_api/docs/support/app_location_installations#reorder-app-installations-for-location
35 */
36 reorder: (options = {}) => {
37 const { error } = Joi.object({
38 data: _data.required()
39 }).validate(options);
40 if (error) throw new Error(error.details[0].message);
41
42 const { data } = options;
43 return {
44 method: 'POST',
45 url: `${url}/api/v2/apps/location_installations/reorder.json`,
46 headers,
47 data
48 };
49 }
50 };
51};