1 | const validate = require('./validate');
|
2 |
|
3 | module.exports = ({ instance, headers }) => {
|
4 | const url = `https://${instance}.zendesk.com`;
|
5 |
|
6 | return {
|
7 | set: (options = {}) => {
|
8 | const { error } = validate.set(options);
|
9 | if (error) throw new Error(error.details[0].message);
|
10 |
|
11 | const { user_id, data } = options;
|
12 | return {
|
13 | method: 'POST',
|
14 | url: `${url}/api/v2/users/${user_id}/password.json`,
|
15 | headers,
|
16 | data
|
17 | };
|
18 | },
|
19 |
|
20 | change: (options = {}) => {
|
21 | const { error } = validate.change(options);
|
22 | if (error) throw new Error(error.details[0].message);
|
23 |
|
24 | const { user_id, data } = options;
|
25 | return {
|
26 | method: 'PUT',
|
27 | url: `${url}/api/v2/users/${user_id}/password.json`,
|
28 | headers,
|
29 | data
|
30 | };
|
31 | },
|
32 |
|
33 | requirements: (options = {}) => {
|
34 | const { error } = validate.requirements(options);
|
35 | if (error) throw new Error(error.details[0].message);
|
36 |
|
37 | const { user_id } = options;
|
38 | return {
|
39 | method: 'GET',
|
40 | url: `${url}/api/v2/users/${user_id}/password/requirements.json`,
|
41 | headers
|
42 | };
|
43 | }
|
44 | };
|
45 | };
|