Giter VIP home page Giter VIP logo

wunderlist.js's Introduction

Wunderlist Javascript SDK

The Wunderlist JS SDK simplifies interacting with the Wunderlist API. It can be used both in the browser and on the server side.

Note: Before you can start using Wunderlist API you need to register your app.

Basic Usage

Node

var WunderlistSDK = require('wunderlist');
var wunderlistAPI = new WunderlistSDK({
  'accessToken': 'a user access_token',
  'clientID': 'your client_id'
});

wunderlistAPI.http.lists.all()
  .done(function (lists) {
    /* do stuff */
  })
  .fail(function () {
    console.error('there was a problem');
  });

Browser

Include the SDK somewhere:

<head>
  <script type="text/javascript" src="/dist/wunderlist.sdk.js"></script>
</head>

... it can be now loaded from a global namespace ...

var WunderlistSDK = window.wunderlist.sdk;

... or as an AMD module (if an AMD loader was present before the sdk was loaded) ...

define(['wunderlist.sdk'], function (WunderlistSDK) {
  // do stuff with wunderlist by getting an instance of the sdk through WunderlistSDK#start
});

Get an instance of the SDK:

// Returns an instance of the Wunderlist SDK setup with the correct client ID and user access token
// and sets up a single WebSocket connection for REST over socket proxying
var WunderlistAPI = new WunderlistSDK({
  'accessToken': 'a user token',
  'clientID': 'your application id'
});

WunderlistAPI.initialized.done(function () {
  // Where handleListData and handleError are functions
  // 'http' here can be replaced with 'socket' to use a WebSocket connection for all requests
  WunderlistAPI.http.lists.all()
    // handleListData will be called with the object parsed from the response JSON
    .done(handleListData)
    // handleError will be called with the error/event
    .fail(handleError);
});

Advanced Usage

All the available API services are exposed on the wunderlist.sdk constructor as services. This allows creating an instance of a single service rather than all services for the entire API.

'use strict';

var sdk = require('wunderlist');
var oauthConfig = require('../../config/oauth.json');

sdk.prototype.setupLogging({
  'logLevel': 'error',
  'logPattern': '*'
});

function getService (context, service) {

  var options = {
    'accessToken': context.session.access_token,
    'clientID': oauthConfig.clientId,
    'maxHttpRequests': 1000,
    'checkHealth': false
  };

  return new sdk.services[service]({
    'config': options
  });
}

module.exports = {
  'get': getService
};

Documentation

Open /docs/index.html in your browser for the full JS documentation, or from the /docs path if you are running the development server.

Development

The Wunderlist Javascript SDK is built with Wunderbits, lo-dash, node.js, grunt and some other stuff

Get started

If you are on a vanilla system, you need some tools

Make yourself owner of /usr/local:

$ sudo chown -R whoami:staff /usr/local

One time setup:

$ make install

Clone the repo & start developing

$ git clone [email protected]:wunderlist/wunderlist.js.git
$ cd wunderlist.js
$ make start

Run tests

Run development server

$ make start

This will install all dependencies (via npm) if needed and start the server. By default the server runs on port 5020. You can configure this by setting the PORT environment variable, via the command line (i.e. env PORT=1234 make start).

Run unit tests

$ make unit

Watch unit tests (for development)

$ make watch

Debug (with node-inspector)

$ make debug

Run benchmark tests

$ make benchmarks

Run specific tests in node (run mocha directly)

$ ./node_modules/mocha/bin/_mocha --require specs/helper.js --grep "SchemaValidator" --watch --reporter spec specs/**/*.spec.js

Run specific tests in the browser

just click on a suite to use that as the grep pattern

Resources

Build documentation

$ make documentation

wunderlist.js's People

Contributors

octatone avatar klaascuvelier avatar adamschroder avatar rotev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.