()
| 523 | private accessToken: string | null = null; |
| 524 | |
| 525 | async getAccessToken(): Promise<string> { |
| 526 | if (this.accessToken) return this.accessToken; |
| 527 | |
| 528 | const token = ConfigManager.get(CONFIG_KEYS.GEMINI_TELEGRAPH_TOKEN); |
| 529 | if (token) { |
| 530 | this.accessToken = token; |
| 531 | return token; |
| 532 | } |
| 533 | |
| 534 | const response = await HttpClient.makeRequest('https://api.telegra.ph/createAccount', { |
| 535 | method: 'POST', |
| 536 | data: { |
| 537 | short_name: 'PagerMaid-Gemini' |
| 538 | } |
| 539 | }); |
| 540 | |
| 541 | if (response.status === 200 && response.data.ok) { |
| 542 | const accessToken = response.data.result.access_token; |
| 543 | this.accessToken = accessToken; |
| 544 | ConfigManager.set(CONFIG_KEYS.GEMINI_TELEGRAPH_TOKEN, accessToken); |
| 545 | return accessToken; |
| 546 | } |
| 547 | |
| 548 | throw new Error('Failed to create Telegraph account'); |
| 549 | } |
| 550 | |
| 551 | async createPage(title: string, htmlContent: string): Promise<{ url: string; path: string }> { |
| 552 | const token = await this.getAccessToken(); |
no test coverage detected