@cityssm/mto-handler
v0.2.0
Published
Generates files compatible with the Ontario Ministry of Transportation's Authorized Requester Information Services (ARIS). Parses files downloaded from ARIS.
Downloads
92
Readme
MTO ARIS Handler for Node
Generates files compatible with the Ontario Ministry of Transportation's Authorized Requester Information Services (ARIS). Parses files downloaded from ARIS.
Installation
npm install @cityssm/mto-handler
Usage
import fs from 'node:fs/promises'
import { MTOBatchWriter, parseMTOBatchResult } from '@cityssm/mto-handler'
/*
* Generate a file to send to MTO
*/
const writer = new MTOBatchWriter({
authorizedUser: 'XXXX',
includeLabels: false,
sentDate: '2024-03-19'
})
writer.addBatchEntry({
issueDate: '2024-01-01',
ticketNumber: 'TKT12345',
licencePlateNumber: 'SAMPLE'
})
const fileData = writer.writeBatch()
await fs.writeFile('./path/to/uploadToMto.txt', fileData)
/*
* Parse data retrieved from MTO
*/
const resultsBuffer = await fs.readFile('./path/to/downloadedFromMto.txt')
const resultsData = resultsBuffer.toString()
const results = await parseMTOBatchResult(resultsData)