From dee0c54c23c15b6c6ee308716c026c9638a24ac0 Mon Sep 17 00:00:00 2001 From: Jasper Zonneveld Date: Wed, 13 Mar 2024 12:10:52 +0100 Subject: [PATCH] feat: add new properties --- src/Api/Situations.php | 6 +++++- src/Models/Contact.php | 24 ++++++++++++++++++++++++ src/Models/Situation.php | 12 +++++++++++- src/Models/VehicleInformation.php | 4 +++- src/Parsers/ContactParser.php | 28 ++++++++++++++++++++++++++++ src/Parsers/RestrictionParser.php | 4 +++- src/Parsers/SituationParser.php | 12 +++++++++--- src/Parsers/UrlParser.php | 27 +++++++++++++++++++++++++++ 8 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 src/Models/Contact.php create mode 100644 src/Parsers/ContactParser.php create mode 100644 src/Parsers/UrlParser.php diff --git a/src/Api/Situations.php b/src/Api/Situations.php index 9351287..463aaeb 100644 --- a/src/Api/Situations.php +++ b/src/Api/Situations.php @@ -6,11 +6,13 @@ use Swis\Melvin\Client; use Swis\Melvin\Parsers\AttachmentParser; +use Swis\Melvin\Parsers\ContactParser; use Swis\Melvin\Parsers\DetourParser; use Swis\Melvin\Parsers\GeometryParser; use Swis\Melvin\Parsers\PeriodParser; use Swis\Melvin\Parsers\RestrictionParser; use Swis\Melvin\Parsers\SituationParser; +use Swis\Melvin\Parsers\UrlParser; use Swis\Melvin\SituationFilterParameters; class Situations extends AbstractApi @@ -27,7 +29,9 @@ public function __construct(Client $client, ?SituationParser $situationParser = new PeriodParser(), new AttachmentParser(), new RestrictionParser($geometryParser), - new DetourParser($geometryParser) + new DetourParser($geometryParser), + new ContactParser(), + new UrlParser() ); } diff --git a/src/Models/Contact.php b/src/Models/Contact.php new file mode 100644 index 0000000..5470502 --- /dev/null +++ b/src/Models/Contact.php @@ -0,0 +1,24 @@ +contactId, + $object->firstName, + $object->prefix, + $object->lastName, + $object->email, + $object->phone, + $object->organisation ?? $object->organization, + $object->parentSituationId, + $object->function, + $object->publicPhone, + $object->active, + $object->createdById + ); + } +} diff --git a/src/Parsers/RestrictionParser.php b/src/Parsers/RestrictionParser.php index 86cedca..ead2096 100644 --- a/src/Parsers/RestrictionParser.php +++ b/src/Parsers/RestrictionParser.php @@ -42,7 +42,9 @@ public function parse(\stdClass $object, int $index): Restriction if ($vehicleInformation = (array) ($object->properties->vehicleInformation ?? []) ? $object->properties->vehicleInformation : null) { $vehicleInformation = new VehicleInformation( $vehicleInformation->heightCharacteristic ?? null, - $vehicleInformation->lengthCharacteristic ?? null + $vehicleInformation->lengthCharacteristic ?? null, + $vehicleInformation->widthCharacteristic ?? null, + $vehicleInformation->grossWeightCharacteristic ?? null, ); } diff --git a/src/Parsers/SituationParser.php b/src/Parsers/SituationParser.php index 5a9d9e8..42dab7d 100644 --- a/src/Parsers/SituationParser.php +++ b/src/Parsers/SituationParser.php @@ -27,7 +27,9 @@ public function __construct( protected PeriodParser $periodParser, protected AttachmentParser $attachmentParser, protected RestrictionParser $restrictionParser, - protected DetourParser $detourParser + protected DetourParser $detourParser, + protected ContactParser $contactParser, + protected UrlParser $urlParser ) { } @@ -90,7 +92,7 @@ public function parse(\stdClass $object, array $restrictions, array $detours = [ $object->properties->project, Source::from($object->properties->source), $object->properties->published, - ($object->properties->url ?? '') ?: null, + $this->urlParser->parse($object->properties->url ?? ''), ($object->properties->urlDescription ?? '') ?: null, Delay::from($object->properties->delay), ($object->properties->workType ?? '') ? WorkType::from($object->properties->workType) : null, @@ -107,7 +109,11 @@ public function parse(\stdClass $object, array $restrictions, array $detours = [ $lastChangedBy, array_map([$this->attachmentParser, 'parse'], $object->properties->attachments ?? [], array_keys($object->properties->attachments ?? [])), array_map([$this->restrictionParser, 'parse'], $restrictions, array_keys($restrictions)), - array_map([$this->detourParser, 'parse'], $detours, array_keys($detours)) + array_map([$this->detourParser, 'parse'], $detours, array_keys($detours)), + $object->properties->permitId, + $object->properties->referenceId, + $object->properties->remarks, + array_map([$this->contactParser, 'parse'], $object->properties->contacts ?? []), ); } diff --git a/src/Parsers/UrlParser.php b/src/Parsers/UrlParser.php new file mode 100644 index 0000000..0ea69e0 --- /dev/null +++ b/src/Parsers/UrlParser.php @@ -0,0 +1,27 @@ +