export class DeviceInfo {
  private readonly _os: 'Android' | 'iOS';
  private readonly _osVersion: string;
  private readonly _deviceModel?: string;
  private readonly _screenResolution?: string;

  private constructor(props: {
    os: 'Android' | 'iOS';
    osVersion: string;
    deviceModel?: string;
    screenResolution?: string;
  }) {
    this._os = props.os;
    this._osVersion = props.osVersion;
    this._deviceModel = props.deviceModel;
    this._screenResolution = props.screenResolution;
  }

  get os(): 'Android' | 'iOS' {
    return this._os;
  }

  get osVersion(): string {
    return this._osVersion;
  }

  get deviceModel(): string | undefined {
    return this._deviceModel;
  }

  get screenResolution(): string | undefined {
    return this._screenResolution;
  }

  static create(props: {
    os: string;
    osVersion: string;
    deviceModel?: string;
    screenResolution?: string;
  }): DeviceInfo {
    const normalizedOs = props.os.toLowerCase() === 'ios' ? 'iOS' : 'Android';
    return new DeviceInfo({
      os: normalizedOs,
      osVersion: props.osVersion,
      deviceModel: props.deviceModel,
      screenResolution: props.screenResolution,
    });
  }
}
