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 7 #93

Merged
merged 12 commits into from
Feb 1, 2020
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,19 @@ 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 Activities, Tags, Views, Ticket Forms, Ticket Fields, User Fields, Organization Fields, Job Statuses, Audit Logs
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

### Sunshine API

Custom Object Types, Custom Object Records, Relationship Types, Relationship Records
Custom Object Types, Custom Object Records, Relationship Types, Relationship Records, Custom Objects Events

### Under Construction

#### Support

- [ ] Brands
- [ ] User Identities
- [ ] User Passwords
- [ ] Requests
- [ ] Ticket Metric Events
- [ ] Attachments
- [ ] Sessions
- [ ] Triggers
Expand All @@ -109,28 +107,20 @@ Custom Object Types, Custom Object Records, Relationship Types, Relationship Rec
- [ ] Dynamic Content
- [ ] Locales
- [ ] Schedules
- [ ] Sharing Agreements
- [ ] Support Addresses
- [ ] Skill-based Routing
- [ ] Incremental Skill-based Routing
- [ ] Workspaces
- [ ] Apps
- [ ] App Installation Locations
- [ ] App Locations
- [ ] OAuth Clients
- [ ] OAuth Tokens
- [ ] OAuth Tokens for Grant Types
- [ ] Authorized Global Clients
- [ ] Account Settings
- [ ] Bookmarks
- [ ] Push Notification Devices
- [ ] Resource Collections
- [ ] Channel Framework
- [ ] Twitter Channel

#### Sunshine

- [ ] Custom Objects Events
- [ ] Jobs
- [ ] Limits
- [ ] Events
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"src/*"
],
"dependencies": {
"@hapi/joi": "^16.1.1",
"@hapi/joi": "^17.1.0",
"js-base64": "^2.5.1"
},
"devDependencies": {
"@types/jest": "^24.0.18",
"eslint": "^6.4.0",
"eslint-plugin-jest": "^22.17.0",
"jest": "^24.9.0"
"eslint-plugin-jest": "^23.6.0",
"jest": "^25.1.0"
}
}
31 changes: 31 additions & 0 deletions src/api/sunshine/object_events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// const Joi = require('@hapi/joi');
const { validate, prepare } = require('../../utils/options');

// Validation
// const _id = Joi.number().positive();
// 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 Custom Objects Events
*
* GET api/sunshine/objects/events
* https://developer.zendesk.com/rest_api/docs/sunshine/object_events#list-custom-objects-events
*/
list: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/sunshine/objects/events`,
headers
};
}
};
};
51 changes: 51 additions & 0 deletions src/api/support/account_settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const Joi = require('@hapi/joi');
const { validate, prepare } = require('../../utils/options');

// Validation
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 {
/**
* Show Settings
*
* GET /api/v2/account/settings.json
* https://developer.zendesk.com/rest_api/docs/support/account_settings#show-settings
*/
show: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/account/settings.json`,
headers
};
},

/**
* Update Account Settings
*
* PUT /api/v2/account/settings.json
* https://developer.zendesk.com/rest_api/docs/support/account_settings#update-account-settings
*/
update: (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/account/settings.json`,
headers,
data
};
}
};
};
51 changes: 51 additions & 0 deletions src/api/support/app_installation_locations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const Joi = require('@hapi/joi');
const { validate, prepare } = require('../../utils/options');

// Validation
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 Location Installations
*
* GET /api/v2/apps/location_installations.json
* https://developer.zendesk.com/rest_api/docs/support/app_location_installations#list-location-installations
*/
list: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/apps/location_installations.json`,
headers
};
},

/**
* Reorder App Installations For Location
*
* POST /api/v2/apps/location_installations/reorder.json
* https://developer.zendesk.com/rest_api/docs/support/app_location_installations#reorder-app-installations-for-location
*/
reorder: (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/apps/location_installations/reorder.json`,
headers,
data
};
}
};
};
157 changes: 157 additions & 0 deletions src/api/support/brands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
const Joi = require('@hapi/joi');
const { validate, prepare } = require('../../utils/options');

// Validation
const _id = Joi.number().min(1);
const _host_mapping = Joi.string().min(1);
const _subdomain = 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 Brands
*
* GET /api/v2/brands.json
* https://developer.zendesk.com/rest_api/docs/support/brands#list-brands
*/
list: () => {
// Ignore any options
return {
method: 'GET',
url: `${url}/api/v2/brands.json`,
headers
};
},

/**
* Show a Brand
*
* GET /api/v2/brands/{id}.json
* https://developer.zendesk.com/rest_api/docs/support/brands#show-a-brand
*/
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/brands/${id}.json`,
headers
};
},

/**
* Create Brand
*
* POST /api/v2/brands.json
* https://developer.zendesk.com/rest_api/docs/support/brands#create-brand
*/
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/brands.json`,
headers,
data
};
},

/**
* Update a Brand
*
* PUT /api/v2/brands/{id}.json
* https://developer.zendesk.com/rest_api/docs/support/brands#update-a-brand
*/
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/brands/${id}.json`,
headers,
data
};
},

/**
* Delete a Brand
*
* DELETE /api/v2/tickets/{id}.json
* https://developer.zendesk.com/rest_api/docs/support/brands#delete-a-brand
*/
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/brands/${id}.json`,
headers
};
},

/**
* Check host mapping validity
*
* GET /api/v2/brands/check_host_mapping.json?host_mapping={host_mapping}&subdomain={subdomain}
* https://developer.zendesk.com/rest_api/docs/support/brands#check-host-mapping-validity
*/
check: (options = {}) => {
const { error } = Joi.object({
host_mapping: _host_mapping.required(),
subdomain: _subdomain.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

const { host_mapping, subdomain } = options;
return {
method: 'GET',
url: `${url}/api/v2/brands/check_host_mapping.json?host_mapping=${host_mapping}&subdomain=${subdomain}`,
headers
};
},

/**
* Check host mapping validity for an existing brand
*
* GET /api/v2/brands/{id}/check_host_mapping.json
* https://developer.zendesk.com/rest_api/docs/support/brands#check-host-mapping-validity-for-an-existing-brand
*/
check_existing: (options = {}) => {
const { error } = Joi.object({
id: _id.required()
}).validate(options);
if (error) throw new Error(error.details[0].message);

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