* Get current usage limits and quota information
()
| 483 | * Get current usage limits and quota information |
| 484 | */ |
| 485 | async getUsageLimits(): Promise<UsageLimits> { |
| 486 | const url = `${this.baseUrl}/api/users/me/usage-limits` |
| 487 | |
| 488 | try { |
| 489 | const response = await fetch(url, { |
| 490 | method: 'GET', |
| 491 | headers: { |
| 492 | 'X-API-Key': this.apiKey, |
| 493 | }, |
| 494 | }) |
| 495 | |
| 496 | this.updateRateLimitInfo(response) |
| 497 | |
| 498 | if (!response.ok) { |
| 499 | const errorData = (await response.json().catch(() => ({}))) as unknown as any |
| 500 | throw new SimStudioError( |
| 501 | errorData.error || `HTTP ${response.status}: ${response.statusText}`, |
| 502 | errorData.code, |
| 503 | response.status |
| 504 | ) |
| 505 | } |
| 506 | |
| 507 | const result = await response.json() |
| 508 | return result as UsageLimits |
| 509 | } catch (error: any) { |
| 510 | if (error instanceof SimStudioError) { |
| 511 | throw error |
| 512 | } |
| 513 | |
| 514 | throw new SimStudioError(error?.message || 'Failed to get usage limits', 'USAGE_ERROR') |
| 515 | } |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | export { SimStudioClient as default } |
no test coverage detected