-
Notifications
You must be signed in to change notification settings - Fork 17
/
job.js
37 lines (28 loc) · 911 Bytes
/
job.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const API = require("./api");
class Job {
static create(opts, callback) {
if(this.cli.notification != undefined) {
opts = Object.assign({}, opts, {"notification": this.cli.notification});
}
if(this.cli.storage != undefined) {
opts = Object.assign({}, opts, {"storage": this.cli.storage});
}
var that = this
if (typeof callback === 'undefined') {
return new Promise(function(resolve) {
API.request(that.cli, "POST", "/jobs", opts, resolve);
});
}
API.request(this.cli, "POST", "/jobs", opts, callback);
}
static retrieve(job_id, callback) {
var that = this
if (typeof callback === 'undefined') {
return new Promise(function(resolve) {
API.request(that.cli, "GET", "/jobs/" + job_id, null, resolve);
});
}
API.request(this.cli, "GET", "/jobs/" + job_id, null, callback);
}
}
module.exports = Job;