forked from Shared/esg
parsian inquiries implemented
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class PolicyByChassisRequestDto {
|
||||
@ApiProperty({ example: 'NAAM01E15HK123456', description: 'Vehicle chassis number' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
chassisNo!: string;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString, Length, Matches } from 'class-validator';
|
||||
|
||||
export class PolicyByNationalCodeRequestDto {
|
||||
@ApiProperty({ example: '4311402422', description: 'Iranian national code (10 digits)' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@Length(10, 10)
|
||||
@Matches(/^\d{10}$/, { message: 'nationalCode must be exactly 10 digits' })
|
||||
nationalCode!: string;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString, Matches } from 'class-validator';
|
||||
|
||||
export class PolicyByPlateRequestDto {
|
||||
@ApiProperty({ example: '12', description: 'Two digits on the left side of the plate' })
|
||||
@IsString()
|
||||
@Matches(/^\d{2}$/, { message: 'plk1 must be exactly 2 digits' })
|
||||
plk1!: string;
|
||||
|
||||
@ApiProperty({ example: 'ب', description: 'Middle plate letter' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
plk2!: string;
|
||||
|
||||
@ApiProperty({ example: '345', description: 'Three digits on the right side of the plate' })
|
||||
@IsString()
|
||||
@Matches(/^\d{3}$/, { message: 'plk3 must be exactly 3 digits' })
|
||||
plk3!: string;
|
||||
|
||||
@ApiProperty({ example: '67', description: 'Plate serial' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
plksrl!: string;
|
||||
}
|
||||
@@ -1,27 +1,33 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsIn, IsNotEmpty, IsOptional, IsString, Length, Matches } from 'class-validator';
|
||||
|
||||
export class SayahRequestDto {
|
||||
@ApiProperty({ example: '1', description: '1 for natural person (always use "1")' })
|
||||
@ApiPropertyOptional({ example: '1', description: '1 for natural person' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@IsIn(['1'])
|
||||
accountOwnerType!: string;
|
||||
accountOwnerType?: string;
|
||||
|
||||
@ApiProperty({ example: '4311402422', description: 'Iranian national code (10 digits)' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@Length(10, 10)
|
||||
@Matches(/^\d{10}$/, { message: 'nationalId must be exactly 10 digits' })
|
||||
nationalId!: string;
|
||||
@Matches(/^\d{10}$/, { message: 'nationalCode must be exactly 10 digits' })
|
||||
nationalCode!: string;
|
||||
|
||||
@ApiPropertyOptional({ nullable: true })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
legalId?: string | null;
|
||||
|
||||
@ApiProperty({ example: 'IR800560611828005105117001', description: 'Iranian Sheba ID (26 characters)' })
|
||||
@ApiProperty({
|
||||
example: 'IR800560611828005105117001',
|
||||
description: 'Iranian Sheba ID (26 characters)',
|
||||
})
|
||||
@Transform(({ value }: { value?: string }) => value?.toUpperCase())
|
||||
@IsString()
|
||||
@Length(26, 26)
|
||||
@Matches(/^IR\d{24}$/, { message: 'shebaId must start with IR and contain 24 digits' })
|
||||
shebaId!: string;
|
||||
@Matches(/^IR\d{24}$/, { message: 'sheba must start with IR and contain 24 digits' })
|
||||
sheba!: string;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ import { GenericInquiryResponseDto } from './dto/generic-inquiry-response.dto';
|
||||
import { PostalCodeRequestDto } from './dto/postal-code-request.dto';
|
||||
import { ShahkarRequestDto } from './dto/shahkar-request.dto';
|
||||
import { SayahRequestDto } from './dto/sayah-request.dto';
|
||||
import { PolicyByChassisRequestDto } from './dto/policy-by-chassis-request.dto';
|
||||
import { PolicyByNationalCodeRequestDto } from './dto/policy-by-national-code-request.dto';
|
||||
import { PolicyByPlateRequestDto } from './dto/policy-by-plate-request.dto';
|
||||
import { InquiryService } from './inquiry.service';
|
||||
|
||||
/**
|
||||
@@ -127,6 +130,54 @@ export class InquiryController {
|
||||
return this.inquireGeneric(InquiryType.LEGAL_PERSON, payload, req);
|
||||
}
|
||||
|
||||
@Post('policyByChassis')
|
||||
@InquiryAccess(InquiryType.POLICY_BY_CHASSIS)
|
||||
@Throttle({ default: { limit: 30, ttl: 60000 } })
|
||||
@ApiOperation({ summary: 'Policy inquiry by chassis number' })
|
||||
@ApiResponse({ status: 200, type: GenericInquiryResponseDto })
|
||||
async inquirePolicyByChassis(
|
||||
@Body() payload: PolicyByChassisRequestDto,
|
||||
@Req() req: Request & { requestId?: string; trackingCode?: string },
|
||||
): Promise<BaseInquiryResponseDto<Record<string, unknown>>> {
|
||||
return this.inquireGeneric(
|
||||
InquiryType.POLICY_BY_CHASSIS,
|
||||
payload as unknown as Record<string, unknown>,
|
||||
req,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('policyByPlate')
|
||||
@InquiryAccess(InquiryType.POLICY_BY_PLATE)
|
||||
@Throttle({ default: { limit: 30, ttl: 60000 } })
|
||||
@ApiOperation({ summary: 'Policy inquiry by national vehicle plate' })
|
||||
@ApiResponse({ status: 200, type: GenericInquiryResponseDto })
|
||||
async inquirePolicyByPlate(
|
||||
@Body() payload: PolicyByPlateRequestDto,
|
||||
@Req() req: Request & { requestId?: string; trackingCode?: string },
|
||||
): Promise<BaseInquiryResponseDto<Record<string, unknown>>> {
|
||||
return this.inquireGeneric(
|
||||
InquiryType.POLICY_BY_PLATE,
|
||||
payload as unknown as Record<string, unknown>,
|
||||
req,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('policyByNationalCode')
|
||||
@InquiryAccess(InquiryType.POLICY_BY_NATIONAL_CODE)
|
||||
@Throttle({ default: { limit: 30, ttl: 60000 } })
|
||||
@ApiOperation({ summary: 'Policy inquiry by national code' })
|
||||
@ApiResponse({ status: 200, type: GenericInquiryResponseDto })
|
||||
async inquirePolicyByNationalCode(
|
||||
@Body() payload: PolicyByNationalCodeRequestDto,
|
||||
@Req() req: Request & { requestId?: string; trackingCode?: string },
|
||||
): Promise<BaseInquiryResponseDto<Record<string, unknown>>> {
|
||||
return this.inquireGeneric(
|
||||
InquiryType.POLICY_BY_NATIONAL_CODE,
|
||||
payload as unknown as Record<string, unknown>,
|
||||
req,
|
||||
);
|
||||
}
|
||||
|
||||
private async inquireGeneric(
|
||||
inquiryType: InquiryType,
|
||||
payload: Record<string, unknown>,
|
||||
|
||||
Reference in New Issue
Block a user