-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uml 3459 return sirius data via new endpoint in new format (#2770)
* UML-3460 Return LPA store LPAs via the new endpoint in the new format * UML-3460 serialised objects, transforming enum and datetimes. used inheritance for the entities to help structure datastore and for future sirius implementation * UML-3460 added tests for casters * UML-3460 using datetime immutable instead of interface * UML-3460 using datetime interface in DateToStringSerializer.php * UML-3460 removed unnecessary lpastore person created new files for dedicated tests * UML-3459 updated properties to alphabetical order * UML-3459 added mappings of linked ids * Update service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php Co-authored-by: Adam Cooper <[email protected]> * UML 3459 updated can_cast_sirius_donor test to also test linked donors --------- Co-authored-by: Adam Cooper <[email protected]>
- Loading branch information
1 parent
aaa4641
commit a4273b6
Showing
29 changed files
with
1,433 additions
and
11 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
service-api/app/src/App/src/Entity/Sirius/Casters/CastSiriusDonor.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use App\Entity\Sirius\SiriusLpaDonor; | ||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
use EventSauce\ObjectHydrator\UnableToHydrateObject; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class CastSiriusDonor implements PropertyCaster | ||
{ | ||
/** | ||
* @throws UnableToHydrateObject | ||
*/ | ||
public function cast(mixed $value, ObjectMapper $hydrator): mixed | ||
{ | ||
return $hydrator->hydrateObject(SiriusLpaDonor::class, $value); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
service-api/app/src/App/src/Entity/Sirius/Casters/CastToSiriusLifeSustainingTreatment.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use App\Enum\LifeSustainingTreatment; | ||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class CastToSiriusLifeSustainingTreatment implements PropertyCaster | ||
{ | ||
public function cast(mixed $value, ObjectMapper $hydrator): mixed | ||
{ | ||
return LifeSustainingTreatment::fromShortName($value)->value; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
service-api/app/src/App/src/Entity/Sirius/Casters/ExtractAddressLine1FromSiriusLpa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class ExtractAddressLine1FromSiriusLpa implements PropertyCaster | ||
{ | ||
public function cast(mixed $value, ObjectMapper $hydrator): ?string | ||
{ | ||
if (is_array($value) && isset($value[0]['addressLine1'])) { | ||
return $value[0]['addressLine1']; | ||
} | ||
|
||
return null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
service-api/app/src/App/src/Entity/Sirius/Casters/ExtractAddressLine2FromSiriusLpa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class ExtractAddressLine2FromSiriusLpa implements PropertyCaster | ||
{ | ||
public function cast(mixed $value, ObjectMapper $hydrator): ?string | ||
{ | ||
if (is_array($value) && isset($value[0]['addressLine2'])) { | ||
return $value[0]['addressLine2']; | ||
} | ||
|
||
return null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
service-api/app/src/App/src/Entity/Sirius/Casters/ExtractAddressLine3FromSiriusLpa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class ExtractAddressLine3FromSiriusLpa implements PropertyCaster | ||
{ | ||
public function cast(mixed $value, ObjectMapper $hydrator): ?string | ||
{ | ||
if (is_array($value) && isset($value[0]['addressLine3'])) { | ||
return $value[0]['addressLine3']; | ||
} | ||
|
||
return null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
service-api/app/src/App/src/Entity/Sirius/Casters/ExtractCountryFromSiriusLpa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class ExtractCountryFromSiriusLpa implements PropertyCaster | ||
{ | ||
public function cast(mixed $value, ObjectMapper $hydrator): ?string | ||
{ | ||
if (is_array($value) && isset($value[0]['country'])) { | ||
return $value[0]['country']; | ||
} | ||
|
||
return null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
service-api/app/src/App/src/Entity/Sirius/Casters/ExtractCountyFromSiriusLpa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class ExtractCountyFromSiriusLpa implements PropertyCaster | ||
{ | ||
public function cast(mixed $value, ObjectMapper $hydrator): ?string | ||
{ | ||
if (is_array($value) && isset($value[0]['county'])) { | ||
return $value[0]['county']; | ||
} | ||
|
||
return null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
service-api/app/src/App/src/Entity/Sirius/Casters/ExtractPostcodeFromSiriusLpa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class ExtractPostcodeFromSiriusLpa implements PropertyCaster | ||
{ | ||
public function cast(mixed $value, ObjectMapper $hydrator): ?string | ||
{ | ||
if (is_array($value) && isset($value[0]['postcode'])) { | ||
return $value[0]['postcode']; | ||
} | ||
|
||
return null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
service-api/app/src/App/src/Entity/Sirius/Casters/ExtractTownFromSiriusLpa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class ExtractTownFromSiriusLpa implements PropertyCaster | ||
{ | ||
public function cast(mixed $value, ObjectMapper $hydrator): ?string | ||
{ | ||
if (is_array($value) && isset($value[0]['town'])) { | ||
return $value[0]['town']; | ||
} | ||
|
||
return null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
service-api/app/src/App/src/Entity/Sirius/Casters/ExtractTypeFromSiriusLpa.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class ExtractTypeFromSiriusLpa implements PropertyCaster | ||
{ | ||
public function cast(mixed $value, ObjectMapper $hydrator): ?string | ||
{ | ||
if (is_array($value) && isset($value[0]['type'])) { | ||
return $value[0]['type']; | ||
} | ||
|
||
return null; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
service-api/app/src/App/src/Entity/Sirius/Casters/LinkedDonorCaster.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius\Casters; | ||
|
||
use Attribute; | ||
use EventSauce\ObjectHydrator\ObjectMapper; | ||
use EventSauce\ObjectHydrator\PropertyCaster; | ||
use EventSauce\ObjectHydrator\UnableToHydrateObject; | ||
|
||
#[Attribute(Attribute::TARGET_PARAMETER)] | ||
class LinkedDonorCaster implements PropertyCaster | ||
{ | ||
/** | ||
* @throws UnableToHydrateObject | ||
*/ | ||
public function cast(mixed $value, ObjectMapper $hydrator): array | ||
{ | ||
$linkedDonors = []; | ||
|
||
foreach ($value as $linked) { | ||
$linkedDonors[] = [ | ||
'id' => $linked['id'], | ||
'uId' => $linked['uId'], | ||
]; | ||
} | ||
|
||
return $linkedDonors; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity\Sirius; | ||
|
||
use App\Entity\Casters\CastToWhenTheLpaCanBeUsed; | ||
use App\Entity\Lpa; | ||
use App\Enum\HowAttorneysMakeDecisions; | ||
use App\Enum\LifeSustainingTreatment; | ||
use App\Enum\LpaType; | ||
use DateTimeImmutable; | ||
use EventSauce\ObjectHydrator\PropertyCasters\CastListToType; | ||
use App\Entity\Sirius\Casters\CastSiriusDonor; | ||
use App\Entity\Sirius\Casters\CastToSiriusLifeSustainingTreatment; | ||
|
||
class SiriusLpa extends Lpa | ||
{ | ||
public function __construct( | ||
?bool $applicationHasGuidance, | ||
?bool $applicationHasRestrictions, | ||
?string $applicationType, | ||
#[CastToWhenTheLpaCanBeUsed] | ||
?HowAttorneysMakeDecisions $attorneyActDecisions, | ||
#[CastListToType(SiriusLpaAttorney::class)] | ||
?array $attorneys, | ||
?LpaType $caseSubtype, | ||
?string $channel, | ||
?DateTimeImmutable $dispatchDate, | ||
#[CastSiriusDonor] | ||
?object $donor, | ||
?bool $hasSeveranceWarning, | ||
?DateTimeImmutable $invalidDate, | ||
#[CastToSiriusLifeSustainingTreatment] | ||
?LifeSustainingTreatment $lifeSustainingTreatment, | ||
?DateTimeImmutable $lpaDonorSignatureDate, | ||
?bool $lpaIsCleansed, | ||
?string $onlineLpaId, | ||
?DateTimeImmutable $receiptDate, | ||
?DateTimeImmutable $registrationDate, | ||
?DateTimeImmutable $rejectedDate, | ||
#[CastListToType(SiriusLpaAttorney::class)] | ||
?array $replacementAttorneys, | ||
?string $status, | ||
?DateTimeImmutable $statusDate, | ||
#[CastListToType(SiriusLpaTrustCorporations::class)] | ||
?array $trustCorporations, | ||
?string $uId, | ||
?DateTimeImmutable $withdrawnDate, | ||
) { | ||
parent::__construct( | ||
$applicationHasGuidance, | ||
$applicationHasRestrictions, | ||
$applicationType, | ||
$attorneyActDecisions, | ||
$attorneys, | ||
$caseSubtype, | ||
$channel, | ||
$dispatchDate, | ||
$donor, | ||
$hasSeveranceWarning, | ||
$invalidDate, | ||
$lifeSustainingTreatment, | ||
$lpaDonorSignatureDate, | ||
$lpaIsCleansed, | ||
$onlineLpaId, | ||
$receiptDate, | ||
$registrationDate, | ||
$rejectedDate, | ||
$replacementAttorneys, | ||
$status, | ||
$statusDate, | ||
$trustCorporations, | ||
$uId, | ||
$withdrawnDate | ||
); | ||
} | ||
} |
Oops, something went wrong.