Skip to content

Commit

Permalink
feat(MPDZBS-877): Add showAlternativeLocations to offices endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAFink committed Jan 15, 2025
1 parent 1c7d4f4 commit 63fe1a0
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 15 deletions.
8 changes: 7 additions & 1 deletion zmscitizenapi/src/Zmscitizenapi/Models/Office.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function testRendering()
[
"id" => 9999999,
"name" => "Unittest Source Dienstleister 2",
"showAlternativeLocations" => true,
"address" => null,
"geo" => null,
"scope" => [
Expand Down Expand Up @@ -97,6 +98,7 @@ public function testRenderingRequestRelation()
[
"id" => 9999998,
"name" => "Unittest Source Dienstleister",
"showAlternativeLocations" => false,
"address" => null,
"geo" => null,
"scope" => [
Expand Down Expand Up @@ -130,6 +132,7 @@ public function testRenderingRequestRelation()
[
"id" => 9999999,
"name" => "Unittest Source Dienstleister 2",
"showAlternativeLocations" => true,
"address" => null,
"geo" => null,
"scope" => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function testRendering()
[
"id" => 9999998,
"name" => "Unittest Source Dienstleister",
"showAlternativeLocations" => false,
"address" => null,
"geo" => [
"lat" => "48.12750898398659",
Expand Down Expand Up @@ -76,6 +77,7 @@ public function testRendering()
[
"id" => 9999999,
"name" => "Unittest Source Dienstleister 2",
"showAlternativeLocations" => true,
"address" => null,
"geo" => [
"lat" => "48.12750898398659",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function testRendering()
[
"id" => 9999998,
"name" => "Unittest Source Dienstleister",
"showAlternativeLocations" => false,
"address" => null,
"geo" => [
"lat" => "48.12750898398659",
Expand Down Expand Up @@ -76,6 +77,7 @@ public function testRendering()
[
"id" => 9999999,
"name" => "Unittest Source Dienstleister 2",
"showAlternativeLocations" => true,
"address" => null,
"geo" => [
"lat" => "48.12750898398659",
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
13 changes: 12 additions & 1 deletion 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
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
45 changes: 35 additions & 10 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,7 +61,11 @@
}
},
"geo": {
"type": ["array", "object", "null"],
"type": [
"array",
"object",
"null"
],
"description": "Geographical coordinates of the office",
"properties": {
"lat": {
Expand All @@ -57,10 +82,10 @@
}
}
},
"scope": {

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

0 comments on commit 63fe1a0

Please sign in to comment.