Giter Club home page Giter Club 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

adamschroder avatar klaascuvelier avatar octatone avatar rotev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wunderlist.js's Issues

Invalid reminder datetime

I've tried every format that I know of. What is the correct way to enter the reminder date and time?

dependencies on deprecated modules

npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated [email protected]: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.

Core is missing?

Got the following error:

Cannot find module 'wunderbits.core'

Any ideas?

using node:
var WunderlistSDK = require('wunderlist');

Script Hangs

When running a simple node.js command line script, the script hangs after finishing.

Script just has

var WunderlistSDK = require('wunderlist');
var wunderlistAPI = new WunderlistSDK({
  'accessToken': 'xxxx',
  'clientID': 'xxxx'
});
wunderlistAPI.http.lists.all()
.done(function (lists) {
    console.log(lists);
}
.fail(function (error) {
    console.error('there was a problem' + error);
  });

Clearly I can add a process.exit() to the end of .done, but I assume you're keeping something open? Is this the correct way to exit?

Unable to create a file after upload step. error Upload was not finished properly

Hello,

I am trying to create file after uploading step.
here is my code

if (data.isValid) {
        const dir = "./telegram_uploads";
        telegramBot.downloadFile(telegramResponse.photo[0].file_id, dir).then(function (response) {

            const fileName = "./" + response;
            const mimeType = mime.getType(fileName);

            console.log("mimeType", mimeType);

            const uploadData = {
                content_type: mimeType,
                file_name: fileName,
                file_size: telegramResponse.photo[0].file_size
            };

            wunderlistAPI.http.uploads.create(uploadData)
                .done(function (createUploadResponse, statusCode) {

                    console.log("createUploadResponse", createUploadResponse, statusCode);

                    var createFileData = {
                        upload_id: createUploadResponse.id,
                        task_id: 3846472873, // hardcoded todo1 task
                        local_created_at: new Date("2013-08-02T11:58:55.123Z")
                    };

                    wunderlistAPI.http.files.create(createFileData)
                        .done(function (createFileResponse) {
                            console.log("createFileResponse", createFileResponse);
                        })
                        .fail(function (err) {
                            console.error('there was a problem create file', err);
                        });
                })
                .fail(function (err) {
                    console.error('there was a problem upload file', err);
                });
        }).catch(function (err) {
            console.log("downloadFile err", err);
        });
    }

I am getting error on create file API.

there was a problem create file { error: 
   { type: 'validation_error',
     translation_key: 'api_error_validation_error',
     message: 'The information you sent could not be processed (validation failure).',
     upload: [ 'Upload was not finished properly' ] } }

Here is the complete log

telegramResponse  { message_id: 5162,
  from: 
   { id: 157895645,
     is_bot: false,
     first_name: 'Qadir',
     username: 'qadirsuh',
     language_code: 'en-US' },
  chat: 
   { id: -269600145,
     title: 'Airhome24 - Gubelstrasse 24, Zug :: airhomeCHLU5',
     type: 'group',
     all_members_are_administrators: true },
  date: 2018-05-18T07:56:59.000Z,
  photo: 
   [ { file_id: 'AgADBAADEKwxG0CW8FMeLo8vosukgIhxiRoABCN6pAHob8lfV44FAAEC',
       file_size: 811,
       file_path: 'photos/file_73.jpg',
       width: 90,
       height: 42 },
     { file_id: 'AgADBAADEKwxG0CW8FMeLo8vosukgIhxiRoABNnJIcD3yGXvWI4FAAEC',
       file_size: 12773,
       width: 320,
       height: 148 },
     { file_id: 'AgADBAADEKwxG0CW8FMeLo8vosukgIhxiRoABDNHnyQirKjXWY4FAAEC',
       file_size: 60406,
       width: 800,
       height: 371 },
     { file_id: 'AgADBAADEKwxG0CW8FMeLo8vosukgIhxiRoABEgqeVZarExHVo4FAAEC',
       file_size: 75957,
       width: 960,
       height: 445 } ] }
mimeType image/jpeg
createUploadResponse { id: 194990275,
  user_id: 83893571,
  state: 'new',
  type: 'upload',
  expires_at: '2018-05-18T08:02:02.402Z',
  part: 
   { url: 'https://upload.wunderlist.io/f8d10eb0-3c9e-0136-bdb1-22000a7d84c2-1526630221-932543?partNumber=1&uploadId=ocTB4usGTKDr5moJdhuGOO4kz.eVC9YPYukhmSYjJFr7r5UZUKUjbfK_8CTtRMRQxvSqvRLAN2Y1N42w39sZfbS9JVPr5c30aT1Rjwjbv7sDjjeOl3g3wpu0iOU7iOuF',
     date: 'Fri, 18 May 2018 08:02:02 UTC +00:00',
     authorization: 'AWS AKIAJEN6W4AO3LJODOAA:QFdXLxECwVDp9TPBSX8TEU10K48=' } } 201
there was a problem create file { error: 
   { type: 'validation_error',
     translation_key: 'api_error_validation_error',
     message: 'The information you sent could not be processed (validation failure).',
     upload: [ 'Upload was not finished properly' ] } }

No websocket connection available

Hey guys, really enjoying wunderlist. Was toying around with the API and noticed wunderlistAPI.socket doesn't work. It returns the error: No websocket connection available.

WebSocket connection error

Hi!

Sry for my bad english.
Im studying to be web developer. I got task to implement wunderlist api in some app.
Im getting lists.
Why do i gett this error message?

Ok
(index):24 [Object]
2wunderlist.sdk.js:4286 WebSocket connection to 'wss://socket.wunderlist.com:8443/api/v1/sync?client_id=9bc9faf58bd6f059d8e6…3b93cd2a7bdb69bf68&client_device_id=undefined&client_instance_id=undefined' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

here is code

<script src="~/Scripts/core/wunderlist.sdk.js"></script>
<script>
    var wunderlistSDK = window.wunderlist.sdk;
    var wunderlistAPI = new wunderlistSDK({
        'accessToken': '3bfeea608bc1fca2772a4130b2233cd32c9989ce643b93cd2a7bdb69bf68',
        'clientID': '9bc9faf58bd6f059d8e6'
    });

    wunderlistAPI.http.lists.all()
      .done(function (lists) {
          /* do stuff */
          console.log("Ok"); 
          WebSocket.CLOSED;
          console.log(lists);
      })
      .fail(function () {
          console.error('there was a problem');
      });
</script>

how to get all tasks

I would like to get all tasks (I want to sync with my external system). Its fine if it comes down as a hierarchy.

Thanks,
Jason

Ability to provide access token on a service call

Hello folks!

At the moment I'm curious if it's possible to provide access token when calling specific API resource. For example:

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

wunderlistAPI.http.lists.all()

will return lists for a user who owns access token that we passed to the WunderlistSDK constructor.

I'd like to use this library on the server side, but it seems to be a bit of overkill to recreate WunderlistSDK instance on each call. Instead it would be cool to see something like:

var wunderlistAPI = new WunderlistSDK({
  'clientID': 'client_id'
});

wunderlistAPI.http.lists.all(accessToken)

so it would be possible to re-use wunderlistAPI instance serving requests for different users.

Invoke webhook upon reminder/due date and or time is reached

Hello.
Can any body help me through this.
I have created a webhook for my list and I have checked its invoked on new task creation in that list and update note and create a sub task in it.

But I want my webhook to be invoked when a certain task's due date/time is reached.
basically I am working on a reminder app. I want to notify the user about his reminder.
simply I want my webhook to be invoked when a reminder time is reached.
I have checked it my webhook is not invoking.

please don't tell me this is not supported :(

Error during make

Mac OS: 0.11.1
node: 5.0.0
npm: 3.3.12

$ make
Running "jshint:public" (jshint) task
>> 78 files lint free.

Running "jshint:tests" (jshint) task
>> 31 files lint free.

Running "complexity:public" (complexity) task


Done, without errors.


  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
  ․․․․․․․․․․․․․․․․․․․․{ errors: [ 'Error: data required for file creation' ] }
․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
  ․․․․․․․․․․[FOOBAR] i should call real console
․․․․․․․․․․․․․․․․․․․․․․․

  221 passing (2s)

module.js:339
    throw err;
    ^

Error: Cannot find module 'gulp-streamify/node_modules/gulp-util'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/adrian/Projects/tests/wunderlist.js/node_modules/gulp-cjs/lib/scripts.js:14:14)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
make: *** [build] Error 1

