All files / api/trimet-client/src alerts.ts

100% Statements 4/4
100% Branches 1/1
100% Functions 4/4
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22              3x       1x       1x       1x    
import type { AlertsData } from "./interfaces/alertsData";
import type { TrimetClientOptions } from "./options";
import { getTrimetData } from "./util";
 
type AlertRequestOptions = Pick<TrimetClientOptions, "baseUrl" | "appId">;
 
function requestAlerts({ baseUrl, appId }: AlertRequestOptions, scope = "") {
  return getTrimetData<AlertsData>(`${baseUrl}v2/alerts/json/true/${scope}appID/${appId}`);
}
 
export function getAlertsByRouteId(id: number, options: AlertRequestOptions) {
  return requestAlerts(options, `route/${id}/`);
}
 
export function getAlertsByLocationId(id: number, options: AlertRequestOptions) {
  return requestAlerts(options, `locIDs/${id}/`);
}
 
export function getSystemAlerts(options: AlertRequestOptions) {
  return requestAlerts(options);
}