-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const endpoint = require('../../../../src/api/sunshine/object_events'); | ||
const { prepare } = require('../../../../src/utils/options'); | ||
|
||
describe('object records', () => { | ||
let endPoint, options, url, headers; | ||
|
||
beforeEach(() => { | ||
options = { | ||
instance: 'instance', | ||
email: 'user@email.com', | ||
token: 'token' | ||
}; | ||
endPoint = endpoint(options); | ||
({ url, headers } = prepare(options)); | ||
}); | ||
|
||
afterEach(() => { | ||
options = null; | ||
endPoint = null; | ||
url = null; | ||
headers = null; | ||
}); | ||
|
||
describe('init', () => { | ||
it('should setup endpoint object', () => { | ||
const ep = endpoint(options); | ||
expect(ep).toBeTruthy(); | ||
}); | ||
|
||
it('should fail with invalid input', () => { | ||
expect(() => endpoint()).toThrowError(); | ||
expect(() => endpoint({})).toThrowError(); | ||
}); | ||
}); | ||
|
||
describe('List Custom Objects Events', () => { | ||
it('should process valid input', () => { | ||
expect(endPoint.list()).toEqual({ | ||
method: 'GET', | ||
url: `${url}/api/sunshine/objects/events`, | ||
headers | ||
}); | ||
}); | ||
}); | ||
}); |