//native
type Tomorrow = {
apiKey: string;
};
/**
* List Notifications
*
*/
export async function main(
auth: Tomorrow,
startTime: string | undefined,
endTime: string | undefined,
alertIds: string | undefined,
notificationTypes: string | undefined,
recipients: string | undefined,
status: string | undefined,
locationIds: string | undefined,
Accept_Encoding?: string,
) {
const url = new URL(`https://api.tomorrow.io/v4/notifications`);
for (const [k, v] of [
["startTime", startTime],
["endTime", endTime],
["alertIds", alertIds],
["notificationTypes", notificationTypes],
["recipients", recipients],
["status", status],
["locationIds", locationIds],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
...(Accept_Encoding ? { "Accept-Encoding": Accept_Encoding } : {}),
ApiKey: auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago