From b41abc797969c6501778d227a58c12306e4e46d9 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sun, 3 Jan 2021 08:49:38 +0100 Subject: [PATCH] Output the case number --- src/index.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 70917ca..7ce8c0c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,7 +52,8 @@ export async function submit( reason: string, photos: Array, timestamp: Date, - contact_details: ContactDetails + contact_details: ContactDetails, + plate: string ) { if (location.address.includes("\n")) { throw new Error("no newlines allowed in address"); @@ -74,7 +75,9 @@ export async function submit( const [date_str, hour] = formatTimestamp(timestamp); - const body = `Samochód ${reason || ""}. Zdjęci${ + const body = `Samochód ${ + reason || "" + }. Numer rejestracyjny samochodu: ${plate} Zdjęci${ photos.length === 1 ? "e" : "a" } wykonane ${date_str} o godz. ${hour} w pobliżu ul. ${ location.address @@ -178,5 +181,11 @@ export async function submit( "--data", `action=save&source=summary&instance=poznan_sm&x=${x}&y=${y}&lon=${x}&lat=${y}&srs=EPSG%3A2177&goto_thanks=`, ]); - console.log(response); + const matches = response.match( + /
  • Numer: ([0-9]+)<\/strong><\/li>/ + ); + if (matches === null) { + throw new Error("Could not extract submission number"); + } + return matches[1]; }