mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
DB: support age group by age API
This commit is contained in:
parent
7a3fd4fca5
commit
1236cf63a0
1 changed files with 7 additions and 2 deletions
|
@ -19,7 +19,7 @@ const {bike} = require('../../format/filters')
|
|||
const products = require('./products')
|
||||
const baseProfile = require('./base.json')
|
||||
const formatLoyaltyCard = require('./loyalty-cards').format
|
||||
const {ageGroup} = require('./ageGroup')
|
||||
const {ageGroup, ageGroupFromAge} = require('./ageGroup')
|
||||
|
||||
const transformReqBody = (ctx, body) => {
|
||||
const req = body.svcReqL[0] || {}
|
||||
|
@ -156,11 +156,16 @@ const transformJourneysQuery = ({opt}, query) => {
|
|||
const filters = query.jnyFltrL
|
||||
if (opt.bike) filters.push(bike)
|
||||
|
||||
if (('age' in opt) && ('ageGroup' in opt))
|
||||
throw new TypeError('opt.age and opt.ageGroup are mutually exclusive.')
|
||||
|
||||
const tvlrAgeGroup = ('age' in opt) ? ageGroupFromAge(opt.age) : opt.ageGroup
|
||||
|
||||
query.trfReq = {
|
||||
jnyCl: opt.firstClass === true ? 1 : 2,
|
||||
// todo [breaking]: support multiple travelers
|
||||
tvlrProf: [{
|
||||
type: opt.ageGroup || ageGroup.ADULT,
|
||||
type: tvlrAgeGroup || ageGroup.ADULT,
|
||||
redtnCard: opt.loyaltyCard
|
||||
? formatLoyaltyCard(opt.loyaltyCard)
|
||||
: null
|
||||
|
|
Loading…
Add table
Reference in a new issue