<?php

namespace PortalPeople\virtualstock\events;

use yii\base\Event;

/**
 * Event fired when stock levels are refreshed from the VirtualStock API.
 *
 * Triggered on `Yii::$app` using the event name defined by
 * `WebhookService::EVENT_STOCK_UPDATED`.
 *
 * Handlers receive this event object directly:
 *
 * ```php
 * Yii::$app->on(WebhookService::EVENT_STOCK_UPDATED, function (StockUpdatedEvent $e) {
 *     foreach ($e->stockResults as $sku => $data) {
 *         // persist $data['quantity'] etc.
 *     }
 * });
 * ```
 */
class StockUpdatedEvent extends Event
{
    /**
     * Map of supplier SKU → stock data array.
     * On failure the entry contains `['error' => string]`.
     *
     * @var array<string, array<string, mixed>>
     */
    public array $stockResults = [];

    /** Number of SKUs that could not be fetched. */
    public int $failedCount = 0;
}
