-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove old check repute url, replace with request to INR VOL-5804
- Loading branch information
Showing
12 changed files
with
322 additions
and
276 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
app/api/module/Api/data/nr/checkGoodReputeRequestTemplate.xml
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CheckGoodRepute_Request xmlns="https://webgate.ec.testa.eu/move-hub/erru/3.4"> | ||
<Header version="3.4" technicalId="afbacb8a-b313-4daa-881b-7b7a65204b69" | ||
workflowId="446940dc-eb68-4462-9424-4893ce051fdb" sentAt="2016-01-01T00:00:00Z" | ||
timeoutValue="2016-01-01T00:00:20Z" from="UK" to="ZZ"/> | ||
<Body businessCaseId="CGR Request Example" originatingAuthority="UK Competent Authority" requestPurpose="Other" | ||
requestSource="Other"> | ||
<SearchedTransportManager> | ||
<TransportManagerNameDetails familyName="Creighton-Ward" firstName="Penelope" dateOfBirth="1939-12-24"/> | ||
<TransportManagerCertificateDetails certificateNumber="CPC004" certificateIssueDate="2012-01-31" certificateIssueCountry="UK"/> | ||
</SearchedTransportManager> | ||
</Body> | ||
</CheckGoodRepute_Request> |
61 changes: 61 additions & 0 deletions
61
app/api/module/Api/data/nr/checkGoodReputeResponseTemplate.xml
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,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CheckGoodRepute_Response xmlns="https://webgate.ec.testa.eu/move-hub/erru/3.4"> | ||
<Header version="3.4" | ||
technicalId="f148c54c-488f-42bc-bae1-8eb09e8f7a3f" | ||
workflowId="446940dc-eb68-4462-9424-4893ce051fdb" | ||
sentAt="2016-01-01T00:00:05Z" | ||
from="EU" | ||
to="IE"/> | ||
<Body businessCaseId="CGR Notification Example" | ||
originatingAuthority="UK Competent Authority"> | ||
<SearchedTransportManager> | ||
<TransportManagerNameDetails familyName="Creighton-Ward" | ||
firstName="Penelope" | ||
dateOfBirth="1939-12-24" | ||
familyNameSearchKey="CRAGTANWAD" | ||
firstNameSearchKey="PANALAP"/> | ||
<TransportManagerCertificateDetails certificateNumber="CPC004" | ||
certificateIssueDate="2012-01-31" | ||
certificateIssueCountry="UK"/> | ||
</SearchedTransportManager> | ||
<MemberState memberStateCode="AT" | ||
statusCode="NotFound"/> | ||
<MemberState memberStateCode="BE" | ||
statusCode="NotFound"/> | ||
<!-- Multiple other countries --> | ||
<MemberState memberStateCode="UK" | ||
statusCode="Found"> | ||
<TransportManagerDetails respondingAuthority=" UK Competent Authority " | ||
searchMethod="CPC"> | ||
<TransportManagerNameDetails familyName="Creighton-Ward" | ||
firstName="Penelope" | ||
dateOfBirth="1939-12-24" | ||
placeOfBirth="London"/> | ||
<TransportManagerAddressDetails address="Address Line 1" | ||
postCode="W1" | ||
city="London" | ||
country="UK"/> | ||
<TransportManagerCertificateDetails certificateNumber="CPC004" | ||
certificateIssueDate="2012-01-31" | ||
certificateIssueCountry="UK" | ||
certificateValidity="Invalid"> | ||
<Fitness fitnessStatus="Unfit" | ||
unfitStartDate="2015-12-09" | ||
unfitEndDate="2016-06-09"/> | ||
</TransportManagerCertificateDetails> | ||
<TransportUndertakings totalManagedUndertakings="1" | ||
totalManagedVehicles="7"> | ||
<TransportUndertaking transportUndertakingName="International Rescue " | ||
numberOfVehicles="7" | ||
communityLicenceNumber="CL-IR-000001-001" | ||
communityLicenceStatus="Active"> | ||
<TransportUndertakingAddress address="Tracy Villa" | ||
postCode="SP1" | ||
city="Tracy Island" | ||
country="UK"/> | ||
</TransportUndertaking> | ||
</TransportUndertakings> | ||
</TransportManagerDetails> | ||
</MemberState> | ||
</Body> | ||
</CheckGoodRepute_Response> |
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
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
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,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dvsa\Olcs\Api\Service\Nr; | ||
|
||
use Dvsa\Olcs\Api\Domain\Util\DateTime\DateTime as DateTimeExtended; | ||
use Olcs\XmlTools\Xml\XmlNodeBuilder; | ||
|
||
class AbstractXmlRequest | ||
{ | ||
public const AUTHORITY_TC = 'Traffic Commissioner'; | ||
|
||
private readonly string $responseDateTime; | ||
|
||
private readonly string $timeoutDateTime; | ||
|
||
private readonly string $technicalId; | ||
|
||
protected string $authority; | ||
|
||
public function __construct(protected readonly XmlNodeBuilder $xmlBuilder, private readonly string $erruVersion) | ||
{ | ||
$dateTime = new DateTimeExtended(); | ||
$this->responseDateTime = $dateTime->format(\DateTime::ATOM); | ||
$this->timeoutDateTime = $dateTime->add(new \DateInterval('PT10S'))->format(\DateTime::ATOM); | ||
$this->technicalId = $this->generateGuid(); | ||
$this->authority = self::AUTHORITY_TC; | ||
} | ||
|
||
protected function getHeader(string $workflowId, string $memberStateCode): array | ||
{ | ||
//if member state was GB, we need to make this UK | ||
$filteredMemberStateCode = ($memberStateCode === 'GB' ? 'UK' : $memberStateCode); | ||
|
||
return [ | ||
'name' => 'Header', | ||
'attributes' => [ | ||
'version' => $this->erruVersion, | ||
'technicalId' => $this->technicalId, | ||
'workflowId' => $workflowId, | ||
'sentAt' => $this->responseDateTime, | ||
'timeoutValue' => $this->timeoutDateTime, | ||
'from' => 'UK', | ||
'to' => $filteredMemberStateCode | ||
], | ||
]; | ||
} | ||
|
||
protected function generateGuid(): string | ||
{ | ||
// com_create_guid is unavailable on our environments | ||
return sprintf( | ||
'%04X%04X-%04X-%04X-%04X-%04X%04X%04X', | ||
mt_rand(0, 65535), | ||
mt_rand(0, 65535), | ||
mt_rand(0, 65535), | ||
mt_rand(16384, 20479), | ||
mt_rand(32768, 49151), | ||
mt_rand(0, 65535), | ||
mt_rand(0, 65535), | ||
mt_rand(0, 65535) | ||
); | ||
} | ||
} |
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,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dvsa\Olcs\Api\Service\Nr; | ||
|
||
use Dvsa\Olcs\Api\Domain\Exception\ForbiddenException; | ||
use Dvsa\Olcs\Api\Entity\Tm\TransportManager; | ||
|
||
class CheckGoodRepute extends AbstractXmlRequest | ||
{ | ||
public function create(TransportManager $transportManager): string | ||
{ | ||
//must have address information as a minimum | ||
if (!$transportManager->hasReputeCheckAddress()) { | ||
throw new ForbiddenException('No Tm address information available for repute check'); | ||
} | ||
|
||
$xmlData = [ | ||
'Header' => $this->getHeader($this->generateGuid(), 'ZZ'), | ||
'Body' => $this->getBody($transportManager) | ||
]; | ||
|
||
$this->xmlBuilder->setData($xmlData); | ||
return $this->xmlBuilder->buildTemplate(); | ||
} | ||
|
||
/** | ||
* Fetches array of information for the xml body | ||
*/ | ||
private function getBody(TransportManager $transportManager): array | ||
{ | ||
return [ | ||
'name' => 'Body', | ||
'attributes' => [ | ||
'businessCaseId' => $this->generateGuid(), | ||
'originatingAuthority' => $this->authority, | ||
'requestPurpose' => 'Other', | ||
'requestSource' => 'Other', | ||
], | ||
'nodes' => [ | ||
0 => [ | ||
'name' => 'SearchedTransportManager', | ||
'nodes' => [ | ||
0 => [ | ||
'name' => 'TransportUndertakingAddress', | ||
'attributes' => [ | ||
'address' => 'address', | ||
'postcode' => 'postcode', | ||
'city' => 'city', | ||
'country' => 'UK', | ||
], | ||
], | ||
], | ||
], | ||
], | ||
]; | ||
} | ||
|
||
private function getTransportManagerDetails(TransportManager $transportManager): array | ||
{ | ||
|
||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/api/module/Api/src/Service/Nr/CheckGoodReputeFactory.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,32 @@ | ||
<?php | ||
|
||
namespace Dvsa\Olcs\Api\Service\Nr; | ||
|
||
use Olcs\XmlTools\Xml\XmlNodeBuilder; | ||
use Laminas\ServiceManager\Factory\FactoryInterface; | ||
use Psr\Container\ContainerInterface; | ||
|
||
class CheckGoodReputeFactory implements FactoryInterface | ||
{ | ||
public const XML_NS_MSG = 'No config specified for xml ns'; | ||
public const XML_VERSION_MSG = 'No config specified for erru version'; | ||
public const ROOT_ELEMENT = 'CheckGoodRepute_Request'; | ||
|
||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): CheckGoodRepute | ||
{ | ||
$config = $container->get('config'); | ||
if (!isset($config['nr']['compliance_episode']['xmlNs'])) { | ||
throw new \RuntimeException(self::XML_NS_MSG); | ||
} | ||
|
||
if (!isset($config['nr']['compliance_episode']['erruVersion'])) { | ||
throw new \RuntimeException(self::XML_VERSION_MSG); | ||
} | ||
|
||
$ns = $config['nr']['compliance_episode']['xmlNs']; | ||
$erruVersion = $config['nr']['compliance_episode']['erruVersion']; | ||
|
||
$xmlBuilder = new XmlNodeBuilder(self::ROOT_ELEMENT, $ns . $erruVersion, []); | ||
return new CheckGoodRepute($xmlBuilder, $erruVersion); | ||
} | ||
} |
Oops, something went wrong.