From 42959879e7496c2034d255dc4c400298e370b8cc Mon Sep 17 00:00:00 2001 From: Alexander Petkov Date: Wed, 25 Oct 2023 16:13:55 +0300 Subject: [PATCH] swagger: Provide schema for iris-transaction-test endpoint --- .../bank-transactions.controller.ts | 12 +++++++++++- .../dto/bank-transactions-iris-simulate.dto.ts | 2 +- .../dto/iris-bank-account-info.dto.ts | 3 +++ .../dto/iris-bank-transaction-info.dto.ts | 15 +++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/apps/api/src/bank-transactions/bank-transactions.controller.ts b/apps/api/src/bank-transactions/bank-transactions.controller.ts index 33ce74af0..1143b55d6 100644 --- a/apps/api/src/bank-transactions/bank-transactions.controller.ts +++ b/apps/api/src/bank-transactions/bank-transactions.controller.ts @@ -5,6 +5,7 @@ import { Controller, ForbiddenException, Get, + HttpCode, Logger, NotFoundException, Param, @@ -13,7 +14,7 @@ import { Query, Res, } from '@nestjs/common' -import { ApiQuery, ApiTags } from '@nestjs/swagger' +import { ApiBody, ApiOperation, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger' import { RealmViewSupporters, ViewSupporters } from '@podkrepi-bg/podkrepi-types' import { Roles, RoleMatchingMode, AuthenticatedUser } from 'nest-keycloak-connect' import { KeycloakTokenParsed, isAdmin } from '../auth/keycloak' @@ -28,6 +29,8 @@ import { DateTime, Interval } from 'luxon' import { ConfigService } from '@nestjs/config' import { IrisBankTransactionSimulationDto } from './dto/bank-transactions-iris-simulate.dto' import { AffiliateService } from '../affiliate/affiliate.service' +import { IrisIbanAccountInfoDto } from './dto/iris-bank-account-info.dto' +import { IrisTransactionInfoDto } from './dto/iris-bank-transaction-info.dto' @ApiTags('bank-transaction') @Controller('bank-transaction') @@ -152,6 +155,13 @@ export class BankTransactionsController { }) } + @ApiOperation({ summary: 'Simulating bank transaction response from IRIS API' }) + @ApiResponse({ status: 204 }) + @ApiBody({ + type: IrisBankTransactionSimulationDto, + description: 'Request body for simulating IRIS response', + }) + @HttpCode(204) @Post('iris-transaction-test') async testIrisInsertion( @Body() irisDto: IrisBankTransactionSimulationDto, diff --git a/apps/api/src/bank-transactions/dto/bank-transactions-iris-simulate.dto.ts b/apps/api/src/bank-transactions/dto/bank-transactions-iris-simulate.dto.ts index 100491ea6..065200b78 100644 --- a/apps/api/src/bank-transactions/dto/bank-transactions-iris-simulate.dto.ts +++ b/apps/api/src/bank-transactions/dto/bank-transactions-iris-simulate.dto.ts @@ -13,7 +13,7 @@ export class IrisBankTransactionSimulationDto { @Type(() => IrisIbanAccountInfoDto) irisIbanAccountInfo: IrisIbanAccountInfoDto - @ApiProperty() + @ApiProperty({ type: () => IrisTransactionInfoDto }) @Expose() @IsArray() @ValidateNested({ each: true }) diff --git a/apps/api/src/bank-transactions/dto/iris-bank-account-info.dto.ts b/apps/api/src/bank-transactions/dto/iris-bank-account-info.dto.ts index f2e9a2ee8..1e671831d 100644 --- a/apps/api/src/bank-transactions/dto/iris-bank-account-info.dto.ts +++ b/apps/api/src/bank-transactions/dto/iris-bank-account-info.dto.ts @@ -1,3 +1,4 @@ +import { ApiProperty } from '@nestjs/swagger' import { Currency } from '@prisma/client' import { Expose } from 'class-transformer' import { IsIBAN, IsString } from 'class-validator' @@ -12,6 +13,7 @@ export class IrisIbanAccountInfoDto { name: string + @ApiProperty() @IsString() @IsIBAN() @Expose() @@ -23,6 +25,7 @@ export class IrisIbanAccountInfoDto { bankHash: string + @ApiProperty() @IsString() @Expose() bankName: string diff --git a/apps/api/src/bank-transactions/dto/iris-bank-transaction-info.dto.ts b/apps/api/src/bank-transactions/dto/iris-bank-transaction-info.dto.ts index cf832605c..6ff9cf07b 100644 --- a/apps/api/src/bank-transactions/dto/iris-bank-transaction-info.dto.ts +++ b/apps/api/src/bank-transactions/dto/iris-bank-transaction-info.dto.ts @@ -1,3 +1,4 @@ +import { ApiProperty } from '@nestjs/swagger' import { Currency } from '@prisma/client' import { Expose, Type } from 'class-transformer' import { @@ -11,6 +12,7 @@ import { } from 'class-validator' class bankAccountDto { + @ApiProperty() @IsString() @IsIBAN() @Expose() @@ -18,65 +20,78 @@ class bankAccountDto { } class transactionAmountDto { + @ApiProperty() @IsNumber() @Expose() amount: number + @ApiProperty() @IsEnum(Currency) @Expose() currency: Currency } export class IrisTransactionInfoDto { + @ApiProperty() @IsString() @Expose() transactionId: string + @ApiProperty() @IsString() @Expose() bookingDate: string + @ApiProperty() @IsObject() @Expose() @Type(() => bankAccountDto) @ValidateNested({ each: true }) debtorAccount: bankAccountDto + @ApiProperty() @IsObject() @Expose() @Type(() => bankAccountDto) @ValidateNested({ each: true }) creditorAccount: bankAccountDto + @ApiProperty() @IsOptional() @IsString() @Expose() creditorName: string | null + @ApiProperty() @IsOptional() @IsString() @Expose() debtorName: string | null + @ApiProperty() @IsString() @Expose() remittanceInformationUnstructured: string + @ApiProperty() @IsObject() @Expose() @Type(() => transactionAmountDto) @ValidateNested({ each: true }) transactionAmount: transactionAmountDto + @ApiProperty() @IsOptional() @IsNumber() @Expose() exchangeRate: number | null + @ApiProperty() @Expose() @IsString() valueDate: string + @ApiProperty() @Expose() @IsString() creditDebitIndicator: 'DEBIT' | 'CREDIT'