@takentrade/takentrade-libs
Version:
TakeNTrade shared libraries
175 lines (174 loc) • 4.12 kB
TypeScript
import { TransactionCategory, TransactionStatus } from '../../common/enums/transaction.enum';
/**
* NATS Event Contracts
* TypeScript interfaces for inter-service communication via NATS
*/
export interface UserCreatedEvent {
userId: string;
email: string;
phone: string;
username: string;
firstname?: string;
lastname?: string;
middlename?: string;
gender?: string;
dateOfBirth?: string;
referralCode?: string;
createdAt: string;
}
export interface PaymentSuccessEvent {
transactionId: string;
userId: string;
amount: number;
fee?: number;
currency: string;
category?: string;
provider: 'PROVIDUS' | 'PAYSTACK';
reference: string;
providerReference?: string;
balanceBefore?: number;
balanceAfter?: number;
metadata?: Record<string, any>;
timestamp: string;
}
export interface PaymentFailedEvent {
transactionId: string;
userId: string;
amount: number;
currency: string;
provider: 'PROVIDUS' | 'PAYSTACK';
reference: string;
reason: string;
errorCode?: string;
timestamp: string;
}
export interface TransactionProcessedEvent {
transactionId: string;
userId: string;
type: 'CREDIT' | 'DEBIT';
category: string;
amount: number;
fee: number;
balanceBefore: number;
balanceAfter: number;
reference: string;
description: string;
metadata?: Record<string, any>;
timestamp: string;
}
export interface NotificationSentEvent {
notificationId: string;
userId: string;
channel: 'EMAIL' | 'SMS' | 'PUSH' | 'VOICE';
type: string;
status: 'SENT' | 'FAILED';
timestamp: string;
}
export interface SavingsMaturedEvent {
savingsId: string;
userId: string;
amount: number;
interest: number;
interestRate?: number;
balance: number;
plan: string;
maturityDate: string;
timestamp: string;
}
export interface LoanApprovedEvent {
loanId: string;
userId: string;
amount: number;
interestRate: number;
totalInterest: number;
processingFee: number;
duration: string;
repaymentDate: string;
timestamp: string;
}
export interface LoanRepaidEvent {
loanId: string;
userId: string;
amount: number;
remainingBalance: number;
reference?: string;
timestamp: string;
}
export interface CreateProvidusAccountEvent {
userId: string;
bvn?: string;
firstName?: string;
lastName?: string;
dateOfBirth?: string;
phoneNumber?: string;
email?: string;
address?: string;
}
export interface KycVerifiedEvent {
userId: string;
verificationId: string;
bvn: string;
timestamp: string;
}
export interface KycRejectedEvent {
userId: string;
verificationId: string;
reason: string;
timestamp: string;
}
export interface VasTransactionEvent {
transactionId: string;
userId: string;
serviceId: string;
category: TransactionCategory;
amount: number;
recipientIdentifier: string;
status: TransactionStatus;
provider: string;
reference: string;
timestamp: string;
}
export interface AjoContributionEvent {
ajoId: string;
userId: string;
amount: number;
reference: string;
status: TransactionStatus;
timestamp: string;
}
export interface AjoMemberJoinedEvent {
ajoId: string;
userId: string;
joinedAt: string;
timestamp: string;
}
export interface ReferralRewardClaimedEvent {
userId: string;
referralId: string;
amount: number;
reference: string;
timestamp: string;
}
export interface WithdrawalRequestedEvent {
withdrawalId: string;
userId: string;
amount: number;
bankName: string;
accountNumber: string;
status: TransactionStatus;
timestamp: string;
}
export interface ProvidusDebitEvent {
userId: string;
amount: number;
reference: string;
metadata?: Record<string, any>;
timestamp: string;
}
export interface ProvidusCreditEvent {
userId: string;
amount: number;
reference: string;
metadata?: Record<string, any>;
timestamp: string;
}