-
Notifications
You must be signed in to change notification settings - Fork 46
/
common.js
46 lines (40 loc) · 1.16 KB
/
common.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
38
39
40
41
42
43
44
45
// This module contains functions shared by multiple tests
var util = require('util');
// session to use for all the invocations, should be set by test
exports.session = null;
exports.loginName = null;
exports.password = null;
exports.applicationKey = null;
// login to Betfair
exports.login = function(par, cb) {
if(!cb)
// cb is first parameter
cb = par;
console.log('===== Logging in to Betfair =====');
var session = exports.session;
session.open(exports.loginName, exports.password, exports.applocationKey, function(err, res) {
if (err) {
console.log('Login error', err);
} else {
console.log('Login OK');
}
exports.loginCookie = res.responseCookie;
cb(err);
});
}
// logout from Betfair
exports.logout = function(par, cb) {
if(!cb)
// cb is first parameter
cb = par;
console.log('===== Logging out... =====');
var session = exports.session;
session.close(function(err, res) {
if (err) {
console.log('Logout error', err);
} else {
console.log('Logout OK');
}
cb(err);
});
}