gradido/backend/src/graphql/model/RedeemJwtLink.ts
clauspeterhuebner 13059672f9 linting
2025-05-14 15:00:47 +02:00

56 lines
1.3 KiB
TypeScript

import { Decimal } from 'decimal.js-light'
import { Field, ObjectType } from 'type-graphql'
import { RedeemJwtPayloadType } from '@/auth/jwt/payloadtypes/RedeemJwtPayloadType'
import { Community } from './Community'
import { User } from './User'
@ObjectType()
export class RedeemJwtLink {
constructor(
redeemJwtPayload: RedeemJwtPayloadType,
senderCommunity: Community,
senderUser: User,
recipientCommunity: Community,
recipientUser?: User,
) {
this.senderCommunity = senderCommunity
this.recipientCommunity = recipientCommunity
this.senderUser = senderUser
if (recipientUser !== undefined) {
this.recipientUser = recipientUser
} else {
this.recipientUser = null
}
this.amount = new Decimal(redeemJwtPayload.amount)
this.memo = redeemJwtPayload.memo
this.code = redeemJwtPayload.redeemcode
this.validUntil = new Date(redeemJwtPayload.validuntil)
}
@Field(() => Community)
senderCommunity: Community
@Field(() => User)
senderUser: User
@Field(() => Community)
recipientCommunity: Community
@Field(() => User, { nullable: true })
recipientUser: User | null
@Field(() => Decimal)
amount: Decimal
@Field(() => String)
memo: string
@Field(() => String)
code: string
@Field(() => Date)
validUntil: Date
}