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

Cleanup and update endpoints #42

Merged
merged 3 commits into from
Apr 12, 2018
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
84 changes: 36 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,77 +120,65 @@ timekit.getConfig();

## Usage (endpoints)

All the Timekit API endpoints are supported as methods. For endpoints taking parameters/data, the `data` argument should be an object with keys named as referenced in the docs - see: https://reference.timekit.io/
All the Timekit API endpoints are supported as methods. For endpoints taking parameters/data, the `data` argument should be an object with keys named as referenced in the docs - see: https://reference.timekit.io/reference/

If you supply keys as camelCased, they will automatically be converted to snake_case for you. Responses can also be converted to camelCase automatically if you set the config variable "convertResponseToCamelcase" to true.

Endpoints/methods:

```javascript
// Accounts endpoints
timekit.getAccounts();
timekit.accountGoogleSignup(data, shouldAutoRedirect:Boolean);
timekit.accountSync(data);
// App endpoints
timekit.getApp(data);

// Resource endpoints
timekit.getResources();
timekit.getResource(data);
timekit.createResource(data);
timekit.updateResource(data);
timekit.resetResourcePassword(data);
timekit.getResourceTimezone(data);

// FindTime endpoints
timekit.findTime(data);
timekit.findTimeBulk(data);
timekit.findTimeTeam(data);

// Booking endpoints
timekit.getBookings();
timekit.getBooking(data);
timekit.createBooking(data);
timekit.createBookingsBulk(data);
timekit.updateBooking(data);
timekit.updateBookingsBulk(data);
timekit.getGroupBookings();
timekit.getGroupBooking(data);

// Auth endpoints
// Auth endpoints (Note: only used to fetch a resource key)
timekit.auth(data);

// Apps endpoints
timekit.getApps();
timekit.getApp(data);
timekit.createApp(data);
timekit.updateApp(data);
timekit.deleteApp(data);
// Account endpoints
timekit.getAccounts();
timekit.accountGoogleSignup(data, shouldAutoRedirect:Boolean);
timekit.accountSync(data);

// Calendars endpoints
// Calendar endpoints
timekit.getCalendars();
timekit.getCalendar(data);
timekit.createCalendar(data);
timekit.updateCalendar(data);
timekit.deleteCalendar(data);

// Events endpoints
// Event endpoints
timekit.getEvents(data);
timekit.getEvent(data);
timekit.createEvent(data);
timekit.updateEvent(data);
timekit.deleteEvent(data);

// FindTime endpoints
timekit.findTime(data);
timekit.findTimeBulk(data);
timekit.findTimeTeam(data);
timekit.createFindTimeFilterCollection(data);
timekit.getFindTimeFilterCollections();
timekit.updateFindTimeFilterCollection(data);

// Users endpoints
timekit.createUser(data);
timekit.getUserInfo();
timekit.updateUser(data);
timekit.resetUserPassword(data);
timekit.getUserTimezone(data);

// Credentials endpoints
// Credential endpoints (Note: only used manage resource keys)
timekit.getCredentials();
timekit.createCredential(data);
timekit.deleteCredential(data);

// Bookings endpoints
timekit.getBookings();
timekit.getBooking(data);
timekit.createBooking(data);
timekit.updateBooking(data);
timekit.getGroupBookings();
timekit.getGroupBooking(data);

// Widget endpoints
timekit.getWidgets();
timekit.getWidget(data);
timekit.getHostedWidget(data);
timekit.getEmbedWidget(data);
timekit.createWidget(data);
timekit.updateWidget();
timekit.deleteWidget();
```

Request example:
Expand Down Expand Up @@ -236,7 +224,7 @@ Example:
```javascript

timekit.makeRequest({
url: '/endpoint/goes/here',
url: '/bookings',
method: 'post',
data: {
key: 'value'
Expand Down
125 changes: 125 additions & 0 deletions src/deprecated_endpoints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
module.exports = function (TK) {

/**
* Create a new user with the given properties
* @type {Function}
* @return {Promise}
*/
TK.createUser = function(data) {

return TK.makeRequest({
url: '/users',
method: 'post',
data: data
});

};

/**
* Fetch current user data from server
* @type {Function}
* @return {Promise}
*/
TK.getUserInfo = function() {

return TK.makeRequest({
url: '/users/me',
method: 'get'
});

};

/**
* Fetch current user data from server
* @type {Function}
* @return {Promise}
*/
TK.updateUser = function(data) {

return TK.makeRequest({
url: '/users/me',
method: 'put',
data: data
});

};

/**
* Reset password for a user
* @type {Function}
* @return {Promise}
*/
TK.resetUserPassword = function(data) {

return TK.makeRequest({
url: '/users/resetpassword',
method: 'post',
data: data
});

};

/**
* Get a specific users' timezone
* @type {Function}
* @return {Promise}
*/
TK.getUserTimezone = function(data) {

return TK.makeRequest({
url: '/users/timezone/' + data.email,
method: 'get'
});

};

/**
* Create a findtime filtercollection
* @type {Function}
* @return {Promise}
*/
TK.createFindTimeFilterCollection = function(data) {

return TK.makeRequest({
url: '/findtime/filtercollections',
method: 'post',
data: data
});

};

/**
* Get findtime filtercollections
* @type {Function}
* @return {Promise}
*/
TK.getFindTimeFilterCollections = function() {

return TK.makeRequest({
url: '/findtime/filtercollections',
method: 'get'
});

};

/**
* Update a findtime filtercollections
* @type {Function}
* @return {Promise}
*/
TK.updateFindTimeFilterCollection = function(data) {

var id = data.id;
delete data.id;

return TK.makeRequest({
url: '/findtime/filtercollections/' + id,
method: 'get',
data: data
});

};

return TK;

}
Loading