mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 00:24:54 +00:00
feat: show embossing information for child cards
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Get, HttpCode, HttpStatus, Post, UseGuards } from '@nestjs/common';
|
||||
import { Body, Controller, Get, HttpCode, HttpStatus, Param, Post, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { Roles } from '~/auth/enums';
|
||||
import { IJwtPayload } from '~/auth/interfaces';
|
||||
@ -34,6 +34,15 @@ export class CardsController {
|
||||
return ResponseFactory.data(cards.map((card) => new ChildCardResponseDto(card)));
|
||||
}
|
||||
|
||||
@Get('child-cards/:cardid/embossing-details')
|
||||
@UseGuards(RolesGuard)
|
||||
@AllowedRoles(Roles.GUARDIAN)
|
||||
@ApiDataResponse(CardEmbossingDetailsResponseDto)
|
||||
async getChildCardEmbossingDetails(@Param('cardid') cardId: string, @AuthenticatedUser() { sub }: IJwtPayload) {
|
||||
const res = await this.cardService.getChildCardEmbossingInformation(cardId, sub);
|
||||
return ResponseFactory.data(res);
|
||||
}
|
||||
|
||||
@Get('current')
|
||||
@ApiDataResponse(CardResponseDto)
|
||||
async getCurrentCard(@AuthenticatedUser() { sub }: IJwtPayload) {
|
||||
|
||||
@ -114,6 +114,14 @@ export class CardService {
|
||||
return this.neoleapService.getEmbossingInformation(card);
|
||||
}
|
||||
|
||||
async getChildCardEmbossingInformation(cardId: string, guardianId: string) {
|
||||
const card = await this.getCardById(cardId);
|
||||
if (card.parentId !== guardianId) {
|
||||
throw new BadRequestException('CARD.DOES_NOT_BELONG_TO_GUARDIAN');
|
||||
}
|
||||
return this.neoleapService.getEmbossingInformation(card);
|
||||
}
|
||||
|
||||
async updateCardLimit(cardId: string, newLimit: number) {
|
||||
const { affected } = await this.cardRepository.updateCardLimit(cardId, newLimit);
|
||||
|
||||
|
||||
@ -102,6 +102,7 @@
|
||||
"INVALID_OTP": "رمز التحقق الذي أدخلته غير صالح. يرجى المحاولة مرة أخرى."
|
||||
},
|
||||
"CARD": {
|
||||
"INSUFFICIENT_BALANCE": "البطاقة لا تحتوي على رصيد كافٍ لإكمال هذا التحويل."
|
||||
"INSUFFICIENT_BALANCE": "البطاقة لا تحتوي على رصيد كافٍ لإكمال هذا التحويل.",
|
||||
"DOES_NOT_BELONG_TO_GUARDIAN": "البطاقة لا تنتمي إلى ولي الأمر."
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,6 +101,7 @@
|
||||
"INVALID_OTP": "The OTP you entered is invalid. Please try again."
|
||||
},
|
||||
"CARD": {
|
||||
"INSUFFICIENT_BALANCE": "The card does not have sufficient balance to complete this transfer."
|
||||
"INSUFFICIENT_BALANCE": "The card does not have sufficient balance to complete this transfer.",
|
||||
"DOES_NOT_BELONG_TO_GUARDIAN": "The card does not belong to the guardian."
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user