Compare commits

..

No commits in common. "d15369406dbfd5aa75805a7cef0a54a3efc5749d" and "b59d7b3084e5c09a9b79b3217c272e4c7c1fa137" have entirely different histories.

6 changed files with 4 additions and 69 deletions

View file

@ -95,8 +95,6 @@
"bitmasks", "bitmasks",
"Blaschkoallee", "Blaschkoallee",
"Blissestr", "Blissestr",
"bmis",
"BMIS",
"BNWNZF", "BNWNZF",
"Böhme", "Böhme",
"BONVOYO", "BONVOYO",
@ -197,7 +195,6 @@
"Fehrbelliner", "Fehrbelliner",
"Fernbf", "Fernbf",
"Fernverkehr", "Fernverkehr",
"firmen",
"Flexpreis", "Flexpreis",
"Flix", "Flix",
"Fltr", "Fltr",
@ -266,7 +263,6 @@
"Hohenzollerndamm", "Hohenzollerndamm",
"Hüngheim", "Hüngheim",
"IBNR", "IBNR",
"identifikationsart",
"Ihren", "Ihren",
"Ihrer", "Ihrer",
"Informationen", "Informationen",
@ -614,7 +610,6 @@
"Zoologischer", "Zoologischer",
"Zuege", "Zuege",
"zugart", "zugart",
"Zugehoerigkeit",
"zugattrib", "zugattrib",
"zugattribute", "zugattribute",
"Zuges", "Zuges",

View file

@ -81,7 +81,6 @@ With `opt`, you can override the default options, which look like this:
firstClass: false, // first or second class for tickets firstClass: false, // first or second class for tickets
loyaltyCard: null, // BahnCards etc., see below loyaltyCard: null, // BahnCards etc., see below
language: 'en', // language to get results in language: 'en', // language to get results in
bmisNumber: null, // 7-digit BMIS number for business customer rates
} }
``` ```
@ -317,27 +316,6 @@ hafas.journeys(from, to, {
}) })
``` ```
## Using the `bmisNumber` option
bahn.business customers with a BMIS number can get their corporate rates and corporate tariffs by providing their 7-digit BMIS number:
```js
// Option 1: Using the bmisNumber parameter directly
await client.journeys(from, to, {
bmisNumber: '1234567' // Your 7-digit BMIS number
})
// Option 2: Using the createBusinessClient helper function
import {createBusinessClient} from 'db-vendo-client'
import {profile as dbProfile} from 'db-vendo-client/p/db/index.js'
const businessClient = createBusinessClient(dbProfile, userAgent, '1234567')
// Now all journey searches will automatically include the BMIS number
await businessClient.journeys(from, to)
```
When a BMIS number is provided, the request will include a `firmenZugehoerigkeit` object with the BMIS number and identification type, allowing business customers to access their special rates and conditions.
## The `routingMode` option ## The `routingMode` option
The `routingMode` option is not supported by db-vendo-client. The behavior will be the same as the [`HYBRID` mode of hafas-client](https://github.com/public-transport/hafas-client/blob/main/p/db/readme.md#using-the-routingmode-option), i.e. cancelled trains/infeasible journeys will also be contained for informational purpose. The `routingMode` option is not supported by db-vendo-client. The behavior will be the same as the [`HYBRID` mode of hafas-client](https://github.com/public-transport/hafas-client/blob/main/p/db/readme.md#using-the-routingmode-option), i.e. cancelled trains/infeasible journeys will also be contained for informational purpose.

View file

@ -183,7 +183,6 @@ const createClient = (profile, userAgent, opt = {}) => {
bestprice: false, // search for lowest prices across the entire day bestprice: false, // search for lowest prices across the entire day
deutschlandTicketDiscount: false, deutschlandTicketDiscount: false,
deutschlandTicketConnectionsOnly: false, deutschlandTicketConnectionsOnly: false,
bmisNumber: null, // 7-digit BMIS number for business customer rates
}, opt); }, opt);
if (opt.when !== undefined) { if (opt.when !== undefined) {
@ -244,7 +243,6 @@ const createClient = (profile, userAgent, opt = {}) => {
scheduledDays: false, // parse & expose dates the journey is valid on? scheduledDays: false, // parse & expose dates the journey is valid on?
deutschlandTicketDiscount: false, deutschlandTicketDiscount: false,
deutschlandTicketConnectionsOnly: false, deutschlandTicketConnectionsOnly: false,
bmisNumber: null, // 7-digit BMIS number for business customer rates
}, opt); }, opt);
const req = profile.formatRefreshJourneyReq({profile, opt}, refreshToken); const req = profile.formatRefreshJourneyReq({profile, opt}, refreshToken);
@ -397,33 +395,7 @@ const createClient = (profile, userAgent, opt = {}) => {
return client; return client;
}; };
const createBusinessClient = (profile, userAgent, bmisNumber, opt = {}) => {
if (!bmisNumber || typeof bmisNumber !== 'string') {
throw new TypeError('bmisNumber must be a non-empty string');
}
// Create a client with BMIS number included in all journey requests
const client = createClient(profile, userAgent, opt);
// Wrap journeys method to always include BMIS number
const originalJourneys = client.journeys;
client.journeys = async (from, to, opt = {}) => {
return originalJourneys(from, to, {...opt, bmisNumber});
};
// Wrap refreshJourney method to always include BMIS number
if (client.refreshJourney) {
const originalRefreshJourney = client.refreshJourney;
client.refreshJourney = async (refreshToken, opt = {}) => {
return originalRefreshJourney(refreshToken, {...opt, bmisNumber});
};
}
return client;
};
export { export {
createClient, createClient,
createBusinessClient,
loadEnrichedStationData, loadEnrichedStationData,
}; };

View file

@ -4,7 +4,7 @@ const formatBaseJourneysReq = (ctx) => {
// TODO opt.accessibility // TODO opt.accessibility
// TODO routingMode // TODO routingMode
const travellers = ctx.profile.formatTravellers(ctx); const travellers = ctx.profile.formatTravellers(ctx);
const baseReq = { return {
autonomeReservierung: false, autonomeReservierung: false,
einstiegsTypList: [ einstiegsTypList: [
'STANDARD', 'STANDARD',
@ -27,16 +27,6 @@ const formatBaseJourneysReq = (ctx) => {
}, },
reservierungsKontingenteVorhanden: false, reservierungsKontingenteVorhanden: false,
}; };
// Add business customer affiliation if BMIS number is provided
if (ctx.opt.bmisNumber) {
baseReq.firmenZugehoerigkeit = {
bmisNr: ctx.opt.bmisNumber,
identifikationsart: 'BMIS',
};
}
return baseReq;
}; };
const formatJourneysReq = (ctx, from, to, when, outFrwd, journeysRef) => { const formatJourneysReq = (ctx, from, to, when, outFrwd, journeysRef) => {

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "db-vendo-client", "name": "db-vendo-client",
"version": "6.9.0", "version": "6.8.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "db-vendo-client", "name": "db-vendo-client",
"version": "6.9.0", "version": "6.8.2",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"content-type": "^1.0.5", "content-type": "^1.0.5",

View file

@ -1,7 +1,7 @@
{ {
"name": "db-vendo-client", "name": "db-vendo-client",
"description": "Client for bahn.de public transport APIs.", "description": "Client for bahn.de public transport APIs.",
"version": "6.9.0", "version": "6.8.2",
"type": "module", "type": "module",
"main": "index.js", "main": "index.js",
"files": [ "files": [