import { AuthApiClient } from '../../api/auth/AuthApiClient';
import { SessionPresenter } from '../../presenters/SessionPresenter';
import type { SessionViewModel } from '../../view-models';

/**
 * Session Service
 *
 * Orchestrates session operations by coordinating API calls and presentation logic.
 * All dependencies are injected via constructor.
 */
export class SessionService {
  constructor(
    private readonly apiClient: AuthApiClient,
    private readonly presenter: SessionPresenter
  ) {}

  /**
   * Get current user session with presentation transformation
   */
  async getSession(): Promise<SessionViewModel | null> {
    try {
      const dto = await this.apiClient.getSession();
      return this.presenter.presentSession(dto);
    } catch (error) {
      throw error;
    }
  }
}