export interface GitHubRepository {
	id: number;
	name: string;
	full_name: string;
	html_url: string;
	ssh_url: string;
	description: string | null;
	private: boolean;
	default_branch: string;
}

export interface GitHubService {
	/**
	 * Fetches a list of repositories for the authenticated user
	 * @returns Promise resolving to an array of GitHub repositories
	 */
	getRepositories(): Promise<GitHubRepository[]>;
}

export class GitHubServiceImpl implements GitHubService {
	private projectId: string;

	constructor(projectId: string) {
		this.projectId = projectId;
	}

	async getRepositories(): Promise<GitHubRepository[]> {
		const response = await fetch(`/api/project/${this.projectId}/repos/github`);

		if (!response.ok) {
			throw new Error(`Failed to fetch repositories: ${response.statusText}`);
		}

		return response.json();
	}
}
