Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 4 additions & 31 deletions zmsadmin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion zmscitizenapi/src/Zmscitizenapi/Models/ThinnedScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class ThinnedScope extends Entity implements JsonSerializable
public ?string $slotsPerAppointment;
public ?string $appointmentsPerMail;
public ?string $whitelistedMails;
public ?int $reservationDuration = null;

public function __construct(int $id = 0, ?ThinnedProvider $provider = null, ?string $shortName = null, ?string $emailFrom = null, ?bool $emailRequired = null, ?bool $telephoneActivated = null, ?bool $telephoneRequired = null, ?bool $customTextfieldActivated = null, ?bool $customTextfieldRequired = null, ?string $customTextfieldLabel = null, ?bool $customTextfield2Activated = null, ?bool $customTextfield2Required = null, ?string $customTextfield2Label = null, ?bool $captchaActivatedRequired = null, ?string $displayInfo = null, ?string $slotsPerAppointment = null, ?string $appointmentsPerMail = null, ?string $whitelistedMails = null)
public function __construct(int $id = 0, ?ThinnedProvider $provider = null, ?string $shortName = null, ?string $emailFrom = null, ?bool $emailRequired = null, ?bool $telephoneActivated = null, ?bool $telephoneRequired = null, ?bool $customTextfieldActivated = null, ?bool $customTextfieldRequired = null, ?string $customTextfieldLabel = null, ?bool $customTextfield2Activated = null, ?bool $customTextfield2Required = null, ?string $customTextfield2Label = null, ?bool $captchaActivatedRequired = null, ?string $displayInfo = null, ?string $slotsPerAppointment = null, ?string $appointmentsPerMail = null, ?string $whitelistedMails = null, ?int $reservationDuration = null)
{
$this->id = $id;
$this->provider = $provider;
Expand All @@ -51,6 +52,7 @@ public function __construct(int $id = 0, ?ThinnedProvider $provider = null, ?str
$this->slotsPerAppointment = $slotsPerAppointment;
$this->appointmentsPerMail = $appointmentsPerMail;
$this->whitelistedMails = $whitelistedMails;
$this->reservationDuration = $reservationDuration;
$this->ensureValid();
}

Expand Down Expand Up @@ -146,6 +148,11 @@ public function getWhitelistedMails(): ?string
return $this->whitelistedMails;
}

public function getReservationDuration(): ?int
{
return $this->reservationDuration;
}

public function toArray(): array
{
return [
Expand All @@ -167,6 +174,7 @@ public function toArray(): array
'slotsPerAppointment' => $this->slotsPerAppointment,
'appointmentsPerMail' => $this->appointmentsPerMail,
'whitelistedMails' => $this->whitelistedMails,
'reservationDuration' => $this->reservationDuration,
];
}

Expand Down
22 changes: 20 additions & 2 deletions zmscitizenapi/src/Zmscitizenapi/Services/Core/MapperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ public static function mapScopeForProvider(int $providerId, ?ThinnedScopeList $s
return $matchingScope;
}

public static function extractReservationDuration(
\BO\Zmsentities\Scope|\BO\Zmscitizenapi\Models\ThinnedScope|null $scope
): ?int {
if ($scope === null) {
return null;
}
if ($scope instanceof \BO\Zmscitizenapi\Models\ThinnedScope) {
$v = $scope->getReservationDuration();
return $v !== null ? (int) $v : null;
}
$v = $scope?->toProperty()?->preferences?->appointment?->reservationDuration?->get();
return $v !== null ? (int) $v : null;
}

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
Expand All @@ -71,6 +85,8 @@ public static function mapOfficesWithScope(ProviderList $providerList, bool $sho
continue;
}

$rd = self::extractReservationDuration($providerScope);

