import { ApiReviewRichInformation } from 'src/application/models/api/responseGenerics';

export const isApiReviewRichInformation = (
  richInfo: unknown,
): richInfo is ApiReviewRichInformation => {
  if (richInfo == null || typeof richInfo !== 'object') {
    return false;
  }

  if (
    'cons' in richInfo &&
    (!Array.isArray(richInfo.cons) || richInfo.cons.some(con => typeof con !== 'string'))
  ) {
    return false;
  }

  if (
    'pros' in richInfo &&
    (!Array.isArray(richInfo.pros) || richInfo.pros.some(pro => typeof pro !== 'string'))
  ) {
    return false;
  }

  if ('review_date' in richInfo && typeof richInfo.review_date !== 'string') {
    return false;
  }

  if ('reviewer_title' in richInfo && typeof richInfo.reviewer_title !== 'string') {
    return false;
  }

  if ('product_familiarity' in richInfo && typeof richInfo.product_familiarity !== 'string') {
    return false;
  }

  return true;
};
