WebhookEventMessage example

$webhookData = $this->getPayloadForWebhook($webhook$event);
            } catch (AppUrlChangeDetectedException) {
                // don't dispatch webhooks for apps if url changed                 continue;
            }

            $webhookEventId = $webhookData['source']['eventId'];

            $appId = $webhook->getApp() !== null ? $webhook->getApp()->getId() : null;
            $secret = $webhook->getApp() !== null ? $webhook->getApp()->getAppSecret() : null;

            $webhookEventMessage = new WebhookEventMessage(
                $webhookEventId,
                $webhookData,
                $appId,
                $webhook->getId(),
                $this->shopwareVersion,
                $webhook->getUrl(),
                $secret,
                $languageId,
                $userLocale
            );

            

            'webhooks' => [
                [
                    'id' => $webhookId,
                    'name' => 'hook1',
                    'eventName' => 'order',
                    'url' => 'https://test.com',
                ],
            ],
        ]]$this->context);

        $webhookEventMessage = new WebhookEventMessage($webhookEventId['body' => 'payload']$appId$webhookId, '6.4', 'http://test.com', 's3cr3t', Defaults::LANGUAGE_SYSTEM, 'en-GB');

        $webhookEventLogRepository->create([[
            'id' => $webhookEventId,
            'appName' => 'SwagApp',
            'deliveryStatus' => WebhookEventLogDefinition::STATUS_QUEUED,
            'webhookName' => 'hook1',
            'eventName' => 'order',
            'appVersion' => '0.0.1',
            'url' => 'https://test.com',
            'serializedWebhookMessage' => serialize($webhookEventMessage),
        ]]$this->context);

        
unset($actualPayload['source']['eventId']);
                static::assertEquals($payload$actualPayload);
                static::assertEquals($appId$message->getAppId());
                static::assertEquals($webhookId$message->getWebhookId());
                static::assertEquals($shopwareVersion$message->getShopwareVersion());
                static::assertEquals('s3cr3t', $message->getSecret());
                static::assertEquals(Defaults::LANGUAGE_SYSTEM, $message->getLanguageId());
                static::assertEquals('en-GB', $message->getUserLocale());

                return true;
            }))
            ->willReturn(new Envelope(new WebhookEventMessage($webhookEventId$payload$appId$webhookId, '6.4', 'http://test.com', 's3cr3t', Defaults::LANGUAGE_SYSTEM, 'en-GB')));

        $webhookDispatcher = new WebhookDispatcher(
            $this->getContainer()->get('event_dispatcher'),
            $this->getContainer()->get(Connection::class),
            $client,
            $this->shopUrl,
            $this->getContainer(),
            $this->getContainer()->get(HookableEventFactory::class),
            Kernel::SHOPWARE_FALLBACK_VERSION,
            $bus,
            false
        );


    public function testItChangeColumnAppNameAndAppVersionSuccessfully(): void
    {
        $this->connection->executeStatement('DELETE FROM webhook_event_log');

        $context = Context::createDefaultContext();

        $webhookEventId = Uuid::randomHex();
        $webhookId = Uuid::randomHex();

        $webhookEventMessage = new WebhookEventMessage($webhookEventId[], null, $webhookId, '6.4', 'http://test.com', null, Defaults::LANGUAGE_SYSTEM, 'en-GB');

        $webhookEventLogRepo = $this->getContainer()->get('webhook_event_log.repository');
        $webhookEventLogRepo->create([[
            'id' => $webhookEventId,
            'deliveryStatus' => WebhookEventLogDefinition::STATUS_QUEUED,
            'webhookName' => 'webhookName',
            'eventName' => 'eventName',
            'url' => 'http://test.com',
            'serializedWebhookMessage' => serialize($webhookEventMessage),
        ]]$context);

        

                    'id' => $webhookId,
                    'name' => 'hook1',
                    'eventName' => 'order',
                    'url' => 'https://test.com',
                ],
            ],
        ]], Context::createDefaultContext());

        $webhookEventLogRepository = $this->getContainer()->get('webhook_event_log.repository');
        $webhookEventId = Uuid::randomHex();
        $webhookEventMessage = new WebhookEventMessage($webhookEventId['body' => 'payload']$appId$webhookId, '6.4', 'http://test.com', 's3cr3t', Defaults::LANGUAGE_SYSTEM, 'en-GB');

        $webhookEventLogRepository->create([[
            'id' => $webhookEventId,
            'appName' => 'SwagApp',
            'deliveryStatus' => WebhookEventLogDefinition::STATUS_QUEUED,
            'webhookName' => 'hook1',
            'eventName' => 'order',
            'appVersion' => '0.0.1',
            'url' => 'https://test.com',
            'serializedWebhookMessage' => serialize($webhookEventMessage),
        ]], Context::createDefaultContext());

        
Home | Imprint | This part of the site doesn't use cookies.