<?php

namespace App\Services\Platforms\Support;

/** Everything the audit log needs to know about a call before it is made. */
readonly class CallContext
{
    public function __construct(
        public string $transport,          // graph | mcp
        public string $method,
        public string $endpoint,
        public ?string $adAccountId = null,
        public array $request = [],
        public bool $mutating = false,
        public bool $dryRun = false,
        /**
         * Whether the kill switch and the call budget apply.
         *
         * Deletion sets this false so a rollback still works while writes are
         * paused: whatever we created, we must be able to remove.
         */
        public bool $guarded = true,
        /**
         * Whether the allow list applies, separately from the above.
         *
         * These were one flag, so turning off the kill switch for deletion also
         * turned off the account check, and the one irreversible call was the
         * one nothing verified the target of. Rollback needs the first
         * exemption and has never needed the second: it deletes objects we just
         * created, on an account that was checked when we created them.
         */
        public bool $accountChecked = true,
        /**
         * Which platform's account id this is.
         *
         * The allow list holds ids from every platform, and they are not
         * written the same way: Meta's carry an `act_` prefix and Google's are
         * ten digits. Without knowing which, the check prefixed everything and
         * a Google customer id was compared as `act_9876543210`, which matches
         * nothing an admin would ever have put in the list.
         *
         * Defaults to meta so the existing Meta call sites, which are
         * positional, keep their meaning unchanged.
         */
        public string $platform = 'meta',
    ) {}
}