Unable to fetch lists

Following the basic example I'm unable to get a result. I can't give more specific examples because there doesn't seem to be a way to surface error codes? Curiously, I can get a result using bare request (and curl). My code (running on an express server):

// doesn't work
var WunderlistSDK = require('wunderlist');
  var wunderlist = new WunderlistSDK({
    'accessToken': process.env.WUNDERLIST_ACCESS_TOKEN,
    'clientID': process.env.WUNDERLIST_CLIENT_ID
  });

  wunderlist.http.lists.all()
    .done(function (lists) {
      console.log(lists);
    })
    .fail(function () {
      console.error('there was a problem');
    });
// works fine
var request = require('request');
var options = {
  url: 'https://a.wunderlist.com/api/v1/lists',
  headers: {
    'X-Access-Token': process.env.WUNDERLIST_ACCESS_TOKEN,
    'X-Client-ID': process.env.WUNDERLIST_CLIENT_ID
  }
};

request(options, function(err, resp, body){
  var lists = JSON.parse(body); // is actually the error message in case of err
  if (!err && resp.statusCode === 200) 
    res.send(lists);
  } else {
    console.log('code: ',resp.statusCode);
    res.send(body);
  }
});

SDK version is 0.1.2. Any ideas? Let me know if I can provide any other info.

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.