73 lines
4.0 KiB
TypeScript
73 lines
4.0 KiB
TypeScript
import { Injectable, Inject } from '@nestjs/common';
|
|
import { GetEntitySponsorshipPricingResultDto, GetSponsorsOutput, CreateSponsorInput, CreateSponsorOutput, GetSponsorDashboardQueryParams, SponsorDashboardDTO, GetSponsorSponsorshipsQueryParams, SponsorSponsorshipsDTO, SponsorDto, SponsorDashboardMetricsDTO, SponsoredLeagueDTO, SponsorDashboardInvestmentDTO, SponsorshipDetailDTO } from './dto/SponsorDto';
|
|
|
|
// Use cases
|
|
import { GetSponsorshipPricingUseCase } from '@gridpilot/racing/application/use-cases/GetSponsorshipPricingUseCase';
|
|
import { GetSponsorsUseCase } from '@gridpilot/racing/application/use-cases/GetSponsorsUseCase';
|
|
import { CreateSponsorUseCase } from '@gridpilot/racing/application/use-cases/CreateSponsorUseCase';
|
|
import { GetSponsorDashboardUseCase } from '@gridpilot/racing/application/use-cases/GetSponsorDashboardUseCase';
|
|
import { GetSponsorSponsorshipsUseCase } from '@gridpilot/racing/application/use-cases/GetSponsorSponsorshipsUseCase';
|
|
|
|
// Presenters
|
|
import { GetSponsorshipPricingPresenter } from './presenters/GetSponsorshipPricingPresenter';
|
|
import { GetSponsorsPresenter } from './presenters/GetSponsorsPresenter';
|
|
import { CreateSponsorPresenter } from './presenters/CreateSponsorPresenter';
|
|
import { GetSponsorDashboardPresenter } from './presenters/GetSponsorDashboardPresenter';
|
|
import { GetSponsorSponsorshipsPresenter } from './presenters/GetSponsorSponsorshipsPresenter';
|
|
|
|
// Tokens
|
|
import { GET_SPONSORSHIP_PRICING_USE_CASE_TOKEN, GET_SPONSORS_USE_CASE_TOKEN, CREATE_SPONSOR_USE_CASE_TOKEN, GET_SPONSOR_DASHBOARD_USE_CASE_TOKEN, GET_SPONSOR_SPONSORSHIPS_USE_CASE_TOKEN, LOGGER_TOKEN } from './SponsorProviders';
|
|
import { Logger } from '@gridpilot/shared/application';
|
|
|
|
@Injectable()
|
|
export class SponsorService {
|
|
constructor(
|
|
@Inject(GET_SPONSORSHIP_PRICING_USE_CASE_TOKEN) private readonly getSponsorshipPricingUseCase: GetSponsorshipPricingUseCase,
|
|
@Inject(GET_SPONSORS_USE_CASE_TOKEN) private readonly getSponsorsUseCase: GetSponsorsUseCase,
|
|
@Inject(CREATE_SPONSOR_USE_CASE_TOKEN) private readonly createSponsorUseCase: CreateSponsorUseCase,
|
|
@Inject(GET_SPONSOR_DASHBOARD_USE_CASE_TOKEN) private readonly getSponsorDashboardUseCase: GetSponsorDashboardUseCase,
|
|
@Inject(GET_SPONSOR_SPONSORSHIPS_USE_CASE_TOKEN) private readonly getSponsorSponsorshipsUseCase: GetSponsorSponsorshipsUseCase,
|
|
@Inject(LOGGER_TOKEN) private readonly logger: Logger,
|
|
) {}
|
|
|
|
async getEntitySponsorshipPricing(): Promise<GetEntitySponsorshipPricingResultDto> {
|
|
this.logger.debug('[SponsorService] Fetching sponsorship pricing.');
|
|
|
|
const presenter = new GetSponsorshipPricingPresenter();
|
|
await this.getSponsorshipPricingUseCase.execute(undefined, presenter);
|
|
return presenter.viewModel;
|
|
}
|
|
|
|
async getSponsors(): Promise<GetSponsorsOutput> {
|
|
this.logger.debug('[SponsorService] Fetching sponsors.');
|
|
|
|
const presenter = new GetSponsorsPresenter();
|
|
await this.getSponsorsUseCase.execute(undefined, presenter);
|
|
return presenter.viewModel;
|
|
}
|
|
|
|
async createSponsor(input: CreateSponsorInput): Promise<CreateSponsorOutput> {
|
|
this.logger.debug('[SponsorService] Creating sponsor.', { input });
|
|
|
|
const presenter = new CreateSponsorPresenter();
|
|
await this.createSponsorUseCase.execute(input, presenter);
|
|
return presenter.viewModel;
|
|
}
|
|
|
|
async getSponsorDashboard(params: GetSponsorDashboardQueryParams): Promise<SponsorDashboardDTO | null> {
|
|
this.logger.debug('[SponsorService] Fetching sponsor dashboard.', { params });
|
|
|
|
const presenter = new GetSponsorDashboardPresenter();
|
|
await this.getSponsorDashboardUseCase.execute(params, presenter);
|
|
return presenter.viewModel as SponsorDashboardDTO | null;
|
|
}
|
|
|
|
async getSponsorSponsorships(params: GetSponsorSponsorshipsQueryParams): Promise<SponsorSponsorshipsDTO | null> {
|
|
this.logger.debug('[SponsorService] Fetching sponsor sponsorships.', { params });
|
|
|
|
const presenter = new GetSponsorSponsorshipsPresenter();
|
|
await this.getSponsorSponsorshipsUseCase.execute(params, presenter);
|
|
return presenter.viewModel as SponsorSponsorshipsDTO | null;
|
|
}
|
|
}
|