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

use EasyChat\Library\Messenger\YoulaItemContextService;

class MessengerYoulaItemContextEnrichJob {
    private $registry;

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

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