export class GitLabDiffStatsFetchGateway {
    executor;
    constructor(executor) {
        this.executor = executor;
    }
    fetchDiffStats(projectPath, mergeRequestNumber) {
        try {
            const encodedProject = projectPath.replace(/\//g, '%2F');
            const mrResponse = this.executor(`glab api projects/${encodedProject}/merge_requests/${mergeRequestNumber}`);
            const mergeRequest = JSON.parse(mrResponse);
            if (typeof mergeRequest.additions !== 'number' ||
                typeof mergeRequest.deletions !== 'number') {
                return null;
            }
            const commitsResponse = this.executor(`glab api projects/${encodedProject}/merge_requests/${mergeRequestNumber}/commits`);
            const commits = JSON.parse(commitsResponse);
            return {
                additions: mergeRequest.additions,
                deletions: mergeRequest.deletions,
                commitsCount: Array.isArray(commits) ? commits.length : 0,
            };
        }
        catch {
            return null;
        }
    }
}
//# sourceMappingURL=diffStatsFetch.gitlab.gateway.js.map