Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 8 #94

Merged
merged 8 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ try {

### Support API

Search, Users, End Users, Groups, Group Memberships, Custom Agent Roles, Organizations, Organization Subscriptions, Organization Memberships, Tickets, Ticket Import, Satisfaction Ratings, Satisfaction Reasons, Suspended Tickets, Ticket Audits, Ticket Comments, Ticket Skips, Ticket Metrics, Ticket Metric Events, Ticket Activities, Tags, Views, Brands, Sharing Agreements, Support Addresses, Ticket Forms, Ticket Fields, User Fields, Organization Fields, Job Statuses, Incremental Skill-based Routing, Workspaces, App Installation Locations, Account Settings, Audit Logs, Twitter Channel
Search, Users, End Users, Groups, Group Memberships, Custom Agent Roles, Organizations, Organization Subscriptions, Organization Memberships, Tickets, Ticket Import, Satisfaction Ratings, Satisfaction Reasons, Suspended Tickets, Ticket Audits, Ticket Comments, Ticket Skips, Ticket Metrics, Ticket Metric Events, Ticket Activities, Tags, Views, Automations, SLA Policies, Targets, Target Failures, Brands, Locales, Schedules, Sharing Agreements, Support Addresses, Ticket Forms, Ticket Fields, User Fields, Organization Fields, Job Statuses, Incremental Skill-based Routing, Workspaces, App Installation Locations, App Locations, Account Settings, Audit Logs, Bookmarks, Twitter Channel

### Sunshine API

Expand All @@ -99,22 +99,14 @@ Custom Object Types, Custom Object Records, Relationship Types, Relationship Rec
- [ ] Attachments
- [ ] Sessions
- [ ] Triggers
- [ ] Automations
- [ ] SLA Policies
- [ ] Targets
- [ ] Target Failures
- [ ] Macros
- [ ] Dynamic Content
- [ ] Locales
- [ ] Schedules
- [ ] Skill-based Routing
- [ ] Apps
- [ ] App Locations
- [ ] OAuth Clients
- [ ] OAuth Tokens
- [ ] OAuth Tokens for Grant Types
- [ ] Authorized Global Clients
- [ ] Bookmarks
- [ ] Push Notification Devices
- [ ] Resource Collections
- [ ] Channel Framework
Expand Down
50 changes: 50 additions & 0 deletions src/api/support/app_locations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const Joi = require('@hapi/joi');
const { validate, prepare } = require('../../utils/options');

// Validation
const _id = Joi.number().positive();

// Initialize Endpoint
module.exports = (options = {}) => {
const { error } = validate(options);
if (error) throw new Error(error.details[0].message);

const { url, headers } = prepare(options);

return {
/**
* List Locations
*
* GET /api/v2/apps/locations.json
* https://developer.zendesk.com/rest_api/docs/support/app_locations#list-locations
*/
list: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/apps/locations.json`,
headers
};
},

/**
* Show Location
*
* GET /api/v2/apps/locations/{id}.json
* https://developer.zendesk.com/rest_api/docs/support/app_locations#show-location
*/
show: (options = {}) => {
const { error } = Joi.object({
id: _id.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { id } = options;
return {
method: 'GET',
url: `${url}/api/v2/apps/locations/${id}.json`,
headers
};
}
};
};
192 changes: 192 additions & 0 deletions src/api/support/automations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
const Joi = require('@hapi/joi');
const { validate, prepare } = require('../../utils/options');

// Validation
const _id = Joi.number().min(1);
const _ids = Joi.string().min(1);
const _query = Joi.string().min(1);
const _data = Joi.object();

// Initialize Endpoint
module.exports = (options = {}) => {
const { error } = validate(options);
if (error) throw new Error(error.details[0].message);

const { url, headers } = prepare(options);

return {
/**
* List Automations
*
* GET /api/v2/automations.json
* https://developer.zendesk.com/rest_api/docs/support/automations#list-automations
*/
list: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/automations.json`,
headers
};
},

/**
* Show Automation
*
* GET /api/v2/automations/{id}.json
* https://developer.zendesk.com/rest_api/docs/support/automations#show-automation
*/
show: (options = {}) => {
const { error } = Joi.object({
id: _id.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { id } = options;
return {
method: 'GET',
url: `${url}/api/v2/automations/${id}.json`,
headers
};
},

/**
* List Active Automations
*
* GET /api/v2/automations/active.json
* https://developer.zendesk.com/rest_api/docs/support/automations#list-active-automations
*/
active: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/automations/active.json`,
headers
};
},

/**
* Create Automation
*
* POST /api/v2/automations.json
* https://developer.zendesk.com/rest_api/docs/support/automations#create-automation
*/
create: (options = {}) => {
const { error } = Joi.object({
data: _data.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { data } = options;
return {
method: 'POST',
url: `${url}/api/v2/automations.json`,
headers,
data
};
},

/**
* Update Automation
*
* PUT /api/v2/automations/{id}.json
* https://developer.zendesk.com/rest_api/docs/support/automations#update-automation
*/
update: (options = {}) => {
const { error } = Joi.object({
id: _id.required(),
data: _data.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { id, data } = options;
return {
method: 'PUT',
url: `${url}/api/v2/automations/${id}.json`,
headers,
data
};
},

/**
* Update Many Automations
*
* PUT /api/v2/automations/update_many.json
* https://developer.zendesk.com/rest_api/docs/support/automations#update-many-automations
*/
update_many: (options = {}) => {
const { error } = Joi.object({
data: _data.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { data } = options;
return {
method: 'PUT',
url: `${url}/api/v2/automations/update_many.json`,
headers,
data
};
},

/**
* Delete Automation
*
* DELETE /api/v2/automations/{id}.json
* https://developer.zendesk.com/rest_api/docs/support/automations#delete-automation
*/
delete: (options = {}) => {
const { error } = Joi.object({
id: _id.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { id } = options;
return {
method: 'DELETE',
url: `${url}/api/v2/automations/${id}.json`,
headers
};
},

/**
* Bulk Delete Automations
*
* DELETE /api/v2/automations/destroy_many.json
* https://developer.zendesk.com/rest_api/docs/support/automations#bulk-delete-automations
*/
delete_bulk: (options = {}) => {
const { error } = Joi.object({
ids: _ids.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { ids } = options;
return {
method: 'DELETE',
url: `${url}/api/v2/automations/destroy_many.json?ids=${ids}`,
headers
};
},

/**
* Search Automations
*
* GET /api/v2/automations/search.json
* https://developer.zendesk.com/rest_api/docs/support/automations#search-automations
*/
search: (options = {}) => {
const { error } = Joi.object({
query: _query.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { query } = options;
return {
method: 'GET',
url: `${url}/api/v2/automations/search.json?query=${query}`,
headers
};
}
};
};
117 changes: 117 additions & 0 deletions src/api/support/locales.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
const Joi = require('@hapi/joi');
const { validate, prepare } = require('../../utils/options');

// Validation
const _id = Joi.number().min(1);
const _data = Joi.object();

// Initialize Endpoint
module.exports = (options = {}) => {
const { error } = validate(options);
if (error) throw new Error(error.details[0].message);

const { url, headers } = prepare(options);

return {
/**
* List Locales
*
* GET /api/v2/locales.json
* https://developer.zendesk.com/rest_api/docs/support/locales#list-locales
*/
list: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/locales.json`,
headers
};
},

/**
* List Available Public Locales
*
* GET /api/v2/locales/public.json
* https://developer.zendesk.com/rest_api/docs/support/locales#list-available-public-locales
*/
public: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/locales/public.json`,
headers
};
},

/**
* List Locales for Agent
*
* GET /api/v2/locales/agent.json
* https://developer.zendesk.com/rest_api/docs/support/locales#list-locales-for-agent
*/
agent: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/locales/agent.json`,
headers
};
},

/**
* Show Locale
*
* GET /api/v2/locales/{id}.json
* https://developer.zendesk.com/rest_api/docs/support/locales#show-locale
*/
show: (options = {}) => {
const { error } = Joi.object({
id: _id.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { id } = options;
return {
method: 'GET',
url: `${url}/api/v2/locales/${id}.json`,
headers
};
},

/**
* Show Current Locale
*
* GET /api/v2/locales/current.json
* https://developer.zendesk.com/rest_api/docs/support/locales#show-current-locale
*/
current: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/locales/current.json`,
headers
};
},

/**
* Detect best language for user
*
* GET /api/v2/locales/detect_best_locale.json
* https://developer.zendesk.com/rest_api/docs/support/locales#detect-best-language-for-user
*/
detect: (options = {}) => {
const { error } = Joi.object({
data: _data.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { data } = options;
return {
method: 'GET',
url: `${url}/api/v2/locales/detect_best_locale.json`,
headers,
data
};
}
};
};
Loading