import type { RequestAvatarGenerationResult } from '@core/media/application/use-cases/RequestAvatarGenerationUseCase';
import type { RequestAvatarGenerationOutputDTO } from '../dtos/RequestAvatarGenerationOutputDTO';

type RequestAvatarGenerationResponseModel = RequestAvatarGenerationOutputDTO;

export class RequestAvatarGenerationPresenter {
  private model: RequestAvatarGenerationResponseModel | null = null;

  reset() {
    this.model = null;
  }

  transform(result: RequestAvatarGenerationResult): RequestAvatarGenerationResponseModel {
    this.model = {
      success: result.status === 'completed',
      requestId: result.requestId,
      avatarUrls: result.avatarUrls || [],
    };
    return this.model;
  }

  getResponseModel(): RequestAvatarGenerationResponseModel | null {
    return this.model;
  }

  get responseModel(): RequestAvatarGenerationResponseModel {
    if (!this.model) throw new Error('Presenter not presented');
    return this.model;
  }
}