export const WarningFactory = {
  fromApiWarning(w) {
    return { type: w.type, severity: w.severity, page: w.page, message: w.message }
  },
}

export const FontFactory = {
  fromApiFont(f) {
    return {
      name: f.name,
      status: f.status,
      substitute: f.substitute,
      substituteQuality: f.substitute_quality,
      usedFor: f.used_for,
    }
  },
}

export const ScanFactory = {
  fromApiResponse(data) {
    return {
      sessionId: data.session_id,
      pages: data.pages,
      stories: data.stories,
      images: data.images,
      tables: data.tables,
      fonts: data.fonts.map((f) => FontFactory.fromApiFont(f)),
      warnings: data.warnings.map((w) => WarningFactory.fromApiWarning(w)),
      creditsRequired: 1,
    }
  },
}
