summaryrefslogtreecommitdiff
path: root/src/sources/HttpSource.ts
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2018-05-01 20:26:07 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2018-05-01 20:38:01 +0200
commit567a0f7a2f248cd25b8a5e0e357f9b10c16a9036 (patch)
tree5c0e0e8790fe8f7be2eecfcb4fe70222b7a847da /src/sources/HttpSource.ts
parent1c0c2e4be26dcd68fdb538edd5845ea702b9fa98 (diff)
downloadsplus-567a0f7a2f248cd25b8a5e0e357f9b10c16a9036.tar.gz
splus-567a0f7a2f248cd25b8a5e0e357f9b10c16a9036.zip
Retrieve schedule for current week, add course config var (closes #3)
Diffstat (limited to 'src/sources/HttpSource.ts')
-rw-r--r--src/sources/HttpSource.ts25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/sources/HttpSource.ts b/src/sources/HttpSource.ts
index 45ddd7a..f9391aa 100644
--- a/src/sources/HttpSource.ts
+++ b/src/sources/HttpSource.ts
@@ -1,22 +1,23 @@
-import {get} from 'http';
+import * as request from 'request-promise-native';
import {ISource} from './ISource';
export class HttpSource implements ISource {
- private _uri: string;
+ private _base_uri = 'http://splus.ostfalia.de/semesterplan123.php';
- constructor(path: string) {
- this._uri = path;
+ constructor(private _course: string) {
}
- getData(): Promise<string> {
- return new Promise<string>((resolve, reject) => {
- get(this._uri, (res) => {
- let data = '';
- res.on('error', reject);
- res.on('data', chunk => data += chunk);
- res.on('end', () => resolve(data));
- });
+ getData(weekOfYear: number): PromiseLike<string> {
+ return request({
+ method: 'POST',
+ uri: this._base_uri,
+ qs: {
+ identifier: this._course,
+ },
+ formData: {
+ weeks: weekOfYear.toString(),
+ },
});
}
}