58 lines
1.9 KiB
PHP
58 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Process\Tester\Scenarios;
|
|
|
|
use App\Communication\IncomingMessage;
|
|
use App\Communication\MessageIntake;
|
|
use App\Enums\IntakeKind;
|
|
use App\Enums\Medium;
|
|
use App\Process\Tester\SandboxContext;
|
|
use Carbon\CarbonImmutable;
|
|
|
|
/**
|
|
* V2.1: a general question or a stay inquiry arrives by chat without any case. Shows that it is only answered or referred
|
|
* to the inquiry path and creates no case, reservation or booking.
|
|
*/
|
|
final class GeneralQuestionMessage extends Scenario
|
|
{
|
|
public static function key(): string
|
|
{
|
|
return 'general_question_message';
|
|
}
|
|
|
|
public static function label(): string
|
|
{
|
|
return 'Allgemeine Frage im Chat (ohne Vorgang)';
|
|
}
|
|
|
|
public static function description(): string
|
|
{
|
|
return 'Eine Frage oder Terminanfrage kommt ohne Vorgang im Chat an. Es entsteht kein Vorgang; die Nachricht wird nur beantwortet, auf den Anfrageweg verwiesen oder geklärt.';
|
|
}
|
|
|
|
public static function intakes(): array
|
|
{
|
|
return [IntakeKind::Inquiry];
|
|
}
|
|
|
|
public static function inputs(): array
|
|
{
|
|
return [
|
|
'text' => ['label' => 'Nachricht', 'default' => 'question', 'type' => 'select', 'options' => ['question' => 'Sind Hunde erlaubt?', 'stay' => 'Ist die Wohnung im Dezember frei?', 'unclear' => 'ok danke']],
|
|
];
|
|
}
|
|
|
|
public function events(array $inputs): array
|
|
{
|
|
$text = match ((string) ($inputs['text'] ?? 'question')) {
|
|
'stay' => 'Ist die Wohnung vom 12.12. bis 19.12. frei? Wir würden gern buchen.',
|
|
'unclear' => 'ok danke',
|
|
default => 'Sind Hunde erlaubt und gibt es einen Parkplatz?',
|
|
};
|
|
|
|
return [new ScenarioEvent('Nachricht im Chat ohne Vorgang', fn (SandboxContext $context) => app(MessageIntake::class)->handle(
|
|
new IncomingMessage(Medium::Chat, 'chat-visitor-1', $text, CarbonImmutable::now(), 'tester-'.md5($text)),
|
|
))];
|
|
}
|
|
}
|