Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
8148a47d
Commit
8148a47d
authored
Jul 14, 2021
by
Volker Krause
Browse files
Handle SNCF TER booking confirmations
BUG: 439055
CCBUG: 404451
FIXED-IN: 21.08.0
parent
16ff2755
Pipeline
#70700
skipped
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/lib/scripts/sncf.js
View file @
8148a47d
...
...
@@ -412,3 +412,24 @@ function parseOuigoTicket(pdf, node) {
}
return
res
;
}
function
parseTerConfirmation
(
html
)
{
var
reservations
=
new
Array
();
const
refNum
=
html
.
eval
(
'
//td[@id="referenceContainer"]
'
)[
0
].
content
;
const
name
=
html
.
eval
(
'
//td[@id="nomReferenceContainer"]
'
)[
0
].
content
;
const
journeys
=
html
.
eval
(
'
//table[@id ="emailTrajet" or @id="emailTrajetRetour"]
'
);
for
(
const
journey
of
journeys
)
{
var
res
=
JsonLd
.
newTrainReservation
();
const
dt
=
journey
.
eval
(
'
.//h2
'
)[
0
].
content
.
match
(
/
(\d
.*
)
$/
)[
1
];
res
.
reservationFor
.
departureDay
=
JsonLd
.
toDateTime
(
dt
,
"
dd MMMM yyyy
"
,
"
fr
"
);
const
ps
=
journey
.
eval
(
'
.//p
'
);
res
.
reservationFor
.
departureStation
.
name
=
ps
[
0
].
content
;
res
.
reservationFor
.
departureTime
=
JsonLd
.
toDateTime
(
ps
[
1
].
content
.
match
(
/
(\d
.*
)
/
)[
1
],
"
hh'h'mm
"
,
"
fr
"
);
res
.
reservationFor
.
arrivalStation
.
name
=
ps
[
2
].
content
;
res
.
reservationFor
.
arrivalTime
=
JsonLd
.
toDateTime
(
ps
[
3
].
content
.
match
(
/
(\d
.*
)
/
)[
1
],
"
hh'h'mm
"
,
"
fr
"
);
res
.
reservationNumber
=
refNum
;
res
.
underName
.
name
=
name
;
reservations
.
push
(
res
);
}
return
reservations
;
}
src/lib/scripts/sncf.json
View file @
8148a47d
...
...
@@ -14,19 +14,20 @@
}
],
"function"
:
"parsePdf"
,
"
script"
:
"sncf.js
"
,
"
mimeType"
:
"application/pdf
"
"
mimeType"
:
"application/pdf
"
,
"
script"
:
"sncf.js
"
},
{
"filter"
:
[
{
"match"
:
"^i[01]CV"
,
"mimeType"
:
"text/plain"
"mimeType"
:
"text/plain"
,
"scope"
:
"Current"
}
],
"function"
:
"parseSncfBarcode"
,
"
script"
:
"sncf.js
"
,
"
mimeType"
:
"text/plain
"
"
mimeType"
:
"text/plain
"
,
"
script"
:
"sncf.js
"
},
{
"filter"
:
[
...
...
@@ -38,8 +39,8 @@
}
],
"function"
:
"parseSncfPdfText"
,
"
script"
:
"sncf.js
"
,
"
mimeType"
:
"text/plain
"
"
mimeType"
:
"text/plain
"
,
"
script"
:
"sncf.js
"
},
{
"filter"
:
[
...
...
@@ -50,8 +51,8 @@
}
],
"function"
:
"parseSecutixPdf"
,
"
script"
:
"sncf.js
"
,
"
mimeType"
:
"application/pdf
"
"
mimeType"
:
"application/pdf
"
,
"
script"
:
"sncf.js
"
},
{
"filter"
:
[
...
...
@@ -63,8 +64,8 @@
}
],
"function"
:
"parseOuigoEmail"
,
"
script"
:
"sncf.js
"
,
"
mimeType"
:
"text/html
"
"
mimeType"
:
"text/html
"
,
"
script"
:
"sncf.js
"
},
{
"filter"
:
[
...
...
@@ -76,7 +77,26 @@
}
],
"function"
:
"parseOuigoTicket"
,
"script"
:
"sncf.js"
,
"mimeType"
:
"application/pdf"
"mimeType"
:
"application/pdf"
,
"script"
:
"sncf.js"
},
{
"filter"
:
[
{
"field"
:
"From"
,
"match"
:
"@ter-sncf.fr"
,
"mimeType"
:
"message/rfc822"
,
"scope"
:
"Ancestors"
},
{
"field"
:
"From"
,
"match"
:
"@ter.fr"
,
"mimeType"
:
"message/rfc822"
,
"scope"
:
"Ancestors"
}
],
"function"
:
"parseTerConfirmation"
,
"mimeType"
:
"text/html"
,
"script"
:
"sncf.js"
}
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment