Skip to content
Snippets Groups Projects
Commit 0d74662d authored by michael.minelli's avatar michael.minelli
Browse files

GitlabManager => Correct get user by id for the new gitlab api specs

parent 690cfff7
No related branches found
No related tags found
No related merge requests found
...@@ -18,22 +18,27 @@ class GitlabManager { ...@@ -18,22 +18,27 @@ class GitlabManager {
return `${ Config.gitlab.apiURL }${ route }`; return `${ Config.gitlab.apiURL }${ route }`;
} }
private async getGitlabUser(paramToSearch: string | number, paramName: string): Promise<GitlabUser | undefined> { public async getUserById(id: number): Promise<GitlabUser | undefined> {
try { try {
const params: any = {}; const params: any = {};
params[paramName] = paramToSearch; const user = (await axios.get<GitlabUser>(`${ this.getApiUrl(GitlabRoute.USERS_GET) }/${ String(id) }`, { params: params })).data;
return (await axios.get<Array<GitlabUser>>(this.getApiUrl(GitlabRoute.USERS_GET), { params: params })).data[0];
return user.id === id ? user : undefined;
} catch ( e ) { } } catch ( e ) { }
return undefined; return undefined;
} }
public async getUserById(id: number): Promise<GitlabUser | undefined> {
return await this.getGitlabUser(id, 'id');
}
public async getUserByUsername(username: string): Promise<GitlabUser | undefined> { public async getUserByUsername(username: string): Promise<GitlabUser | undefined> {
return await this.getGitlabUser(username, 'search'); try {
const params: any = {};
params['search'] = username;
const user = (await axios.get<Array<GitlabUser>>(this.getApiUrl(GitlabRoute.USERS_GET), { params: params })).data[0];
return user.username === username ? user : undefined;
} catch ( e ) { }
return undefined;
} }
async getRepository(idOrNamespace: string): Promise<GitlabRepository> { async getRepository(idOrNamespace: string): Promise<GitlabRepository> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment