Technology moves fast! ⚡ Don't get left behind.🚶 Subscribe to our mailing list to keep up with latest and greatest in open source projects! 🏆


Subscribe to our mailing list

js-sdk

:star2: JavaScript SDK for Timekit's scheduling & calendar API

Subscribe to updates I use js-sdk


Statistics on js-sdk

Number of watchers on Github 72
Number of open issues 3
Average time to close an issue about 1 month
Main language JavaScript
Average time to merge a PR 6 days
Open pull requests 5+
Closed pull requests 0+
Last commit over 1 year ago
Repo Created almost 4 years ago
Repo Last Updated about 1 year ago
Size 942 KB
Homepage http://developers...
Organization / Authortimekit-io
Latest Releasev1.12.2
Contributors2
Page Updated
Do you use js-sdk? Leave a review!
View open issues (3)
View js-sdk activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating js-sdk for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Timekit JS SDK

Circle CI Code Coverage

Releases & changelog

Make API calls to Timekit with our easy-to-use JavaScript SDK. It supports all our endpoints as documented on https://reference.timekit.io/.

Visit timekit.io to learn more and don't hesitate to contact Lasse Boisen Andersen (la@timekit.io or create an Issue) for questions. PR's are more than welcome!

Features:

  • Returns ES-6/A+ style promises
  • Works in both node.js and in the browser (>=IE8 and evergreen)
  • Supports custom timestamp formats and timezones

Dependencies

The following libraries are bundled together with the SDK:

  • axios - a promise-based HTTP client for the browser (using XMLHttpRequests) and node.js (using http)
  • base64 - a robust base64 encoder/decoder, used for basic auth headers
  • humps - easy conversion from camelCase to snake_case and vice versa

Installation

The library is hosted on NPM, so you can simply go:

npm install timekit-sdk --save

Module loading

The SDK is UMD (Universal Module Definition) compatible, which means that it can be loaded in various module formats across both browsers and server.

Note: Use plain or minified builds in /dist when using in browser. In node, /src/timekit.js will be used through npm (or reference it manually in your require)

AMD (with e.g. require.js)

require(['timekit-sdk'], function(timekit) {
    console.log(timekit);
});

CommonJS2 (in e.g. node.js)

var timekit = require('timekit-sdk');
console.log(timekit);

As a global variable (in browsers)

<script src="timekit-sdk.js"></script>
<script>
    console.log(timekit);
</script>

See /examples for implementation examples.

Usage (init)

The only required configuration is that you set the app key to your registered app slug on Timekit.

Here's all the available options:

// Overwrites default config with supplied object, possible keys with default values below
timekit.configure({
    app:                        'back-to-the-future',       // your registered app name (visit timekit.io)
    apiBaseUrl:                 'https://api.timekit.io/',  // API endpoint (do not change)
    apiVersion:                 'v2',                       // version of API to call (do not change)
    inputTimestampFormat:       'Y-m-d h:ia',               // default timestamp format that you supply
    outputTimestampFormat:      'Y-m-d h:ia',               // default timestamp format that you want the API to return
    timezone:                   'Europe/Copenhagen',        // override user's timezone for custom formatted timestamps in another timezone
    convertResponseToCamelcase: false,                      // should keys in JSON response automatically be converted from snake_case to camelCase?
    convertRequestToSnakecase:  true,                       // should keys in JSON requests automatically be converted from camelCase to snake_case?
    autoFlattenResponse: true                               // if you keep this set to true, then responses with a "data" key will automatically be flattened to response.data (otherwise you need to access response.data.data). Pagination meta data can be found on response.metaData)
});

// Returns current config object
timekit.getConfig();

// Set the user to auth with (gets automatically set after timekit.auth())
timekit.setUser(
    email,      // [String] email of the user
    apiToken    // [String] access token retrieved from API
);

// Returns current user that have been set previously (email and apiToken)
timekit.getUser();

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/

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:

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

// Auth endpoints
timekit.auth(data);

// Apps endpoints
timekit.getApps();
timekit.getApp(data);
timekit.createApp(data);
timekit.updateApp(data);
timekit.deleteApp(data);

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

