|
1 | | -import { Controller, DefaultValuePipe, Get, ParseIntPipe, Query } from "@nestjs/common"; |
| 1 | +import { Controller, DefaultValuePipe, Get, Param, ParseIntPipe, Query } from "@nestjs/common"; |
2 | 2 | import { ApiOkResponse, ApiOperation, ApiQuery, ApiTags } from "@nestjs/swagger"; |
3 | 3 | import { SortOrder } from "src/common/entities/sort.order"; |
4 | 4 | import { QueryPagination } from "src/common/entities/query.pagination"; |
5 | 5 | import { ApplicationsService } from "./applications.service"; |
6 | 6 | import { Applications } from "./entities/applications"; |
7 | 7 | import { ApplicationFilter, UsersCountRange } from "./entities/application.filter"; |
8 | 8 | import { ApplicationSort } from "./entities/application.sort"; |
9 | | -import { ParseAddressArrayPipe, ParseEnumPipe, ParseBoolPipe } from "@multiversx/sdk-nestjs-common"; |
| 9 | +import { ParseAddressArrayPipe, ParseEnumPipe, ParseBoolPipe, ParseAddressPipe } from "@multiversx/sdk-nestjs-common"; |
10 | 10 |
|
11 | 11 | @Controller() |
12 | 12 | @ApiTags('applications') |
@@ -86,4 +86,17 @@ export class ApplicationsController { |
86 | 86 |
|
87 | 87 | return await this.applicationsService.getApplicationsCount(filter); |
88 | 88 | } |
| 89 | + |
| 90 | + @Get('/applications/:address') |
| 91 | + @ApiOperation({ summary: 'Smart Contract Application', description: 'Returns a smart contract application' }) |
| 92 | + @ApiOkResponse({ type: Applications }) |
| 93 | + @ApiQuery({ name: 'usersCountRange', description: 'Range for users count calculation', required: false, enum: UsersCountRange }) |
| 94 | + @ApiQuery({ name: 'feesRange', description: 'Range for fees captured calculation', required: false, enum: UsersCountRange }) |
| 95 | + async getApplication( |
| 96 | + @Param('address', ParseAddressPipe) address: string, |
| 97 | + @Query('usersCountRange', new ParseEnumPipe(UsersCountRange)) usersCountRange?: UsersCountRange, |
| 98 | + @Query('feesRange', new ParseEnumPipe(UsersCountRange)) feesRange?: UsersCountRange, |
| 99 | + ): Promise<Applications> { |
| 100 | + return await this.applicationsService.getApplication(address, usersCountRange, feesRange); |
| 101 | + } |
89 | 102 | } |
0 commit comments