<?php
/**
 * File Path: includes/import/class-mbs-importer-mybooktable-mapper.php
 *
 * MyBookTable Import — Shared Mapping Constants
 *
 * Centralises the two mapping tables shared by both MyBookTable importers:
 *
 *   MBS_MyBookTable_Importer  (CSV-pipeline path, class-mbs-mybooktable-importer.php)
 *   MBS_Importer_MyBookTable  (direct DAO path,  class-mbs-importer-mybooktable.php)
 *
 * Extract: REF-006 (Session 137). Eliminates duplicated RETAILER_MAP constants
 * and provides a single canonical home for the MBT affiliate-settings mapping.
 *
 * @package    My_Book_Showroom
 * @subpackage Includes/Import
 * @since      1.1.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class MBS_Importer_MyBookTable_Mapper { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- mbs_/MBS_ prefix is correct; scanner not configured with plugin prefix

	/**
	 * MBT buybutton store key → MBS retailer key.
	 *
	 * 'universal' is intentionally absent: it maps to is_direct_author = 1
	 * (author's own site — no retailer_key stored). The caller is responsible
	 * for detecting 'universal' before consulting this map.
	 *
	 * @since 1.1.0
	 * @var array<string, string>
	 */
	const RETAILER_MAP = array(
		'amazon'     => 'amazon',
		'bnn'        => 'bn',
		'ibooks'     => 'apple',
		'kobo'       => 'kobo',
		'googleplay' => 'google',
		'powells'    => 'powells',
	);

	/**
	 * MBT settings key → WordPress option name, for simple string affiliate codes.
	 *
	 * Each entry is written only when the target option is currently empty so
	 * a re-import never clobbers settings the user has already configured in MBS.
	 *
	 * NOT included here (require per-field special handling):
	 *   amazon_buybutton_affiliate_code  maps to mbs_setting_amazon_partner_tag
	 *                                    (different option-key pattern)
	 *   posts_per_page                   requires an integer cast + range check
	 *
	 * @since 1.1.0
	 * @var array<string, string>
	 */
	const AFFILIATE_SETTINGS_MAP = array(
		'itunes_affiliate_token'   => 'mbs_setting_affiliate_apple',
		'indiebound_affiliate_id'  => 'mbs_setting_affiliate_bookshop',
		'powells_partner_id'       => 'mbs_setting_affiliate_powells',
		'linkshare_affiliate_code' => 'mbs_setting_affiliate_bn',
	);
}