$offices[] = new Office(
id: isset($provider->id) ? (int) $provider->id : 0,
name: isset($provider->displayName) ? $provider->displayName : (isset($provider->name) ? $provider->name : null),
Expand Down Expand Up @@ -101,7 +117,8 @@ public static function mapOfficesWithScope(ProviderList $providerList, bool $sho
displayInfo: isset($providerScope->displayInfo) ? (string) $providerScope->displayInfo : null,
slotsPerAppointment: isset($providerScope->slotsPerAppointment) ? ((string) $providerScope->slotsPerAppointment === '' ? null : (string) $providerScope->slotsPerAppointment) : null,
appointmentsPerMail: isset($providerScope->appointmentsPerMail) ? ((string) $providerScope->appointmentsPerMail === '' ? null : (string) $providerScope->appointmentsPerMail) : null,
whitelistedMails: isset($providerScope->whitelistedMails) ? ((string) $providerScope->whitelistedMails === '' ? null : (string) $providerScope->whitelistedMails) : null
whitelistedMails: isset($providerScope->whitelistedMails) ? ((string) $providerScope->whitelistedMails === '' ? null : (string) $providerScope->whitelistedMails) : null,
reservationDuration: $rd,
) : null,
maxSlotsPerAppointment: isset($providerScope) && !isset($providerScope['errors']) && isset($providerScope->slotsPerAppointment) ? ((string) $providerScope->slotsPerAppointment === '' ? null : (string) $providerScope->slotsPerAppointment) : null
);
Expand Down Expand Up @@ -242,7 +259,8 @@ public static function scopeToThinnedScope(Scope $scope): ThinnedScope
displayInfo: isset($scope->data['displayInfo']) ? (string) $scope->data['displayInfo'] : null,
slotsPerAppointment: isset($scope->data['slotsPerAppointment']) ? ((string) $scope->data['slotsPerAppointment'] === '' ? null : (string) $scope->data['slotsPerAppointment']) : null,
appointmentsPerMail: isset($scope->data['appointmentsPerMail']) ? ((string) $scope->data['appointmentsPerMail'] === '' ? null : (string) $scope->data['appointmentsPerMail']) : null,
whitelistedMails: isset($scope->data['whitelistedMails']) ? ((string) $scope->data['whitelistedMails'] === '' ? null : (string) $scope->data['whitelistedMails']) : null
whitelistedMails: isset($scope->data['whitelistedMails']) ? ((string) $scope->data['whitelistedMails'] === '' ? null : (string) $scope->data['whitelistedMails']) : null,
reservationDuration: MapperService::extractReservationDuration($scope),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static function getOffices(bool $showUnpublished = false): OfficeList
}

$matchingScope = $scopeMap[$provider->source . '_' . $provider->id] ?? null;
$rd = MapperService::extractReservationDuration($matchingScope);
$offices[] = new Office(
id: (int) $provider->id,
name: $provider->displayName ?? $provider->name,
Expand Down Expand Up @@ -119,7 +120,8 @@ public static function getOffices(bool $showUnpublished = false): OfficeList
displayInfo: $matchingScope->getDisplayInfo(),
slotsPerAppointment: ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()),
appointmentsPerMail: ((string) $matchingScope->getAppointmentsPerMail() === '' ? null : (string) $matchingScope->getAppointmentsPerMail()),
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails())
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()),
reservationDuration: $rd,
) : null,
maxSlotsPerAppointment: $matchingScope ? ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()) : null
);
Expand Down Expand Up @@ -156,6 +158,7 @@ public static function getScopes(): ThinnedScopeList|array
$key = $provider->source . '_' . $provider->id;
if (isset($scopeMap[$key])) {
$matchingScope = $scopeMap[$key];
$rd = MapperService::extractReservationDuration($matchingScope);
$scopesProjectionList[] = new ThinnedScope(
id: (int) $matchingScope->id,
provider: MapperService::providerToThinnedProvider($provider),
Expand All @@ -174,7 +177,8 @@ public static function getScopes(): ThinnedScopeList|array
displayInfo: $matchingScope->getDisplayInfo(),
slotsPerAppointment: ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()),
appointmentsPerMail: ((string) $matchingScope->getAppointmentsPerMail() === '' ? null : (string) $matchingScope->getAppointmentsPerMail()),
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails())
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()),
reservationDuration: $rd,
);
}
}
Expand Down Expand Up @@ -269,6 +273,7 @@ public static function getScopeByOfficeId(int $officeId): ThinnedScope|array
$finalProvider = $providerKey && isset($providerMap[$providerKey])
? $providerMap[$providerKey]
: $scopeProvider;
$rd = MapperService::extractReservationDuration($matchingScope);
$result = [
'id' => $matchingScope->id,
'provider' => MapperService::providerToThinnedProvider($finalProvider) ?? null,
Expand All @@ -287,7 +292,8 @@ public static function getScopeByOfficeId(int $officeId): ThinnedScope|array
'displayInfo' => $matchingScope->getDisplayInfo() ?? null,
'slotsPerAppointment' => ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()) ?? null,
'appointmentsPerMail' => ((string) $matchingScope->getAppointmentsPerMail() === '' ? null : (string) $matchingScope->getAppointmentsPerMail()) ?? null,
'whitelistedMails' => ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()) ?? null
'whitelistedMails' => ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()) ?? null,
'reservationDuration' => $rd,
];
return new ThinnedScope(
id: (int) $result['id'],
Expand All @@ -307,7 +313,8 @@ public static function getScopeByOfficeId(int $officeId): ThinnedScope|array
displayInfo: $result['displayInfo'],
slotsPerAppointment: $result['slotsPerAppointment'],
appointmentsPerMail: $result['appointmentsPerMail'],
whitelistedMails: $result['whitelistedMails']
whitelistedMails: $result['whitelistedMails'],
reservationDuration: $result['reservationDuration']
);
}

