<?php

declare (strict_types=1);
namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Service\Ucp\Checkout\State;

/**
 * Persists UCP-specific checkout data payload in the WooCommerce session.
 */
final class CheckoutSessionDataRepository
{
    private const CONSENT_KEY = '_ucp_buyer_consent';
    private const DESTINATION_ID_KEY = '_ucp_destination_id';
    /**
     * @param array<string, bool> $consent
     */
    public function set_buyer_consent(array $consent): void
    {
        if (\WC()->session) {
            \WC()->session->set(self::CONSENT_KEY, $consent);
        }
    }
    /**
     * @return array<string, bool>|null
     */
    public function get_buyer_consent(): ?array
    {
        if (!\WC()->session) {
            return null;
        }
        $consent = \WC()->session->get(self::CONSENT_KEY);
        return \is_array($consent) ? $consent : null;
    }
    public function set_destination_id(string $id): void
    {
        if (\WC()->session) {
            \WC()->session->set(self::DESTINATION_ID_KEY, $id);
        }
    }
    public function get_destination_id(): string
    {
        if (\WC()->session) {
            $id = \WC()->session->get(self::DESTINATION_ID_KEY);
            if (\is_string($id) && '' !== $id) {
                return $id;
            }
        }
        return 'dest_1';
    }
}
