aboutsummaryrefslogtreecommitdiffstats
path: root/thallium-frontend/src
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-08-19 17:05:30 +0100
committerGravatar Joe Banks <[email protected]>2024-08-19 17:05:30 +0100
commit686ec81c0c43bd447cd672f0e3881fc30a631442 (patch)
tree10f0caef85cd646157f8cebfd01fe0095983a165 /thallium-frontend/src
parentAdd API client (diff)
Add vouchers client
Diffstat (limited to 'thallium-frontend/src')
-rw-r--r--thallium-frontend/src/api/vouchers.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/thallium-frontend/src/api/vouchers.ts b/thallium-frontend/src/api/vouchers.ts
new file mode 100644
index 0000000..deb0af7
--- /dev/null
+++ b/thallium-frontend/src/api/vouchers.ts
@@ -0,0 +1,27 @@
+import { get, post } from "./client";
+
+export interface Voucher {
+ id: string;
+ voucher_code: string;
+ active: boolean;
+ balance: string;
+ created_at: string;
+ updated_at: string;
+}
+
+export interface VoucherClaim {
+ voucher_code: string;
+ jwt: string;
+}
+
+export const validateVoucher = async (voucher_code: string): Promise<VoucherClaim> => {
+ return await post("/voucher-login", { voucher_code }) as unknown as VoucherClaim;
+};
+
+export const getCurrentVoucher = async (voucherJWT: string): Promise<Voucher> => {
+ return await get("/vouchers/me", {
+ headers: {
+ Authorization: `Bearer ${voucherJWT}`,
+ },
+ }) as unknown as Voucher;
+};