crp-job-client

2.0.9 • Public • Published

CrowdProcess Job Client

Basic CRUD for CrowdProcess Jobs

Getting it

$ # install it with
$ npm install --save crp-job-client
// require it
var Client = require('crp-account-client');
 
// initiallize it with a username and password
var jobs = Client({
  email: 'my@email.com',
  password: 'a safe password'
});
 
// Or with a token
var jobs = Client({
  token: 'bb74a721-1728-45fe-8394-2d3ef4e0ac82'
});

You can get your authentication tokens with the account client.

Create a Job

var job = {
  program: "function Run (d) { return 3*d; }"
};
 
var jobId; // we'll use this on the next code block
jobs.create(job, function (err, res) {
  if (err)
    return console.log('not found :(');
 
  jobId = res.id;
});

View the job

// remember jobId from the last code block ?
jobs(jobId).show(function (err, job) {
  if (err)
    return console.log('not found :(');
 
  console.log(job);
});

List all the jobs

jobs.list(function (err, jobList) {
  if (err)
    return console.log('Something went terribly wrong');
 
  console.log(jobList); // it's an array of objects just like the one you got on jobs(jobId).show()
});

Delete a job

jobs(jobId).destroy(function (err) {
  if (err)
    console.log('cannot find the job');
});

Delete all your jobs

jobs.purge(function (err) {
  if (err)
    console.log('something went terribly wrong');
});

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i crp-job-client

    Weekly Downloads

    6

    Version

    2.0.9

    License

    none

    Last publish

    Collaborators

    • pgte
    • joaojeronimo
    • soarez