-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathconnect.js
More file actions
35 lines (29 loc) · 765 Bytes
/
connect.js
File metadata and controls
35 lines (29 loc) · 765 Bytes
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
'use strict'
const Connection = function() {
};
Connection.prototype.as = function(account) {
this.address = account.address;
this.secret = account.secret;
this.scope = this.address;
}
Connection.prototype.use = function(address) {
if (!this.address) throw new Error('please invoke as method before use!')
this.scope = address;
}
Connection.prototype.useCert = function(cert) {
this.userCert = cert;
}
Connection.prototype.setSchema = function(schemaID) {
this.schemaID = schemaID;
}
Connection.prototype.connect = function() {
let that = this;
return new Promise(function(resolve, reject) {
that.api.connect().then(function() {
resolve(that);
}).catch(function(e) {
reject(e);
});
})
}
module.exports = Connection;