Expand Down Expand Up @@ -419,6 +426,7 @@ public static function getScopeById(?int $scopeId): ThinnedScope|array
$matchingProv = ($providerKey && isset($providerMap[$providerKey]))
? $providerMap[$providerKey]
: $scopeProvider;
$rd = MapperService::extractReservationDuration($matchingScope);
return new ThinnedScope(
id: (int) $matchingScope->id,
provider: MapperService::providerToThinnedProvider($matchingProv),
Expand All @@ -437,7 +445,8 @@ public static function getScopeById(?int $scopeId): ThinnedScope|array
displayInfo: $matchingScope->getDisplayInfo() ?? null,
slotsPerAppointment: ((string) $matchingScope->getSlotsPerAppointment() === '' ? null : (string) $matchingScope->getSlotsPerAppointment()) ?? null,
appointmentsPerMail: ((string) $matchingScope->getAppointmentsPerMail() === '' ? null : (string) $matchingScope->getAppointmentsPerMail()) ?? null,
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()) ?? null
whitelistedMails: ((string) $matchingScope->getWhitelistedMails() === '' ? null : (string) $matchingScope->getWhitelistedMails()) ?? null,
reservationDuration: $rd,
);
}

Expand Down Expand Up @@ -700,6 +709,7 @@ public static function getThinnedProcessById(?int $processId, ?string $authKey):
$providerKey = $scopeProvider ? ($scopeProvider->getSource() . '_' . $scopeProvider->id) : null;
$matchingProvider = $providerKey && isset($providerMap[$providerKey]) ? $providerMap[$providerKey] : $scopeProvider;
$thinnedProvider = MapperService::providerToThinnedProvider($matchingProvider);
$rd = MapperService::extractReservationDuration($process->scope);
$thinnedScope = new ThinnedScope(
id: (int) $process->scope->id,
provider: $thinnedProvider,
Expand All @@ -718,7 +728,8 @@ public static function getThinnedProcessById(?int $processId, ?string $authKey):
displayInfo: $process->scope->getDisplayInfo() ?? null,
slotsPerAppointment: ((string) $process->scope->getSlotsPerAppointment() === '' ? null : (string) $process->scope->getSlotsPerAppointment()) ?? null,
appointmentsPerMail: ((string) $process->scope->getAppointmentsPerMail() === '' ? null : (string) $process->scope->getAppointmentsPerMail()) ?? null,
whitelistedMails: ((string) $process->scope->getWhitelistedMails() === '' ? null : (string) $process->scope->getWhitelistedMails()) ?? null
whitelistedMails: ((string) $process->scope->getWhitelistedMails() === '' ? null : (string) $process->scope->getWhitelistedMails()) ?? null,
reservationDuration: $rd,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public function testRendering()
"displayInfo" => null,
"slotsPerAppointment" => null,
"appointmentsPerMail" => 1,
"whitelistedMails" => null
"whitelistedMails" => null,
"reservationDuration" => 15
],
"subRequestCounts" => [],
"serviceId" => 1063424,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public function testRendering()
'displayInfo' => null,
'slotsPerAppointment' => null,
"appointmentsPerMail" => null,
"whitelistedMails" => null
"whitelistedMails" => null,
"reservationDuration" => null
],
'subRequestCounts' => [],
'serviceId' => 10242339,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public function testRendering()
'displayInfo' => null,
'slotsPerAppointment' => null,
"appointmentsPerMail" => null,
"whitelistedMails" => null
"whitelistedMails" => null,
"reservationDuration" => null
],
'subRequestCounts' => [],
'serviceId' => 10242339,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public function testRendering()
'displayInfo' => null,
'slotsPerAppointment' => null,
"appointmentsPerMail" => null,
"whitelistedMails" => null
"whitelistedMails" => null,
"reservationDuration" => null
],
'subRequestCounts' => [],
'serviceId' => 10242339,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public function testRendering()
"displayInfo" => null,
"slotsPerAppointment" => null,
"appointmentsPerMail" => null,
"whitelistedMails" => null
"whitelistedMails" => null,
"reservationDuration" => null
],
"subRequestCounts" => [],
"serviceId" => 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public function testRendering()
"displayInfo" => null,
"slotsPerAppointment" => null,
"appointmentsPerMail" => null,
"whitelistedMails" => null
"whitelistedMails" => null,
"reservationDuration" => null
],
"status" => "reserved",
"subRequestCounts" => [],
Expand Down
Loading
Loading