mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
fix db price parsing
This commit is contained in:
parent
c10f31811a
commit
6de2dc7bf3
1 changed files with 22 additions and 10 deletions
|
@ -186,14 +186,26 @@ const parseJourneyWithPrice = ({parsed}, raw) => {
|
||||||
parsed.price = null
|
parsed.price = null
|
||||||
// todo: find cheapest, find discounts
|
// todo: find cheapest, find discounts
|
||||||
// todo: write a parser like vbb-parse-ticket
|
// todo: write a parser like vbb-parse-ticket
|
||||||
// [ {
|
// {
|
||||||
// prc: 15000,
|
// "statusCode": "OK",
|
||||||
// isFromPrice: true,
|
// "fareSetL": [
|
||||||
// isBookable: true,
|
// {
|
||||||
// isUpsell: false,
|
// "fareL": [
|
||||||
// targetCtx: 'D',
|
// {
|
||||||
// buttonText: 'To offer selection'
|
// "isFromPrice": true,
|
||||||
// } ]
|
// "isPartPrice": false,
|
||||||
|
// "isBookable": true,
|
||||||
|
// "isUpsell": false,
|
||||||
|
// "targetCtx": "D",
|
||||||
|
// "buttonText": "To offer selection",
|
||||||
|
// "price": {
|
||||||
|
// "amount": 11400
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
if (
|
if (
|
||||||
raw.trfRes &&
|
raw.trfRes &&
|
||||||
Array.isArray(raw.trfRes.fareSetL) &&
|
Array.isArray(raw.trfRes.fareSetL) &&
|
||||||
|
@ -202,9 +214,9 @@ const parseJourneyWithPrice = ({parsed}, raw) => {
|
||||||
raw.trfRes.fareSetL[0].fareL[0]
|
raw.trfRes.fareSetL[0].fareL[0]
|
||||||
) {
|
) {
|
||||||
const tariff = raw.trfRes.fareSetL[0].fareL[0]
|
const tariff = raw.trfRes.fareSetL[0].fareL[0]
|
||||||
if (tariff.prc >= 0) { // wat
|
if (tariff.price && tariff.price.amount >= 0) { // wat
|
||||||
parsed.price = {
|
parsed.price = {
|
||||||
amount: tariff.prc / 100,
|
amount: tariff.price.amount / 100,
|
||||||
currency: 'EUR',
|
currency: 'EUR',
|
||||||
hint: null
|
hint: null
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue