type TriggerResponse = {
success: boolean;
pointsAdded: number;
triggerKey: string;
walletAddress: string;
};
async function fireRewardTrigger(
triggerKey: string,
walletAddress: string,
pointSystemId: string
): Promise<TriggerResponse> {
const res = await fetch("https://api.rewards.so/trigger", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.REWARDS_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ triggerKey, walletAddress, pointSystemId }),
});
if (!res.ok) {
const error = await res.json();
throw new Error(error.message ?? `HTTP ${res.status}`);
}
return res.json();
}