@androozka/zendesk-api-js
Version:
A JS library for interacting with the Zendesk API.
33 lines (27 loc) • 760 B
JavaScript
const validate = require('./validate');
module.exports = ({ instance, headers }) => {
const url = `https://${instance}.zendesk.com`;
return {
show: (options = {}) => {
const { error } = validate.show(options);
if (error) throw new Error(error.details[0].message);
const { id } = options;
return {
method: 'GET',
url: `${url}/api/v2/end_users/${id}.json`,
headers
};
},
update: (options = {}) => {
const { error } = validate.update(options);
if (error) throw new Error(error.details[0].message);
const { id, data } = options;
return {
method: 'PUT',
url: `${url}/api/v2/end_users/${id}.json`,
headers,
data
};
}
};
};