Skip to content

Commit f58fb4e

Browse files
committed
Remove old iphone method. Heinekingmedia took it offline.
1 parent b3735bc commit f58fb4e

File tree

5 files changed

+121
-271
lines changed

5 files changed

+121
-271
lines changed

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@ _test.js
5959

6060
docs/
6161

62-
dist/
62+
dist/
63+
64+
.env

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"devDependencies": {
99
"babel-register": "^6.26.0",
1010
"chai": "^4.1.2",
11+
"dotenv": "^8.1.0",
1112
"esdoc": "^1.1.0",
1213
"esdoc-external-ecmascript-plugin": "^1.0.0",
1314
"esdoc-external-nodejs-plugin": "^1.0.0",

Diff for: src/index.js

+1-50
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,7 @@ export default class DSB {
4040
login: 'https://mobile.dsbcontrol.de/dsbmobilepage.aspx',
4141
main: 'https://www.dsbmobile.de/',
4242
Data: 'http://www.dsbmobile.de/JsonHandlerWeb.ashx/GetData',
43-
default: 'https://www.dsbmobile.de/default.aspx',
44-
loginV1: `https://iphone.dsbcontrol.de/iPhoneService.svc/DSB/authid/${
45-
this.username
46-
}/${this.password}`,
47-
timetables:
48-
'https://iphone.dsbcontrol.de/iPhoneService.svc/DSB/timetables/',
49-
news: 'https://iphone.dsbcontrol.de/iPhoneService.svc/DSB/news/'
43+
default: 'https://www.dsbmobile.de/default.aspx'
5044
};
5145
/**
5246
* @private
@@ -121,49 +115,6 @@ export default class DSB {
121115
return decoded;
122116
}
123117

124-
/**
125-
* Fetch data from the original iphone api (Only news and timetables supported)
126-
* @param {ProgressCallback} [progress]
127-
* @returns {Promise.<Object>}
128-
*/
129-
async fetchV1(progress = () => {}) {
130-
let currentProgress = 0;
131-
const loginV1Response = await this.axios({
132-
method: 'GET',
133-
url: this.urls.loginV1
134-
});
135-
if (loginV1Response.data === '00000000-0000-0000-0000-000000000000')
136-
throw new Error('Login failed.');
137-
const id = loginV1Response.data;
138-
currentProgress++;
139-
progress(percentage.from(currentProgress, 5));
140-
const data = await Promise.all([
141-
this.axios(this.urls.timetables + id).then(response => {
142-
currentProgress++;
143-
progress(percentage.from(currentProgress, 5));
144-
return Promise.resolve({ timetables: response.data });
145-
}),
146-
this.axios(this.urls.news + id).then(response => {
147-
currentProgress++;
148-
progress(percentage.from(currentProgress, 5));
149-
return Promise.resolve({ news: response.data });
150-
})
151-
]);
152-
currentProgress++;
153-
progress(percentage.from(currentProgress, 5));
154-
let newData = {};
155-
for (let fragment of data) {
156-
for (let key in fragment) {
157-
if (fragment.hasOwnProperty(key)) {
158-
newData[key] = fragment[key];
159-
}
160-
}
161-
}
162-
currentProgress++;
163-
progress(percentage.from(currentProgress, 5));
164-
return newData;
165-
}
166-
167118
/**
168119
* Login with username and password
169120
* @param {String|Number} [username=this.username]

Diff for: test/test.js

+4-38
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ const chai = require('chai');
33
const expect = chai.expect;
44
const assert = chai.assert;
55

6+
// Load .env for testing purpose
7+
require('dotenv').config();
8+
69
chai.should();
710

811
describe('Library', function() {
@@ -35,11 +38,6 @@ describe('DSB Instance', function() {
3538
assert.isDefined(dsb.fetch);
3639
assert.isFunction(dsb.fetch);
3740
});
38-
39-
it('should have fetchV1()', function() {
40-
assert.isDefined(dsb.fetchV1);
41-
assert.isFunction(dsb.fetchV1);
42-
});
4341
});
4442

4543
describe('functions', function() {
@@ -95,36 +93,4 @@ describe('functions', function() {
9593
'Method timetable, tiles and news are all not an object.'
9694
);
9795
});
98-
});
99-
100-
describe('functions v1', function() {
101-
const DSB = require('../dist/index');
102-
const dsb = new DSB(process.env.DSBUSERNAME, process.env.PASSWORD);
103-
104-
it('should not throw', function(done) {
105-
dsb.fetchV1()
106-
.then(() => {
107-
done();
108-
})
109-
.catch(e => {
110-
done(e);
111-
});
112-
});
113-
114-
it('should return an object', async function() {
115-
const data = await dsb.fetchV1();
116-
assert.isObject(data);
117-
});
118-
119-
it('should be at least one an array', async function() {
120-
const data = await dsb.fetchV1();
121-
if (
122-
!(
123-
Array.isArray(data.timetables) ||
124-
Array.isArray(data.tiles) ||
125-
Array.isArray(data.news)
126-
)
127-
)
128-
throw new Error('timetables, tiles and news are all not an array.');
129-
});
130-
});
96+
});

0 commit comments

Comments
 (0)