Skip to content

Commit

Permalink
swagger: Provide schema for iris-transaction-test endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Oct 25, 2023
1 parent 8d389a5 commit 4295987
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
12 changes: 11 additions & 1 deletion apps/api/src/bank-transactions/bank-transactions.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Controller,
ForbiddenException,
Get,
HttpCode,
Logger,
NotFoundException,
Param,
Expand All @@ -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'
Expand All @@ -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'

Check warning on line 32 in apps/api/src/bank-transactions/bank-transactions.controller.ts

View workflow job for this annotation

GitHub Actions / Run API tests

'IrisIbanAccountInfoDto' is defined but never used
import { IrisTransactionInfoDto } from './dto/iris-bank-transaction-info.dto'

Check warning on line 33 in apps/api/src/bank-transactions/bank-transactions.controller.ts

View workflow job for this annotation

GitHub Actions / Run API tests

'IrisTransactionInfoDto' is defined but never used

@ApiTags('bank-transaction')
@Controller('bank-transaction')
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class IrisBankTransactionSimulationDto {
@Type(() => IrisIbanAccountInfoDto)
irisIbanAccountInfo: IrisIbanAccountInfoDto

@ApiProperty()
@ApiProperty({ type: () => IrisTransactionInfoDto })
@Expose()
@IsArray()
@ValidateNested({ each: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -12,6 +13,7 @@ export class IrisIbanAccountInfoDto {

name: string

@ApiProperty()
@IsString()
@IsIBAN()
@Expose()
Expand All @@ -23,6 +25,7 @@ export class IrisIbanAccountInfoDto {

bankHash: string

@ApiProperty()
@IsString()
@Expose()
bankName: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ApiProperty } from '@nestjs/swagger'
import { Currency } from '@prisma/client'
import { Expose, Type } from 'class-transformer'
import {
Expand All @@ -11,72 +12,86 @@ import {
} from 'class-validator'

class bankAccountDto {
@ApiProperty()
@IsString()
@IsIBAN()
@Expose()
iban: string
}

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'
Expand Down

0 comments on commit 4295987

Please sign in to comment.