manuscript-api

0.1.0 • Public • Published

Manuscript API

This package is a lightweight NodeJS wrapper around the Manuscript API.

Usage

Set Up

Require manuscript-api with your Manuscript URL and API. This is likely your best approach if you are looking to integrate with a single Manuscript account.

let mAPI = require('manuscript-api')('https://your.manuscript.url/', 'yourmanuscripttoken');

Or require it without account data and provide your data later. This will be your best approach if you are writing a single app that will interface with multiple Manuscript accounts.

let mAPI = require('manuscript-api')
let MAPI = manuscript('https://your.manuscript.url/', 'yourmanuscripttoken');

Work With the Manuscript API

Once you've required manuscript-api and passed it a Manuscript URL and token, you'll have a proxy against which you can call any endpoint of the Manuscript API. For a complete list of Manuscript API endpoints, see the documentation here.

For any api endpoint, call the name of the endpoint against your manuscript Object, and pass your parameters as an object. Under the hood, this wrapper is returning request-promise-native, and returns a promise. Choose your strategy for handling promises:

Both of the following post to http://example.manuscript.url/api/new. First we'll handle the promise:

 
mansucript.new({sTitle:"Case Title"})
  .then(function(data) {
    console.log(data);
  })
  

Alternatively, we can use async\await

async () => {
  let data = await manuscript.new({sTitle:"Case Title"});
  console.log(data);
}
 

Utility Methods

isValid

async () => {
  let isValid = await manuscript.isValid();
  console.log(isValid);
}
 

Returns true if we're able to authenticate to the Manuscript API with the provided credentials and false otherwise. Under the hood, this is just calling the 'logon' endpoint of the Manuscript API.

Made by Fog Creek

\ ゜o゜)ノ

Readme

Keywords

Package Sidebar

Install

npm i manuscript-api

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

121 kB

Total Files

13

Last publish

Collaborators

  • nancyhawa
  • djl605