-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
113 lines (102 loc) · 3.23 KB
/
example.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
var auth = require('./lib/index.js');
var config = require('config');
const USERNAME = (process.env.USERNAME) ?
process.env.USERNAME :
config.get('icarus.username');
const PASSWORD = (process.env.PASSWORD) ?
(process.env.PASSWORD) :
config.get('icarus.password');
if (!(USERNAME && PASSWORD)) {
throw new Error("Missing config values!");
}
// constructor call
var parser = new auth(USERNAME, PASSWORD);
// execute and test module
parser.printStudent();
console.log(parser.getSessionInfo());
console.log(parser.getDepartmentName());
// authenticate and test the other api
parser.authenticate(function (error, response) {
console.log(response);
console.log((response.authenticated) ? "Authenticated" : "Authentication Failed.");
parser.getUserDetails(response.document, response.cookie, function (err, data) {
if (err) {
return console.log(err.message)
}
console.log(data)
});
parser.getSucceededGrades(response.document, function (err, value) {
if (err) {
return console.log(err.message)
}
console.log(value)
});
parser.getAnalyticGrades(response.document, function (err, value) {
if (err) {
return console.log(err.message)
}
console.log(value)
});
parser.getExamGrades(response.document, function (err, value) {
if (err) {
return console.log(err.message)
}
console.log(value)
});
parser.getIntercalaryExamGrades(response.document, function (err, value) {
if (err) {
return console.log(err.message)
}
console.log(value)
});
parser.getCurriculumToDeclare(response.cookie, function (err, value) {
if (err) {
console.log('error:', err.message); // Print the error if one occurred
}
var formData = [];
for (var i in value) {
if (value.hasOwnProperty(i)) {
formData.push(value[i].id);
}
}
console.log(value)
// call postCurriculumToDeclare(formData, (err, value) {....}) to post them
});
parser.postCurriculumToDeclare(['321-2450',
'331-2205',
'321-4120',
'311-0116',
'311-0238',
'311-0327',
'311-0437',
'331-2708'], response.cookie, function (err, value) {
if (err) {
console.log('error:', err.message); // Print the error if one occurred
}
console.log(value);
});
parser.postRequestToDepartment({
id: 'test',
surname: 'test',
name: 'test',
father: 'test',
semester: 'test',
address: 'test',
address2: 'test',
phone: 'test',
emergency: 'test',
method: 'test',
sent_address: 'test',
other: 'test',
requests: [
{name: 'Βεβαίωση Σπουδών', amount: '1'},
{name: 'Βεβαίωση Διαγραφής', amount: '3'},
{name: 'Αλλο', amount: '9', what: 'κάτι άλλο'}
]
}, response.cookie, function (err, value) {
if (err) {
console.log('error:', err.message); // Print the error if one occurred
}
console.log(value);
})
});