<?php

/**
 * Sync module for Bookkeeping.
 *
 * @package northmill-online-shared
 */
declare (strict_types=1);
namespace Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Sync;

use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Abstracts\Hub_API\Hub_Accounts\Hub_Account_Setup;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Abstract_Module;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Sync\Bookkeeping\Article_Account_Codes\Article_Account_Code_Sync;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Sync\Bookkeeping\Income_Account_Codes\Income_Account_Code_Sync;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Sync\Bookkeeping\Other_Account_Codes\Other_Account_Code_Sync;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Sync\Bookkeeping\Vat_Account_Codes\Vat_Account_Code_Sync;
use Northmill_Online_Shared_Checkout\Northmill_Online_Shared\Modules\Sync\Store_Settings\Store_Settings_Sync;
defined('ABSPATH') || exit;
/**
 * Class Bookkeeping_Sync_Module
 */
class Bookkeeping_Sync_Module extends Abstract_Module
{
    public const SYNCER_KEY_AAC = 'article_account_code';
    public const SYNCER_KEY_IAC = 'income_account_code';
    public const SYNCER_KEY_VAC = 'vat_account_code';
    public const SYNCER_KEY_OAC = 'other_account_code';
    public const SYNCER_KEY_SS = 'store_settings';
    /**
     * Set up the module.
     *
     * @return void
     */
    public function setup(): void
    {
        if (Hub_Account_Setup::is_setting_up_hub_accounts()) {
            $this->setup_hub_account_syncers();
        }
    }
    /**
     * Set up cron syncers for Hub account data.
     *
     * @return void
     */
    private function setup_hub_account_syncers(): void
    {
        $this->shared->sync->setup_syncer(self::SYNCER_KEY_AAC, Article_Account_Code_Sync::class, 22);
        $this->shared->sync->setup_syncer(self::SYNCER_KEY_IAC, Income_Account_Code_Sync::class, 22);
        $this->shared->sync->setup_syncer(self::SYNCER_KEY_VAC, Vat_Account_Code_Sync::class, 22);
        $this->shared->sync->setup_syncer(self::SYNCER_KEY_OAC, Other_Account_Code_Sync::class, 22);
        $this->shared->sync->setup_syncer(self::SYNCER_KEY_SS, Store_Settings_Sync::class, 22);
    }
}
