fix data flow issues
This commit is contained in:
@@ -58,6 +58,8 @@ import { RejectLeagueJoinRequestUseCase } from '@core/racing/application/use-cas
|
||||
import { RemoveLeagueMemberUseCase } from '@core/racing/application/use-cases/RemoveLeagueMemberUseCase';
|
||||
import { TransferLeagueOwnershipUseCase } from '@core/racing/application/use-cases/TransferLeagueOwnershipUseCase';
|
||||
import { UpdateLeagueMemberRoleUseCase } from '@core/racing/application/use-cases/UpdateLeagueMemberRoleUseCase';
|
||||
import { GetLeagueWalletUseCase } from '@core/racing/application/use-cases/GetLeagueWalletUseCase';
|
||||
import { WithdrawFromLeagueWalletUseCase } from '@core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase';
|
||||
|
||||
// API Presenters
|
||||
import { AllLeaguesWithCapacityPresenter } from './presenters/AllLeaguesWithCapacityPresenter';
|
||||
@@ -108,6 +110,8 @@ export class LeagueService {
|
||||
private readonly getLeagueMembershipsUseCase: GetLeagueMembershipsUseCase,
|
||||
private readonly getLeagueScheduleUseCase: GetLeagueScheduleUseCase,
|
||||
private readonly getLeagueAdminPermissionsUseCase: GetLeagueAdminPermissionsUseCase,
|
||||
private readonly getLeagueWalletUseCase: GetLeagueWalletUseCase,
|
||||
private readonly withdrawFromLeagueWalletUseCase: WithdrawFromLeagueWalletUseCase,
|
||||
@Inject(LOGGER_TOKEN) private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
@@ -438,4 +442,32 @@ export class LeagueService {
|
||||
races: [],
|
||||
};
|
||||
}
|
||||
|
||||
async getLeagueWallet(leagueId: string): Promise<GetLeagueWalletOutputDTO> {
|
||||
this.logger.debug('Getting league wallet', { leagueId });
|
||||
const result = await this.getLeagueWalletUseCase.execute({ leagueId });
|
||||
if (result.isErr()) {
|
||||
throw new Error(result.unwrapErr().message);
|
||||
}
|
||||
return result.unwrap();
|
||||
}
|
||||
|
||||
async withdrawFromLeagueWallet(leagueId: string, input: WithdrawFromLeagueWalletInputDTO): Promise<WithdrawFromLeagueWalletOutputDTO> {
|
||||
this.logger.debug('Withdrawing from league wallet', { leagueId, amount: input.amount });
|
||||
const result = await this.withdrawFromLeagueWalletUseCase.execute({
|
||||
leagueId,
|
||||
amount: input.amount,
|
||||
currency: input.currency,
|
||||
seasonId: input.seasonId,
|
||||
destinationAccount: input.destinationAccount,
|
||||
});
|
||||
if (result.isErr()) {
|
||||
const error = result.unwrapErr();
|
||||
if (error.code === 'WITHDRAWAL_NOT_ALLOWED') {
|
||||
return { success: false, message: error.message };
|
||||
}
|
||||
throw new Error(error.message);
|
||||
}
|
||||
return result.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user