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 { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||||
import { Roles } from '~/auth/enums';
|
import { Roles } from '~/auth/enums';
|
||||||
import { IJwtPayload } from '~/auth/interfaces';
|
import { IJwtPayload } from '~/auth/interfaces';
|
||||||
@ -34,6 +34,15 @@ export class CardsController {
|
|||||||
return ResponseFactory.data(cards.map((card) => new ChildCardResponseDto(card)));
|
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')
|
@Get('current')
|
||||||
@ApiDataResponse(CardResponseDto)
|
@ApiDataResponse(CardResponseDto)
|
||||||
async getCurrentCard(@AuthenticatedUser() { sub }: IJwtPayload) {
|
async getCurrentCard(@AuthenticatedUser() { sub }: IJwtPayload) {
|
||||||
|
|||||||
@ -114,6 +114,14 @@ export class CardService {
|
|||||||
return this.neoleapService.getEmbossingInformation(card);
|
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) {
|
async updateCardLimit(cardId: string, newLimit: number) {
|
||||||
const { affected } = await this.cardRepository.updateCardLimit(cardId, newLimit);
|
const { affected } = await this.cardRepository.updateCardLimit(cardId, newLimit);
|
||||||
|
|
||||||
|
|||||||
@ -100,8 +100,9 @@
|
|||||||
},
|
},
|
||||||
"OTP": {
|
"OTP": {
|
||||||
"INVALID_OTP": "رمز التحقق الذي أدخلته غير صالح. يرجى المحاولة مرة أخرى."
|
"INVALID_OTP": "رمز التحقق الذي أدخلته غير صالح. يرجى المحاولة مرة أخرى."
|
||||||
},
|
},
|
||||||
"CARD": {
|
"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."
|
"INVALID_OTP": "The OTP you entered is invalid. Please try again."
|
||||||
},
|
},
|
||||||
"CARD": {
|
"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