website refactor
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { DomainError } from '@/lib/contracts/services/Service';
|
||||
|
||||
/**
|
||||
* Sponsor Service - DTO Only
|
||||
*
|
||||
@@ -7,7 +10,102 @@
|
||||
export class SponsorService {
|
||||
constructor(private readonly apiClient: any) {}
|
||||
|
||||
async getSponsorById(sponsorId: string): Promise<any> {
|
||||
return { id: sponsorId, name: 'Sponsor' };
|
||||
async getSponsorById(sponsorId: string): Promise<Result<any, DomainError>> {
|
||||
try {
|
||||
const result = await this.apiClient.getSponsor(sponsorId);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'getSponsorById' });
|
||||
}
|
||||
}
|
||||
|
||||
async getSponsorDashboard(sponsorId: string): Promise<Result<any, DomainError>> {
|
||||
try {
|
||||
const result = await this.apiClient.getDashboard(sponsorId);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'getSponsorDashboard' });
|
||||
}
|
||||
}
|
||||
|
||||
async getSponsorSponsorships(sponsorId: string): Promise<Result<any, DomainError>> {
|
||||
try {
|
||||
const result = await this.apiClient.getSponsorships(sponsorId);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'getSponsorSponsorships' });
|
||||
}
|
||||
}
|
||||
|
||||
async getBilling(sponsorId: string): Promise<Result<any, DomainError>> {
|
||||
try {
|
||||
const result = await this.apiClient.getBilling(sponsorId);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'getBilling' });
|
||||
}
|
||||
}
|
||||
|
||||
async getAvailableLeagues(): Promise<Result<any, DomainError>> {
|
||||
try {
|
||||
const result = await this.apiClient.getAvailableLeagues();
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'getAvailableLeagues' });
|
||||
}
|
||||
}
|
||||
|
||||
async getLeagueDetail(leagueId: string): Promise<Result<any, DomainError>> {
|
||||
try {
|
||||
const result = await this.apiClient.getLeagueDetail(leagueId);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'getLeagueDetail' });
|
||||
}
|
||||
}
|
||||
|
||||
async getSettings(sponsorId: string): Promise<Result<any, DomainError>> {
|
||||
try {
|
||||
const result = await this.apiClient.getSettings(sponsorId);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'getSettings' });
|
||||
}
|
||||
}
|
||||
|
||||
async updateSettings(sponsorId: string, input: any): Promise<Result<void, DomainError>> {
|
||||
try {
|
||||
await this.apiClient.updateSettings(sponsorId, input);
|
||||
return Result.ok(undefined);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'updateSettings' });
|
||||
}
|
||||
}
|
||||
|
||||
async acceptSponsorshipRequest(requestId: string, sponsorId: string): Promise<Result<void, DomainError>> {
|
||||
try {
|
||||
await this.apiClient.acceptSponsorshipRequest(requestId, sponsorId);
|
||||
return Result.ok(undefined);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'acceptSponsorshipRequest' });
|
||||
}
|
||||
}
|
||||
|
||||
async rejectSponsorshipRequest(requestId: string, sponsorId: string, reason?: string): Promise<Result<void, DomainError>> {
|
||||
try {
|
||||
await this.apiClient.rejectSponsorshipRequest(requestId, sponsorId, reason);
|
||||
return Result.ok(undefined);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'rejectSponsorshipRequest' });
|
||||
}
|
||||
}
|
||||
|
||||
async getPendingSponsorshipRequests(input: any): Promise<Result<any, DomainError>> {
|
||||
try {
|
||||
const result = await this.apiClient.getPendingSponsorshipRequests(input);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({ type: 'notImplemented', message: 'getPendingSponsorshipRequests' });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user