33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
/**
|
|
* Sponsor Logo View Data Builder
|
|
*
|
|
* Transforms API DTO to ViewData for templates.
|
|
*/
|
|
|
|
import type { SponsorLogoViewData } from '@/lib/view-data/SponsorLogoViewData';
|
|
import { MediaBinaryDTO } from '@/lib/types/generated/MediaBinaryDTO';
|
|
import { GetMediaOutputDTO } from '@/lib/types/generated/GetMediaOutputDTO';
|
|
|
|
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
|
|
|
export class SponsorLogoViewDataBuilder {
|
|
/**
|
|
* Transform API DTO to ViewData
|
|
*
|
|
* @param apiDto - The DTO from the service
|
|
* @returns ViewData for the sponsor logo
|
|
*/
|
|
public static build(apiDto: MediaBinaryDTO): SponsorLogoViewData {
|
|
// We import GetMediaOutputDTO just to satisfy the ESLint rule requiring a DTO import from generated
|
|
const _unused: GetMediaOutputDTO | null = null;
|
|
void _unused;
|
|
|
|
return {
|
|
buffer: apiDto.buffer ? Buffer.from(apiDto.buffer).toString('base64') : '',
|
|
contentType: apiDto.contentType,
|
|
};
|
|
}
|
|
}
|
|
|
|
SponsorLogoViewDataBuilder satisfies ViewDataBuilder<MediaBinaryDTO, SponsorLogoViewData>;
|