Code Monkey home page Code Monkey logo

megaplanjs's Introduction

Megaplan client module for NodeJS

A NodeJS library to work with megaplan.ru API ver. 1

Provides a class that implements Megaplan authentication and request signing. Only supports POST requests. The complete API documentation is at: https://dev.megaplan.ru/api/index.html

At first you need to install library

npm install megaplanjs --save

You can generate documentaion with commands:

npm install
npm run docs

Authorization

To authorize using a password:

var megaplan = require ('megaplanjs');
var client = new megaplan.Client('my.megaplan.ru').auth('me', 'pass');
client.on('auth', function (res, err) {
    // store res.access_id, res.secret_key if you need these (see below)
    console.log('authenticated', res, err);

    client.tasks().send(function (tasks) {
        console.log(tasks); // a lot of results
    }, function (err) {
        console.log(err);
    });
});

To authorize using tokens:

var megaplan = require ('megaplanjs');
var client = new megaplan.Client('xyz.megaplan.ru', access_id, secret_key);
client.tasks().send(function (tasks) {
    console.log(tasks); // still a lot of results
}, function (err) {
    console.log(err);
});

To authorize using one-time-key:

var megaplan = require ('megaplanjs');
var client = new megaplan.Client('xyz.megaplan.ru').auth('', '', '4gih4y4gih4yH77QebicH77Qebic');
client.tasks().send(function (tasks) {
    console.log(tasks); // still a lot of results
}, function (err) {
    console.log(err);
});

Usage

var megaplan = require("megaplanjs");
// SET here your megaplan URL, login and password
var client = new megaplan.Client("my.megaplan.ru").auth("me", "pass");

client.on("auth", function(res, err) {
  // show user's tasks
  client.tasks({ folder: "owner" }).send(
    function(tasks) {
      console.log(tasks);
    },
    function(err) {
      console.log(err);
    }
  );
});

Look index.js for more examples. It's pretty simple to use

Copylefts

Code originally written by Alexej Yaroshevich [email protected] under the MIT License.

Enjoy!

megaplanjs's People

Contributors

alexeybityukov avatar alexkvak avatar atnartur avatar dependabot[bot] avatar ildarik avatar qfox avatar restricted avatar

Stargazers

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

Watchers

 avatar  avatar

megaplanjs's Issues

Task count not working

Implement:

megaplan.tasks({status: "actual", folder: "incoming", count: true}).send(function (count) {
    console.log(count);
});

Problem in request.js:

Megaplan returns { Total: "" }:

if (jkey && (typeof jkey === 'string') && !result[jkey]) {
    throw "key " + jkey + " not exists in json";
}

"jkey" is "tasks" and not exists in response.

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.