UNPKG

1.26 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 * Show Settings
17 *
18 * GET /api/v2/account/settings.json
19 * https://developer.zendesk.com/rest_api/docs/support/account_settings#show-settings
20 */
21 show: () => {
22 // Ignore any options
23 return {
24 method: 'GET',
25 url: `${url}/api/v2/account/settings.json`,
26 headers
27 };
28 },
29
30 /**
31 * Update Account Settings
32 *
33 * PUT /api/v2/account/settings.json
34 * https://developer.zendesk.com/rest_api/docs/support/account_settings#update-account-settings
35 */
36 update: (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: 'PUT',
45 url: `${url}/api/v2/account/settings.json`,
46 headers,
47 data
48 };
49 }
50 };
51};