crp-account-client

CrowdProcess Account Client

npm install crp-account-client
1 downloads in the last day
1 downloads in the last week
19 downloads in the last month

CrowdProcess Account Client

Basically about account CRUD and obtaining tokens. You know, user account stuff.

Getting it

$ # install it with
$ npm install --save crp-account-client
// require it
var Client = require('crp-account-client');

// initiallize the client with a username and a password
var client = Client({
  username: myUsername,
  password: myPassword
});

// or with a token
var client = Client({
  token: myToken
});

// or with nothing at all, if you pretend to create an account
var client = Client();

Obtaining a Token

Of course you have to create an account first.

client.login({
  email: 'myemail@address.com',
  password: 'a secure password'
}, function (err, token) {
  if (!err)
    console.log('now I can use my token:', token);
});

Account CRUD

Create

For this you should use the website.

View

client.account({
  email: 'myemail@address.com',
  password: 'a secure password'
}).view(function (err, account) {
  if (!err)
    console.log('here\'s my account:', account);
});

Update

client.account({
  email: 'myemail@address.com',
  password: 'a secure password'
}).update({
  name: 'My New Name',
  newPassword: 'safer password ?'
}, function (err) {
  if (!err)
    console.log('boom.. hope I remember my new password..');
});

Delete

client.account({
  email: 'myemail@address.com',
  password: 'a secure password'
}).destroy(function (err) {
  if (!err)
    console.log('no more account :(');
})
npm loves you