<?php
namespace EasyChat\Library\Queue\Jobs;

use EasyChat\Library\Messenger\AvitoItemContextService;

class MessengerAvitoItemContextEnrichJob {
    private $registry;

    public function __construct($registry) {
        $this->registry = $registry;
    }

    public function handle(array $payload): void {
        $result = (new AvitoItemContextService($this->registry))->syncByPayload($payload);
        if (empty($result['success'])) {
            throw new \Exception((string)($result['error'] ?? 'avito_item_context_enrich_failed'));
        }
    }
}
