blob: 7042b2d923da5c87ef5421f6e715ef7673fcf97c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import { APIMissingTokenError, get } from "./client";
import store from "../store";
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 getCurrentVoucher = async (): Promise<Voucher> => {
const { voucherToken } = store.getState().authorization;
if (!voucherToken) {
throw new APIMissingTokenError();
}
return await get("/vouchers/me", {
headers: {
Authorization: `Bearer ${voucherToken}`,
},
}) as unknown as Voucher;
};
|