import { LegacyItemVerificationProperties } from "../legacyTypes";
import { ItemVerificationProperties } from "../typings";

/**
 * Maps LegacyItemVerificationProperties to ItemVerificationProperties
 * @param legacyProperties - The legacy item verification properties
 * @returns The new item verification properties format
 */
export const itemVerificationPropertiesMapper = (
  legacyProperties: LegacyItemVerificationProperties
): ItemVerificationProperties => {
  return {
    scan_channel: legacyProperties.scan_channel,
    scan_type: legacyProperties.scan_type,
    is_successful: legacyProperties.is_successful,
    item_info: {
      id: legacyProperties.item_info.id,
      type: legacyProperties.item_info.type,
      batch_id: legacyProperties.item_info.batch_id,
      reward_id: legacyProperties.item_info.reward_id,
      survey_id: legacyProperties.item_info.survey_id,
      is_featured: legacyProperties.item_info.is_featured,
      expiry_date: legacyProperties.item_info.expiry_date,
      production_date: legacyProperties.item_info.production_date,
    },
  };
};