// Events endpoints
timekit.getEvents(data);
timekit.getEvent(data);
timekit.createEvent(data);
timekit.updateEvent(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
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:


timekit.createEvent({
  start:        '2015-10-26T15:45:00+00:07',
  end:          '2015-10-26T17:30:00+00:07',
  what:         'Coffee with the timelords',
  where:        'Timekit HQ @ San Francisco',
  participants: ['doc.brown@timekit.io', 'john@doe.com'],
  invite:       true,
  calendar_id:  '794f6cca-68b5-11e5-9d70-feff819cdc9f'
}).then(function(response){
  console.log(response);
}).catch(function(response){
  console.log(response);
});

Response example:


{
  // data is the response that was provided by the server
  data: {},
  // status is the HTTP status code from the server response
  status: 200,
  // statusText is the HTTP status message from the server response
  statusText: 'OK',
  // headers the headers that the server responded with
  headers: {},
  // config is the config that was provided to `axios` for the request
  config: {}
}

Usage (lowlevel API)

If you, for some reason, would like direct access to axios's request API, you can call the timekit.makeRequest() method directly. We'll still set the correct config headers, base url and includes, but otherwise it supports all the settings that axios does.

Example:


timekit.makeRequest({
  url: '/endpoint/goes/here',
  method: 'post',
  data: {
    key: 'value'
  },
  timeout: 1000
}).then(function(response){
  console.log(response);
}).catch(function(response){
  console.log(response);
});

Dynamic includes

The Timekit API have support for dynamically including related models (aka. expand objects). We supports this functionality by providing a chainable/fluent method called .include() that can be called right before a request.

The method takes unlimited string arguments, with each one being a model that you want included in the response. For nested data (e.g. events grouped by calendar), use the dot notation to dig into relations, like calender.events.

Example:


timekit
.include('calendars.events', 'users')
.getUserInfo()
.then(function(response) {
    // Response contains JSON data with nested info on the user's calendars, events and meetings
});

This is super powerful because it means that you can avoid unnecessary extra requests compared to fetching each resource sequentially.

Building from source

We use webpack for packaging the library as a module. To build the source files in /src to /dist, run:

# install dev dependencies
npm install
# build plain
webpack
# build minified
webpack --config webpack.config.min.js

Running tests

We use jasmine + karma for unit testing, which works together with webpack.

To run the test suite, simply do:

# install dev dependencies
npm install
# install karma as global
npm install -g karma
# start karma and run
karma start

Roadmap/todos

See Issues for feature requests, bugs etc.

js-sdk open pull requests (View All Pulls)
  • Update package.json
  • Project stop-the-bleeding
  • fix(core): auth issue with camelCase
  • fix example in README
  • Support for app token auth
js-sdk questions on Stackoverflow (View All Questions)
  • facebook js sdk not working on android app webview
  • How to get a list of event created by a user in facebook using JS sdk?
  • get error when use cloudboost js sdk for user logout function, any idea?
  • Download Facebook JS SDK
  • Amazon API Gateway IAM authenticated example with generated JS SDK
  • Passing Access Token from Facebook JS sdk to PHP session or cookie
  • Using Firebase JS SDK offline capability vs promises to cache data?
  • The Socket JS SDK trying to join the channel again and again in phoenix framework
  • Yammer Login Popup not working on mobile using JS SDK
  • facebook js SDK module for Yii2
  • How to import Parse JS sdk into ionic 2 beta
  • AWS Node JS SDK - Amazon IOT - MalformedPolicyException: Policy document is Malformed
  • Js SDK Facebook share image Uncaught Error: invalid version specified
  • How to test Facebook JS SDK sign in using Cucumber?
  • JS SDK FB.login() works but pop-up dialog is staying open after logged in
  • The security token included in the request is invalid. aws js sdk
  • JS SDK not returning full object, only abbreviation
  • Soundcloud JS SDK - SC.Connect() callback window can't close if App installed on iOS
  • Google oauth2 works with one time code generated from Android but not working for code generated from JS SDK
  • Deezer JS SDK with Android & iOS devices
  • In Parse.com JS SDK, how to delete an element from inside an array of pointers?
  • AWS JS SDK, IAM and DynamoDB Issue
  • Expires header for Facebook JS SDK and Google Analytics
  • Unable to authorize with LinkedIn JS SDK on iOS Safari from non-https url
  • CORS error with listBuckets in AWS JS SDK
  • Parse.com JS SDK multiple nested queries with include
  • Facebook JS SDK how to get current user's first name?
  • getLoginStatus returns status unknown when trying to logout from Facebook using Facebook JS SDK
  • Facebook JS SDK - email response undefined
  • Add Query conditionals to related object's properties in parse.com with JS SDK
js-sdk list of languages used
js-sdk latest release notes
v1.12.2 v1.12.2

[2018-02-20 15:52 +00:00] Link to new API reference in readme by @petersuhm - https://github.com/timekit-io/js-sdk/pull/41

v1.12.1 v1.12.1

[2018-02-16 14:21 +00:00] fix(core): auth issue with camelCase by @peterbsmith2 - https://github.com/timekit-io/js-sdk/pull/38 [2018-02-16 14:21 +00:00] fix example in README by @peterbsmith2 - https://github.com/timekit-io/js-sdk/pull/37

v1.12.0 v1.12.0

[2017-11-30 08:51 +00:00] Added configurable header by @Trolzie - https://github.com/timekit-io/js-sdk/pull/39

More projects by timekit-io View all
Other projects in JavaScript