add simple profile boilerplate

This commit is contained in:
Jannis R 2018-03-24 18:18:34 +01:00
parent 2430a74414
commit 27085d1db0
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 46 additions and 0 deletions

View 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

View file

@ -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: