feat(tbank): add GET /positions endpoint with cursor pagination
This commit is contained in:
parent
6b3bdd2aec
commit
8b202ef7d3
@ -0,0 +1,18 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsNumber, IsOptional, IsString, Max, Min } from 'class-validator';
|
||||
|
||||
export class BrokerPositionQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Cursor for pagination (positionUid)' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
cursor?: string;
|
||||
|
||||
@ApiPropertyOptional({ default: 10 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
limit?: number = 10;
|
||||
}
|
||||
@ -7,7 +7,9 @@ import {
|
||||
BrokerOperationSyncEnvelopeDto,
|
||||
BrokerOperationsEnvelopeDto,
|
||||
BrokerPortfolioEnvelopeDto,
|
||||
BrokerPositionsEnvelopeDto,
|
||||
} from './dto/broker-envelope.dto';
|
||||
import { BrokerPositionQueryDto } from './dto/broker-position-query.dto';
|
||||
import { BrokerOperationQueryDto } from './dto/broker-operation-query.dto';
|
||||
import { BrokerOperationSyncQueryDto } from './dto/broker-operation-sync-query.dto';
|
||||
import { BrokerAccountsService } from './services/broker-accounts.service';
|
||||
@ -43,6 +45,21 @@ export class TBankController {
|
||||
return new ApiResponse(result.data, result.meta.fromCache, result.meta.cachedAt);
|
||||
}
|
||||
|
||||
@Get('accounts/:accountId/positions')
|
||||
@ApiOperation({ summary: 'Get paginated T-Bank broker account positions' })
|
||||
@ApiOkResponse({ type: BrokerPositionsEnvelopeDto })
|
||||
async getPositions(
|
||||
@Param('accountId') accountId: string,
|
||||
@Query() query: BrokerPositionQueryDto,
|
||||
) {
|
||||
const result = await this.brokerPortfolioService.getPositions(
|
||||
accountId,
|
||||
query.cursor,
|
||||
query.limit,
|
||||
);
|
||||
return new ApiResponse(result.data, result.meta.fromCache, result.meta.cachedAt);
|
||||
}
|
||||
|
||||
@Get('accounts/:accountId/operations')
|
||||
@ApiOperation({ summary: 'Get paginated T-Bank broker account operations' })
|
||||
@ApiOkResponse({ type: BrokerOperationsEnvelopeDto })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user