From 7e2dd0b627ba192f73de4d7110f4b433e8b394af Mon Sep 17 00:00:00 2001 From: GreyC <4105526+GreyC@users.noreply.github.com> Date: Fri, 13 Mar 2026 10:36:03 +0000 Subject: [PATCH] Refactor JulesClient to consolidate header construction Introduced a private static method `buildHeaders` to eliminate duplication in header creation logic. This allows both the instance method `getHeaders` and the static method `validateKey` to share the same header definition. - Added `private static buildHeaders(apiKey: string)` - Updated `getHeaders()` to use `buildHeaders` - Updated `static validateKey(apiKey: string)` to use `buildHeaders` Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- packages/cli/src/client.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/client.ts b/packages/cli/src/client.ts index 497f4b4..f1499dd 100644 --- a/packages/cli/src/client.ts +++ b/packages/cli/src/client.ts @@ -9,20 +9,21 @@ export class JulesClient { this.apiKey = apiKey || getApiKey(); } - private getHeaders(): Record { + private static buildHeaders(apiKey: string): Record { return { - 'x-goog-api-key': this.apiKey, + 'x-goog-api-key': apiKey, 'Content-Type': 'application/json', }; } + private getHeaders(): Record { + return JulesClient.buildHeaders(this.apiKey); + } + static async validateKey(apiKey: string): Promise { const response = await fetch(`${BASE_URL}/sessions`, { method: 'GET', - headers: { - 'x-goog-api-key': apiKey, - 'Content-Type': 'application/json', - }, + headers: JulesClient.buildHeaders(apiKey), }); if (!response.ok) {