Skip to content

Commit

Permalink
fix(ZMS): show alternative locations for offices (#820)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Fink <tom@Thomass-MacBook-Air.local>
  • Loading branch information
ThomasAFink and Thomas Fink authored Feb 6, 2025
1 parent 160dae9 commit a7b3a64
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 29 deletions.
6 changes: 6 additions & 0 deletions zmscitizenapi/src/Zmscitizenapi/Models/Office.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class Office extends Entity implements JsonSerializable
/** @var array|null */
public ?array $displayNameAlternatives = null;

/** @var bool|null */
public ?bool $showAlternativeLocations = null;

/** @var string|null */
public ?string $organization = null;

Expand All @@ -43,6 +46,7 @@ public function __construct(
int $id,
string $name,
?array $address = null,
?bool $showAlternativeLocations = null,
?array $displayNameAlternatives = null,
?string $organization = null,
?string $organizationUnit = null,
Expand All @@ -53,6 +57,7 @@ public function __construct(
$this->id = $id;
$this->name = $name;
$this->address = $address;
$this->showAlternativeLocations = $showAlternativeLocations;
$this->displayNameAlternatives = $displayNameAlternatives;
$this->organization = $organization;
$this->organizationUnit = $organizationUnit;
Expand Down Expand Up @@ -81,6 +86,7 @@ public function toArray(): array
'id' => $this->id,
'name' => $this->name,
'address' => $this->address,
'showAlternativeLocations' => $this->showAlternativeLocations,
'displayNameAlternatives' => $this->displayNameAlternatives,
'organization' => $this->organization,
'organizationUnit' => $this->organizationUnit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static function mapOfficesWithScope(ProviderList $providerList): OfficeLi
id: isset($provider->id) ? (int) $provider->id : 0,
name: isset($provider->displayName) ? $provider->displayName : (isset($provider->name) ? $provider->name : null),
address: isset($provider->data['address']) ? $provider->data['address'] : null,
showAlternativeLocations: isset($provider->data['showAlternativeLocations']) ? $provider->data['showAlternativeLocations'] : null,
displayNameAlternatives: $provider->data['displayNameAlternatives'] ?? [],
organization: $provider->data['organization'] ?? null,
organizationUnit: $provider->data['organizationUnit'] ?? null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static function getOffices(): OfficeList
id: (int) $provider->id,
name: $provider->displayName ?? $provider->name,
address: $provider->data['address'] ?? null,
showAlternativeLocations: $provider->data['showAlternativeLocations'] ?? null,
displayNameAlternatives: $provider->data['displayNameAlternatives'] ?? [],
organization: $provider->data['organization'] ?? null,
organizationUnit: $provider->data['organizationUnit'] ?? null,
Expand Down Expand Up @@ -251,6 +252,11 @@ public static function getOfficeListByServiceId(int $serviceId): OfficeList|arra
$offices[] = new Office(
id: (int) $provider->id,
name: $provider->name,
showAlternativeLocations: $provider->data['showAlternativeLocations'] ?? null,
displayNameAlternatives: $provider->data['displayNameAlternatives'] ?? [],
organization: $provider->data['organization'] ?? null,
organizationUnit: $provider->data['organizationUnit'] ?? null,
slotTimeInMinutes: $provider->data['slotTimeInMinutes'] ?? null,
address: $provider->address ?? null,
geo: $provider->geo ?? null,
scope: $scope
Expand Down Expand Up @@ -373,6 +379,7 @@ public static function getOfficesThatProvideService(int $serviceId): OfficeList|
id: (int) $provider->id,
name: $provider->displayName ?? $provider->name,
address: $provider->data['address'] ?? null,
showAlternativeLocations: $provider->data['showAlternativeLocations'] ?? null,
displayNameAlternatives: $provider->data['displayNameAlternatives'] ?? [],
organization: $provider->data['organization'] ?? null,
organizationUnit: $provider->data['organizationUnit'] ?? null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function testRendering()
"id" => 9999999,
"name" => "Unittest Source Dienstleister 2",
"address" => null,
"displayNameAlternatives" => null,
"showAlternativeLocations" => true,
"displayNameAlternatives" => [],
"organization" => null,
"organizationUnit" => null,
"slotTimeInMinutes" => null,
Expand Down Expand Up @@ -102,7 +103,8 @@ public function testRenderingRequestRelation()
"id" => 9999998,
"name" => "Unittest Source Dienstleister",
"address" => null,
"displayNameAlternatives" => null,
"showAlternativeLocations" => false,
"displayNameAlternatives" => [],
"organization" => null,
"organizationUnit" => null,
"slotTimeInMinutes" => null,
Expand Down Expand Up @@ -139,7 +141,8 @@ public function testRenderingRequestRelation()
"id" => 9999999,
"name" => "Unittest Source Dienstleister 2",
"address" => null,
"displayNameAlternatives" => null,
"showAlternativeLocations" => true,
"displayNameAlternatives" => [],
"organization" => null,
"organizationUnit" => null,
"slotTimeInMinutes" => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function testRendering()
"id" => 9999998,
"name" => "Unittest Source Dienstleister",
"address" => null,
"showAlternativeLocations" => false,
"displayNameAlternatives" => [],
"organization" => null,
"organizationUnit" => null,
Expand Down Expand Up @@ -81,6 +82,7 @@ public function testRendering()
"id" => 9999999,
"name" => "Unittest Source Dienstleister 2",
"address" => null,
"showAlternativeLocations" => true,
"displayNameAlternatives" => [],
"organization" => null,
"organizationUnit" => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function testRendering()
"id" => 9999998,
"name" => "Unittest Source Dienstleister",
"address" => null,
"showAlternativeLocations" => false,
"displayNameAlternatives" => [],
"organization" => null,
"organizationUnit" => null,
Expand Down Expand Up @@ -81,6 +82,7 @@ public function testRendering()
"id" => 9999999,
"name" => "Unittest Source Dienstleister 2",
"address" => null,
"showAlternativeLocations" => true,
"displayNameAlternatives" => [],
"organization" => null,
"organizationUnit" => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"geo": {
"lat": "48.12750898398659",
"lon": "11.604317899956524"
}
},
"showAlternativeLocations": false
},
"contact": {
"city": "Berlin",
Expand All @@ -46,7 +47,8 @@
"geo": {
"lat": "48.12750898398659",
"lon": "11.604317899956524"
}
},
"showAlternativeLocations": true
},
"contact": {
"city": "Berlin",
Expand Down
33 changes: 28 additions & 5 deletions zmsentities/schema/citizenapi/collections/officeList.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"type": ["array", "object", "null"],
"type": [
"array",
"object",
"null"
],
"properties": {
"offices": {
"type": "array",
Expand All @@ -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",
Expand Down Expand Up @@ -59,19 +70,31 @@
}
},
"displayNameAlternatives": {
"type": ["array", "null"],
"type": [
"array",
"null"
],
"description": "Alternative names of the office"
},
"organization": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"description": "The name of the Organization"
},
"organizationUnit": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"description": "The name of the organization"
},
"slotTimeInMinutes": {
"type": ["integer", "null"],
"type": [
"integer",
"null"
],
"description": "Slot time in minutes"
},
"geo": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -64,19 +71,31 @@
}
},
"displayNameAlternatives": {
"type": ["array", "null"],
"type": [
"array",
"null"
],
"description": "Alternative names of the office"
},
"organization": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"description": "The name of the Organization"
},
"organizationUnit": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"description": "The name of the organization"
},
"slotTimeInMinutes": {
"type": ["integer", "null"],
"type": [
"integer",
"null"
],
"description": "Slot time in minutes"
},
"geo": {
Expand Down
65 changes: 51 additions & 14 deletions zmsentities/schema/citizenapi/office.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -40,23 +61,39 @@
}
},
"displayNameAlternatives": {
"type": ["array", "null"],
"type": [
"array",
"null"
],
"description": "Alternative names of the office"
},
"organization": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"description": "The name of the Organization"
},
"organizationUnit": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"description": "The name of the organization"
},
"slotTimeInMinutes": {
"type": ["integer", "null"],
"type": [
"integer",
"null"
],
"description": "Slot time in minutes"
},
"geo": {
"type": ["array", "object", "null"],
"type": [
"array",
"object",
"null"
],
"description": "Geographical coordinates of the office",
"properties": {
"lat": {
Expand All @@ -73,10 +110,10 @@
}
}
},
"scope": {

}
"scope": {}
},
"required": ["id"],
"required": [
"id"
],
"description": "Schema definition for the Office entity"
}
}

0 comments on commit a7b3a64

Please sign in to comment.