//native
type Brex = {
token: string;
};
/**
*
Terminate card
*
Terminates an existing card. The card owner will receive a notification about it.
*/
export async function main(
auth: Brex,
id: string,
body: {
description?: string;
reason:
| "CARD_DAMAGED"
| "CARD_LOST"
| "CARD_NOT_RECEIVED"
| "DO_NOT_NEED_PHYSICAL_CARD"
| "DO_NOT_NEED_VIRTUAL_CARD"
| "FRAUD"
| "OTHER";
},
Idempotency_Key?: string,
) {
const url = new URL(`https://platform.brexapis.com/v2/cards/${id}/terminate`);
const response = await fetch(url, {
method: "POST",
headers: {
...(Idempotency_Key ? { "Idempotency-Key": Idempotency_Key } : {}),
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 217 days ago