mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
add simple profile boilerplate
This commit is contained in:
parent
2430a74414
commit
27085d1db0
2 changed files with 46 additions and 0 deletions
44
docs/profile-boilerplate.js
Normal file
44
docs/profile-boilerplate.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
'use strict'
|
||||
|
||||
// see the ./writing-a-profile.md guide
|
||||
const products = [
|
||||
{
|
||||
id: 'nationalExp',
|
||||
mode: 'train',
|
||||
bitmasks: [1],
|
||||
name: 'InterCityExpress',
|
||||
short: 'ICE',
|
||||
default: true
|
||||
},
|
||||
{
|
||||
id: 'national',
|
||||
mode: 'train',
|
||||
bitmasks: [2],
|
||||
name: 'InterCity & EuroCity',
|
||||
short: 'IC/EC',
|
||||
default: true
|
||||
}
|
||||
]
|
||||
|
||||
const transformReqBody = (body) => {
|
||||
// get these from the recorded app requests
|
||||
// body.client = { … }
|
||||
// body.ver = …
|
||||
// body.auth = { … }
|
||||
// body.lang = …
|
||||
return body
|
||||
}
|
||||
|
||||
const insaProfile = {
|
||||
// locale: …,
|
||||
// timezone: …,
|
||||
// endpoint: …,
|
||||
transformReqBody,
|
||||
|
||||
products: products,
|
||||
|
||||
journeyLeg: false,
|
||||
radar: false
|
||||
}
|
||||
|
||||
module.exports = insaProfile
|
|
@ -78,6 +78,8 @@ If you pass this profile into `hafas-client`, the `parseLine` method will overri
|
|||
- Add a function `transformReqBody(body)` to your profile, which assigns them to `body`.
|
||||
- Some profiles have a `checksum` parameter (like [here](https://gist.github.com/derhuerst/2a735268bd82a0a6779633f15dceba33#file-journey-details-1-http-L1)) or two `mic` & `mac` parameters (like [here](https://gist.github.com/derhuerst/5fa86ed5aec63645e5ae37e23e555886#file-1-http-L1)). If you see one of them in your requests, jump to [*Appendix A: checksum, mic, mac*](#appendix-a-checksum-mic-mac). Unfortunately, this is necessary to get the profile working.
|
||||
|
||||
You may want to use the [profile boilerplate code](profile-boilerplate.js).
|
||||
|
||||
## 3. Products
|
||||
|
||||
In `hafas-client`, there's a difference between the `mode` and the `product` field:
|
||||
|
|
Loading…
Add table
Reference in a new issue