| 117 | } |
| 118 | |
| 119 | export async function getSkillQuota(accessToken: string): Promise<SkillQuotaResponse> { |
| 120 | const response = await fetch(`${baseUrl}/api/v2/skills/quota`, { |
| 121 | headers: { Authorization: `Bearer ${accessToken}` }, |
| 122 | }); |
| 123 | |
| 124 | if (!response.ok) { |
| 125 | const errorData = await response.json().catch(() => ({})); |
| 126 | return { |
| 127 | used: 0, |
| 128 | limit: 0, |
| 129 | remaining: 0, |
| 130 | tier: "free", |
| 131 | resetDate: null, |
| 132 | error: (errorData as { message?: string }).message || `HTTP error ${response.status}`, |
| 133 | }; |
| 134 | } |
| 135 | |
| 136 | return (await response.json()) as SkillQuotaResponse; |
| 137 | } |
| 138 | |
| 139 | export async function getSkillQuestions( |
| 140 | libraries: Array<{ id: string; name: string }>, |