Skip to content

Commit 998a487

Browse files
authored
Merge pull request #539 from Sanofi-IADC/feat/ARM-1357
feat: ARM-1357 add API to get versions on a project
2 parents d35344f + 4ded270 commit 998a487

File tree

5 files changed

+92
-8
lines changed

5 files changed

+92
-8
lines changed

src/jira/jira.service.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ export class JiraService {
117117
},
118118
),
119119
)
120-
.then((response) => response.data)
120+
.then((response) => {
121+
this.logger.log('Retrieving findTickets');
122+
return response;
123+
})
121124
.catch((e) => {
122125
this.logger.log(e, 'error:findTickets');
123126
});
@@ -418,6 +421,32 @@ export class JiraService {
418421
});
419422
}
420423

424+
/**
425+
* @function findProjectVersions Service
426+
* @description Returns the list of project versions.
427+
* @return Promise {any}
428+
*/
429+
async findProjectVersions(projectIdOrKey: string): Promise<AxiosResponse> {
430+
this.init();
431+
return firstValueFrom(
432+
this.http.get(
433+
`${this.baseUrl}/rest/api/3/project/${projectIdOrKey}/versions`,
434+
{ auth: { username: this.apiUsername, password: this.apiToken } },
435+
),
436+
)
437+
.then((response) => {
438+
this.logger.log('Retrieving findProjectVersions');
439+
return response;
440+
})
441+
.catch((err) => {
442+
this.logger.log(err, 'error:findProjectVersions');
443+
throw new HttpException(
444+
`error:API findProjectVersions > ${err}`,
445+
404,
446+
);
447+
});
448+
}
449+
421450
/**
422451
* @function findProjectMetadata Service
423452
* @description Return a the projects metadata
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ApiProperty } from '@nestjs/swagger';
2+
import {
3+
IsNotEmpty, IsString,
4+
} from 'class-validator';
5+
6+
export default class SearchProjectVersionsQueryDTO {
7+
@ApiProperty({
8+
type: String,
9+
description: 'The Jira project key or Id',
10+
example: '"FACTSWT" or "10000"',
11+
})
12+
@IsNotEmpty()
13+
@IsString()
14+
projectIdOrKey: string;
15+
}

src/proxy-api/proxy-api.controller.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import {
1616
GetSpacesParamsDTO,
1717
GetSpacesQueryDTO,
1818
} from './proxy-api.validation.dto';
19-
import { KonviwResults } from './proxy-api.interface';
19+
import { FixVersion, KonviwResults } from './proxy-api.interface';
2020
import SearchProjectIssueTypesWithStatusQueryDTO from './dto/SearchProjectIssueTypesWithStatusQuery';
2121
import GetScreenDetailsDTO from './dto/GetScreenDetailsQuery';
2222
import SearchProjectUsersQueryDTO from './dto/SearchProjectUsersQuery';
23+
import SearchProjectVersionsQueryDTO from './dto/SearchProjectVersionsQuery';
2324

2425
@ApiTags('proxy-api')
2526
@Controller('api')
@@ -171,6 +172,21 @@ export class ProxyApiController {
171172
return this.proxyApi.getJiraUsersByQuery(queries.query, queries.startAt, queries.maxResults);
172173
}
173174

175+
/**
176+
* @GET (controller) api/projects/versions
177+
* @description Returns all versions in a project
178+
* @return {string} 'JSON' - Returns the valid versions for a project.
179+
*/
180+
@ApiOkResponse({
181+
description: 'List project versions',
182+
})
183+
@Get('projects/versions')
184+
async getJiraProjectVersions(
185+
@Query() queries: SearchProjectVersionsQueryDTO,
186+
): Promise<FixVersion> {
187+
return this.proxyApi.getJiraProjectVersions(queries.projectIdOrKey);
188+
}
189+
174190
/**
175191
* @GET (controller) api/spaces
176192
* @description Route to retrieve the Confluence spaces of a type

src/proxy-api/proxy-api.interface.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,17 @@ export interface MetadataSearch {
3737
next: string;
3838
prev: string;
3939
}
40+
41+
export interface FixVersion {
42+
archived: boolean;
43+
id: string;
44+
name: string;
45+
overdue: boolean;
46+
projectId: number;
47+
releaseDate: string;
48+
released: boolean;
49+
self: string;
50+
startDate: string;
51+
userReleaseDate: string;
52+
userStartDate: string;
53+
}

src/proxy-api/proxy-api.service.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,15 @@ export class ProxyApiService {
252252
maxResults: number,
253253
reader?: boolean,
254254
): Promise<any> {
255-
const {
256-
total, issues,
257-
}: any = await this.jira.findTickets(
255+
const { data }: any = await this.jira.findTickets(
258256
server,
259257
jqlSearch,
260258
fields,
261259
startAt,
262260
maxResults,
263261
reader,
264262
);
265-
const parseResults = issues.map((issue: any) => ({
263+
const parseResults = data.issues.map((issue: any) => ({
266264
id: issue.id,
267265
key: issue.key,
268266
selfUri: issue.self,
@@ -275,7 +273,7 @@ export class ProxyApiService {
275273
}));
276274

277275
const meta = {
278-
totalSize: total,
276+
totalSize: data.total,
279277
server,
280278
};
281279

@@ -359,7 +357,6 @@ export class ProxyApiService {
359357
*/
360358
async getJiraUsersByQuery(query: string, startAt: number, maxResults: number): Promise<any> {
361359
const { data, total }: any = await this.jira.findUsersByQuery(query, startAt, maxResults);
362-
this.logger.log(data.values);
363360
const parseResults = data.values.map((user: any) => ({
364361
id: user.accountId,
365362
name: user.displayName,
@@ -378,6 +375,19 @@ export class ProxyApiService {
378375
};
379376
}
380377

378+
/**
379+
* @function getJiraProjectVersions Service
380+
* @description Finds users with a structured query and returns a paginated list of user details
381+
* @return Promise {any}
382+
* @param query {string}
383+
*/
384+
async getJiraProjectVersions(projectIdOrKey: string): Promise<any> {
385+
const { data }: any = await this.jira.findProjectVersions(projectIdOrKey);
386+
return {
387+
fixVersions: data,
388+
};
389+
}
390+
381391
/**
382392
* @function getAllSpaces Service
383393
* @description Retrieve all spaces from a Confluence server

0 commit comments

Comments
 (0)