README
SHUTTER SDK JS
A javascript sdk for Shutter built with webpack, babel & es6. This can be used in node or in the browser*.
NOTE: If used in the browser do not publish your private api key in frontend code.
Install
- Requires node.js >= 14.x
npm i shutter-sdk-js
Setup Client
Next, require the module and instantiate a shutter client by calling new Shutter.client
and setup the client with basic auth credentials (email: 'example@mail.com', password: 'your_pass_here')
. Also need an api url provided by shutter team.
import Shutter from 'shutter-sdk-js';
const shutter = new Shutter.client({
email: "example@mail.com",
password: "your_pass_here",
uri: "example.shutter.com"
});
Methods
The following service methods are available to instantiated clients. The examples assume you have already created a shutter client as shutter
with valid credentials.
Method naming conventions:
get
orget{{Item}}
- expected response for client is a single objectlist
orlist{{Items}}
- expected response for client is a list of objectscreate
orcreate{{Item}}
- expected response for client is a single objectupdate
orupdate{{Item}}
- expected response is an object with a status messagedelete
ordelete{{Item}}
- expected response is an object with a status message
users
create
shutter.users.create({user})
Example:
try {
const createdUser = await shutter.users.create({
name: "test",
email: "test@shutter.com"
});
console.log(createdUser) // logs response data
} catch (err) {
console.log(err); // logs any error
}
Promise Returns:
{
id: '609ab5190ae391f4e90d10f1',
name: 'test',
email: "test@shutter.com"
}
Options:
Parameter | Description |
---|---|
name | Name of the user. |
Email address of the user. Example: "Jhon jhon@host.com". |