From 63fe1a0c9af4943337ac0d41a0687f1d24981962 Mon Sep 17 00:00:00 2001 From: thomasafink Date: Wed, 15 Jan 2025 16:29:53 +0100 Subject: [PATCH] feat(MPDZBS-877): Add showAlternativeLocations to offices endpoints --- .../src/Zmscitizenapi/Models/Office.php | 8 +++- .../Services/Core/MapperService.php | 1 + .../Services/Core/ZmsApiFacadeService.php | 3 ++ .../OfficeListByServiceControllerTest.php | 3 ++ .../Office/OfficesListControllerTest.php | 2 + ...OfficesServicesRelationsControllerTest.php | 2 + .../Services/Core/ZmsApiFacadeServiceTest.php | 3 +- .../fixtures/GET_SourceGet_dldb.json | 6 ++- .../citizenapi/collections/officeList.json | 13 +++++- .../officeServiceAndRelationList.json | 7 +++ zmsentities/schema/citizenapi/office.json | 45 ++++++++++++++----- 11 files changed, 78 insertions(+), 15 deletions(-) diff --git a/zmscitizenapi/src/Zmscitizenapi/Models/Office.php b/zmscitizenapi/src/Zmscitizenapi/Models/Office.php index 8290febc6..df9de3f2e 100644 --- a/zmscitizenapi/src/Zmscitizenapi/Models/Office.php +++ b/zmscitizenapi/src/Zmscitizenapi/Models/Office.php @@ -18,6 +18,9 @@ class Office extends Entity implements JsonSerializable /** @var string */ public string $name; + /** @var bool|null */ + public ?bool $showAlternativeLocations; + /** @var array|null */ public ?array $address = null; @@ -32,14 +35,16 @@ class Office extends Entity implements JsonSerializable * * @param int $id * @param string $name + * @param bool $showAlternativeLocations * @param array|null $address * @param array|null $geo * @param ThinnedScope|null $scope */ - public function __construct(int $id, string $name, ?array $address = null, ?array $geo = null, ?ThinnedScope $scope = null) + public function __construct(int $id, string $name, bool $showAlternativeLocations, ?array $address = null, ?array $geo = null, ?ThinnedScope $scope = null) { $this->id = $id; $this->name = $name; + $this->showAlternativeLocations = $showAlternativeLocations; $this->address = $address; $this->geo = $geo; $this->scope = $scope; @@ -64,6 +69,7 @@ public function toArray(): array return [ 'id' => $this->id, 'name' => $this->name, + 'showAlternativeLocations' => $this->showAlternativeLocations, 'address' => $this->address, 'geo' => $this->geo, 'scope' => $this->scope?->toArray(), diff --git a/zmscitizenapi/src/Zmscitizenapi/Services/Core/MapperService.php b/zmscitizenapi/src/Zmscitizenapi/Services/Core/MapperService.php index ccc339e4e..4f1abf98c 100644 --- a/zmscitizenapi/src/Zmscitizenapi/Services/Core/MapperService.php +++ b/zmscitizenapi/src/Zmscitizenapi/Services/Core/MapperService.php @@ -62,6 +62,7 @@ public static function mapOfficesWithScope(ProviderList $providerList): OfficeLi $offices[] = new Office( id: isset($provider->id) ? (int) $provider->id : 0, name: isset($provider->displayName) ? $provider->displayName : (isset($provider->name) ? $provider->name : null), + showAlternativeLocations: isset($provider->data['showAlternativeLocations']) ? $provider->data['showAlternativeLocations'] : null, address: isset($provider->data['address']) ? $provider->data['address'] : null, geo: isset($provider->data['geo']) ? $provider->data['geo'] : null, scope: isset($providerScope) && !isset($providerScope['errors']) ? new ThinnedScope( diff --git a/zmscitizenapi/src/Zmscitizenapi/Services/Core/ZmsApiFacadeService.php b/zmscitizenapi/src/Zmscitizenapi/Services/Core/ZmsApiFacadeService.php index 32df4fff5..28bb07f0f 100644 --- a/zmscitizenapi/src/Zmscitizenapi/Services/Core/ZmsApiFacadeService.php +++ b/zmscitizenapi/src/Zmscitizenapi/Services/Core/ZmsApiFacadeService.php @@ -60,6 +60,7 @@ public static function getOffices(): OfficeList|array $offices[] = new Office( id: (int) $provider->id, name: $provider->displayName ?? $provider->name, + showAlternativeLocations: $provider->data['showAlternativeLocations'] ?? null, address: $provider->data['address'] ?? null, geo: $provider->data['geo'] ?? null, scope: $matchingScope ? new ThinnedScope( @@ -245,6 +246,7 @@ public static function getOfficeListByServiceId(int $serviceId): OfficeList|arra $offices[] = new Office( id: (int) $provider->id, name: $provider->name, + showAlternativeLocations: $provider->data['showAlternativeLocations'] ?? null, address: $provider->address ?? null, geo: $provider->geo ?? null, scope: $scope @@ -366,6 +368,7 @@ public static function getOfficesThatProvideService(int $serviceId): OfficeList| $offices[] = new Office( id: (int) $provider->id, name: $provider->displayName ?? $provider->name, + showAlternativeLocations: $provider->data['showAlternativeLocations'] ?? null, address: $provider->data['address'] ?? null, geo: $provider->data['geo'] ?? null, scope: $scope instanceof ThinnedScope ? $scope : null diff --git a/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficeListByServiceControllerTest.php b/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficeListByServiceControllerTest.php index 2a0984afd..1a69ec7fe 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficeListByServiceControllerTest.php +++ b/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficeListByServiceControllerTest.php @@ -41,6 +41,7 @@ public function testRendering() [ "id" => 9999999, "name" => "Unittest Source Dienstleister 2", + "showAlternativeLocations" => true, "address" => null, "geo" => null, "scope" => [ @@ -97,6 +98,7 @@ public function testRenderingRequestRelation() [ "id" => 9999998, "name" => "Unittest Source Dienstleister", + "showAlternativeLocations" => false, "address" => null, "geo" => null, "scope" => [ @@ -130,6 +132,7 @@ public function testRenderingRequestRelation() [ "id" => 9999999, "name" => "Unittest Source Dienstleister 2", + "showAlternativeLocations" => true, "address" => null, "geo" => null, "scope" => [ diff --git a/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesListControllerTest.php b/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesListControllerTest.php index 85f19f812..b2a4d2ba4 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesListControllerTest.php +++ b/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesListControllerTest.php @@ -40,6 +40,7 @@ public function testRendering() [ "id" => 9999998, "name" => "Unittest Source Dienstleister", + "showAlternativeLocations" => false, "address" => null, "geo" => [ "lat" => "48.12750898398659", @@ -76,6 +77,7 @@ public function testRendering() [ "id" => 9999999, "name" => "Unittest Source Dienstleister 2", + "showAlternativeLocations" => true, "address" => null, "geo" => [ "lat" => "48.12750898398659", diff --git a/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesServicesRelationsControllerTest.php b/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesServicesRelationsControllerTest.php index 31bcc34ea..b94050a26 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesServicesRelationsControllerTest.php +++ b/zmscitizenapi/tests/Zmscitizenapi/Controllers/Office/OfficesServicesRelationsControllerTest.php @@ -40,6 +40,7 @@ public function testRendering() [ "id" => 9999998, "name" => "Unittest Source Dienstleister", + "showAlternativeLocations" => false, "address" => null, "geo" => [ "lat" => "48.12750898398659", @@ -76,6 +77,7 @@ public function testRendering() [ "id" => 9999999, "name" => "Unittest Source Dienstleister 2", + "showAlternativeLocations" => true, "address" => null, "geo" => [ "lat" => "48.12750898398659", diff --git a/zmscitizenapi/tests/Zmscitizenapi/Services/Core/ZmsApiFacadeServiceTest.php b/zmscitizenapi/tests/Zmscitizenapi/Services/Core/ZmsApiFacadeServiceTest.php index 839b7ca39..35c7d8816 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/Services/Core/ZmsApiFacadeServiceTest.php +++ b/zmscitizenapi/tests/Zmscitizenapi/Services/Core/ZmsApiFacadeServiceTest.php @@ -64,7 +64,8 @@ public function testGetOfficesSuccess(): void 'city' => 'Test City', 'postal_code' => '12345' ], - 'geo' => ['lat' => 48.137154, 'lon' => 11.576124] + 'geo' => ['lat' => 48.137154, 'lon' => 11.576124], + 'showAlternativeLocations' => false ]; $scope = new Scope(); diff --git a/zmscitizenapi/tests/Zmscitizenapi/fixtures/GET_SourceGet_dldb.json b/zmscitizenapi/tests/Zmscitizenapi/fixtures/GET_SourceGet_dldb.json index 8bc72c446..99ac1af9e 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/fixtures/GET_SourceGet_dldb.json +++ b/zmscitizenapi/tests/Zmscitizenapi/fixtures/GET_SourceGet_dldb.json @@ -24,7 +24,8 @@ "geo": { "lat": "48.12750898398659", "lon": "11.604317899956524" - } + }, + "showAlternativeLocations": false }, "contact": { "city": "Berlin", @@ -46,7 +47,8 @@ "geo": { "lat": "48.12750898398659", "lon": "11.604317899956524" - } + }, + "showAlternativeLocations": true }, "contact": { "city": "Berlin", diff --git a/zmsentities/schema/citizenapi/collections/officeList.json b/zmsentities/schema/citizenapi/collections/officeList.json index e067acb43..618c64e73 100644 --- a/zmsentities/schema/citizenapi/collections/officeList.json +++ b/zmsentities/schema/citizenapi/collections/officeList.json @@ -1,5 +1,9 @@ { - "type": ["array", "object", "null"], + "type": [ + "array", + "object", + "null" + ], "properties": { "offices": { "type": "array", @@ -21,6 +25,13 @@ ], "description": "The name of the office" }, + "showAlternativeLocations": { + "type": [ + "boolean", + "null" + ], + "description": "Show alternative office locations in the citizen calendar" + }, "address": { "type": [ "array", diff --git a/zmsentities/schema/citizenapi/collections/officeServiceAndRelationList.json b/zmsentities/schema/citizenapi/collections/officeServiceAndRelationList.json index 03a52e30b..e1b0318ac 100644 --- a/zmsentities/schema/citizenapi/collections/officeServiceAndRelationList.json +++ b/zmsentities/schema/citizenapi/collections/officeServiceAndRelationList.json @@ -26,6 +26,13 @@ ], "description": "The name of the office" }, + "showAlternativeLocations": { + "type": [ + "boolean", + "null" + ], + "description": "Show alternative office locations in the citizen calendar" + }, "address": { "type": [ "array", diff --git a/zmsentities/schema/citizenapi/office.json b/zmsentities/schema/citizenapi/office.json index ce42c4360..6f0621925 100644 --- a/zmsentities/schema/citizenapi/office.json +++ b/zmsentities/schema/citizenapi/office.json @@ -1,20 +1,41 @@ { "title": "Office", - "type": ["array", "object"], + "type": [ + "array", + "object" + ], "properties": { "id": { "type": "integer", "description": "Unique identifier for the office" }, "name": { - "type": ["string", "null"], + "type": [ + "string", + "null" + ], "description": "The name of the office" }, + "showAlternativeLocations": { + "type": [ + "boolean", + "null" + ], + "description": "Show alternative office locations in the citizen calendar" + }, "address": { - "type": ["array", "object", "null"], + "type": [ + "array", + "object", + "null" + ], "description": "The address of the office", "items": { - "type": ["array", "object", "null"], + "type": [ + "array", + "object", + "null" + ], "properties": { "house_number": { "type": "string", @@ -40,7 +61,11 @@ } }, "geo": { - "type": ["array", "object", "null"], + "type": [ + "array", + "object", + "null" + ], "description": "Geographical coordinates of the office", "properties": { "lat": { @@ -57,10 +82,10 @@ } } }, - "scope": { - - } + "scope": {} }, - "required": ["id"], + "required": [ + "id" + ], "description": "Schema definition for the Office entity" -} +} \ No newline at end of file