From 2a67ef831a4467ce0000a29efe88af467dc8baeb Mon Sep 17 00:00:00 2001 From: mbe Date: Tue, 7 Nov 2023 13:27:17 +0100 Subject: [PATCH 01/16] #34741 integrate api endpoints for authorization and account api --- src/modules/mo/mo_dhl/Adapter/DHLAdapter.php | 9 + .../Authentication/ApiKeyAuthentication.php | 21 +++ .../BasicAuthAuthentication.php | 24 +++ .../BearerAuthAuthentication.php | 22 +++ .../mo/mo_dhl/Api/Authentication/Client.php | 84 ++++++++++ .../Authentication/Endpoint/DispenseToken.php | 85 ++++++++++ .../Api/Authentication/Endpoint/Get.php | 42 +++++ .../Api/Authentication/Endpoint/Hello.php | 54 ++++++ .../Authentication/Exception/ApiException.php | 7 + .../Exception/BadRequestException.php | 11 ++ .../Exception/ClientException.php | 7 + .../DispenseTokenBadRequestException.php | 21 +++ .../DispenseTokenForbiddenException.php | 21 +++ .../DispenseTokenUnauthorizedException.php | 21 +++ .../Exception/ForbiddenException.php | 11 ++ .../Exception/HelloBadRequestException.php | 21 +++ .../Exception/HelloForbiddenException.php | 21 +++ .../Exception/HelloUnauthorizedException.php | 21 +++ .../Exception/ServerException.php | 7 + .../Exception/UnauthorizedException.php | 11 ++ .../Authentication/Model/GetResponse200.php | 43 +++++ .../Model/GetResponse200Amp.php | 127 ++++++++++++++ .../Authentication/Model/TokenPostBody.php | 155 ++++++++++++++++++ .../Authentication/Model/TokenResponse.php | 99 +++++++++++ .../GetResponse200AmpNormalizer.php | 96 +++++++++++ .../Normalizer/GetResponse200Normalizer.php | 75 +++++++++ .../Normalizer/JaneObjectNormalizer.php | 62 +++++++ .../Normalizer/TokenPostBodyNormalizer.php | 97 +++++++++++ .../Normalizer/TokenResponseNormalizer.php | 89 ++++++++++ .../Runtime/Client/BaseEndpoint.php | 66 ++++++++ .../Authentication/Runtime/Client/Client.php | 82 +++++++++ .../Runtime/Client/CustomQueryResolver.php | 9 + .../Runtime/Client/Endpoint.php | 42 +++++ .../Runtime/Client/EndpointTrait.php | 15 ++ .../Runtime/Normalizer/CheckArray.php | 13 ++ .../Normalizer/ReferenceNormalizer.php | 25 +++ .../Normalizer/ValidationException.php | 19 +++ .../Runtime/Normalizer/ValidatorTrait.php | 16 ++ .../mo/mo_dhl/Api/MyAccount/Client.php | 58 +++++++ .../Endpoint/GetMyAggregatedUserData.php | 70 ++++++++ .../Api/MyAccount/Endpoint/GetVersion.php | 56 +++++++ .../Api/MyAccount/Exception/ApiException.php | 7 + .../Exception/BadRequestException.php | 11 ++ .../MyAccount/Exception/ClientException.php | 7 + ...yAggregatedUserDataBadRequestException.php | 29 ++++ ...ggregatedUserDataUnauthorizedException.php | 20 +++ .../GetVersionUnauthorizedException.php | 20 +++ .../MyAccount/Exception/ServerException.php | 7 + .../Exception/UnauthorizedException.php | 11 ++ .../Model/AggregatedUserDataResponse.php | 71 ++++++++ .../MyAccount/Model/ApiVersionResponse.php | 71 ++++++++ .../MyAccount/Model/ApiVersionResponseAmp.php | 127 ++++++++++++++ .../Model/ApiVersionResponseBackend.php | 71 ++++++++ .../Model/ApiVersionResponseHTML.php | 43 +++++ .../Model/ApiVersionResponseHTMLAmp.php | 127 ++++++++++++++ .../mo/mo_dhl/Api/MyAccount/Model/Detail.php | 127 ++++++++++++++ .../mo/mo_dhl/Api/MyAccount/Model/Product.php | 99 +++++++++++ .../Api/MyAccount/Model/RequestStatus.php | 127 ++++++++++++++ .../mo/mo_dhl/Api/MyAccount/Model/Service.php | 71 ++++++++ .../mo_dhl/Api/MyAccount/Model/Shipping.php | 43 +++++ .../mo/mo_dhl/Api/MyAccount/Model/User.php | 43 +++++ .../AggregatedUserDataResponseNormalizer.php | 80 +++++++++ .../ApiVersionResponseAmpNormalizer.php | 96 +++++++++++ .../ApiVersionResponseBackendNormalizer.php | 82 +++++++++ .../ApiVersionResponseHTMLAmpNormalizer.php | 96 +++++++++++ .../ApiVersionResponseHTMLNormalizer.php | 75 +++++++++ .../ApiVersionResponseNormalizer.php | 82 +++++++++ .../MyAccount/Normalizer/DetailNormalizer.php | 96 +++++++++++ .../Normalizer/JaneObjectNormalizer.php | 62 +++++++ .../Normalizer/ProductNormalizer.php | 97 +++++++++++ .../Normalizer/RequestStatusNormalizer.php | 96 +++++++++++ .../Normalizer/ServiceNormalizer.php | 82 +++++++++ .../Normalizer/ShippingNormalizer.php | 83 ++++++++++ .../MyAccount/Normalizer/UserNormalizer.php | 73 +++++++++ .../MyAccount/Runtime/Client/BaseEndpoint.php | 66 ++++++++ .../Api/MyAccount/Runtime/Client/Client.php | 82 +++++++++ .../Runtime/Client/CustomQueryResolver.php | 9 + .../Api/MyAccount/Runtime/Client/Endpoint.php | 42 +++++ .../Runtime/Client/EndpointTrait.php | 15 ++ .../Runtime/Normalizer/CheckArray.php | 13 ++ .../Normalizer/ReferenceNormalizer.php | 25 +++ .../Normalizer/ValidationException.php | 19 +++ .../Runtime/Normalizer/ValidatorTrait.php | 16 ++ src/modules/mo/mo_dhl/Main.php | 8 + 84 files changed, 4362 insertions(+) create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Authentication/ApiKeyAuthentication.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Authentication/BasicAuthAuthentication.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Authentication/BearerAuthAuthentication.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Client.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Endpoint/DispenseToken.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Endpoint/Get.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Endpoint/Hello.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/ApiException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/BadRequestException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/ClientException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/DispenseTokenBadRequestException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/DispenseTokenForbiddenException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/DispenseTokenUnauthorizedException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/ForbiddenException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/HelloBadRequestException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/HelloForbiddenException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/HelloUnauthorizedException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/ServerException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Exception/UnauthorizedException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Model/GetResponse200.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Model/GetResponse200Amp.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Model/TokenPostBody.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Model/TokenResponse.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Normalizer/GetResponse200AmpNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Normalizer/GetResponse200Normalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Normalizer/JaneObjectNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Normalizer/TokenPostBodyNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Normalizer/TokenResponseNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/BaseEndpoint.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/CustomQueryResolver.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Endpoint.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/EndpointTrait.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/CheckArray.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/ReferenceNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/ValidationException.php create mode 100644 src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/ValidatorTrait.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Client.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetMyAggregatedUserData.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetVersion.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Exception/ApiException.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Exception/BadRequestException.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Exception/ClientException.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Exception/GetMyAggregatedUserDataBadRequestException.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Exception/GetMyAggregatedUserDataUnauthorizedException.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Exception/GetVersionUnauthorizedException.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Exception/ServerException.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Exception/UnauthorizedException.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/AggregatedUserDataResponse.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponse.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseAmp.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseBackend.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseHTML.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseHTMLAmp.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/Detail.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/Product.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/RequestStatus.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/Service.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/Shipping.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Model/User.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/AggregatedUserDataResponseNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseAmpNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseBackendNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseHTMLAmpNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseHTMLNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/DetailNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/JaneObjectNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ProductNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/RequestStatusNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ServiceNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ShippingNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/UserNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/BaseEndpoint.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/CustomQueryResolver.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Endpoint.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/EndpointTrait.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/CheckArray.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/ReferenceNormalizer.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/ValidationException.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/ValidatorTrait.php diff --git a/src/modules/mo/mo_dhl/Adapter/DHLAdapter.php b/src/modules/mo/mo_dhl/Adapter/DHLAdapter.php index 150ffdef..0efc230b 100644 --- a/src/modules/mo/mo_dhl/Adapter/DHLAdapter.php +++ b/src/modules/mo/mo_dhl/Adapter/DHLAdapter.php @@ -218,6 +218,15 @@ public function buildParcelShipping() return $this->getSdk()->buildParcelShipping(); } + + /** + * @return \Mediaopt\DHL\Api\Authentication\Client + */ + public function buildAuthentication() + { + return $this->getSdk()->buildAuthentication(); + } + /** * @return \Mediaopt\DHL\Api\Retoure */ diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Authentication/ApiKeyAuthentication.php b/src/modules/mo/mo_dhl/Api/Authentication/Authentication/ApiKeyAuthentication.php new file mode 100644 index 00000000..efd8943b --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Authentication/ApiKeyAuthentication.php @@ -0,0 +1,21 @@ +{'apiKey'} = $apiKey; + } + public function authentication(\Psr\Http\Message\RequestInterface $request) : \Psr\Http\Message\RequestInterface + { + $request = $request->withHeader('dhl-api-key', $this->{'apiKey'}); + return $request; + } + public function getScope() : string + { + return 'apiKey'; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Authentication/BasicAuthAuthentication.php b/src/modules/mo/mo_dhl/Api/Authentication/Authentication/BasicAuthAuthentication.php new file mode 100644 index 00000000..774678b6 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Authentication/BasicAuthAuthentication.php @@ -0,0 +1,24 @@ +{'username'} = $username; + $this->{'password'} = $password; + } + public function authentication(\Psr\Http\Message\RequestInterface $request) : \Psr\Http\Message\RequestInterface + { + $header = sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->{'username'}, $this->{'password'}))); + $request = $request->withHeader('Authorization', $header); + return $request; + } + public function getScope() : string + { + return 'basicAuth'; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Authentication/BearerAuthAuthentication.php b/src/modules/mo/mo_dhl/Api/Authentication/Authentication/BearerAuthAuthentication.php new file mode 100644 index 00000000..160db98c --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Authentication/BearerAuthAuthentication.php @@ -0,0 +1,22 @@ +{'token'} = $token; + } + public function authentication(\Psr\Http\Message\RequestInterface $request) : \Psr\Http\Message\RequestInterface + { + $header = sprintf('Bearer %s', $this->{'token'}); + $request = $request->withHeader('Authorization', $header); + return $request; + } + public function getScope() : string + { + return 'bearerAuth'; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Client.php b/src/modules/mo/mo_dhl/Api/Authentication/Client.php new file mode 100644 index 00000000..d035a88e --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Client.php @@ -0,0 +1,84 @@ +executeEndpoint(new \Mediaopt\DHL\Api\Authentication\Endpoint\Get(), $fetch); + } + /** + * The client makes a request to the token endpoint by adding the following parameters + using the application/x-www-form-urlencoded format with a character + encoding of UTF-8 in the HTTP request entity-body: + + * grant_type __REQUIRED__. Must be set to "password" or "refresh_token". + + * client_id __REQUIRED__ (aka client_id (api key)) + + * client_secret __REQUIRED__ (aka client_secret) + + Depending on the grant_type, __additional parameters__ must be provided: + +

grant_type=password

+ + This currently is the only grant type supported. + + * username __REQUIRED__. The resource owner username. Aka username for business customer portal + + * password __REQUIRED__. The resource owner password. Aka password for business customer portal + + * + * @param \Mediaopt\DHL\Api\Authentication\Model\TokenPostBody $requestBody + * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) + * @throws \Mediaopt\DHL\Api\Authentication\Exception\DispenseTokenBadRequestException + * @throws \Mediaopt\DHL\Api\Authentication\Exception\DispenseTokenUnauthorizedException + * @throws \Mediaopt\DHL\Api\Authentication\Exception\DispenseTokenForbiddenException + * + * @return null|\Mediaopt\DHL\Api\Authentication\Model\TokenResponse|\Psr\Http\Message\ResponseInterface + */ + public function dispenseToken(\Mediaopt\DHL\Api\Authentication\Model\TokenPostBody $requestBody, string $fetch = self::FETCH_OBJECT) + { + return $this->executeEndpoint(new \Mediaopt\DHL\Api\Authentication\Endpoint\DispenseToken($requestBody), $fetch); + } + /** + * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) + * @throws \Mediaopt\DHL\Api\Authentication\Exception\HelloBadRequestException + * @throws \Mediaopt\DHL\Api\Authentication\Exception\HelloUnauthorizedException + * @throws \Mediaopt\DHL\Api\Authentication\Exception\HelloForbiddenException + * + * @return null|\Mediaopt\DHL\Api\Authentication\Model\TokenResponse|\Psr\Http\Message\ResponseInterface + */ + public function hello(string $fetch = self::FETCH_OBJECT) + { + return $this->executeEndpoint(new \Mediaopt\DHL\Api\Authentication\Endpoint\Hello(), $fetch); + } + public static function create($httpClient = null, array $additionalPlugins = array(), array $additionalNormalizers = array()) + { + if (null === $httpClient) { + $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); + $plugins = array(); + $uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri('https://api-eu.dhl.com/parcel/de/account/auth/ropc/v1'); + $plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri); + $plugins[] = new \Http\Client\Common\Plugin\AddPathPlugin($uri); + if (count($additionalPlugins) > 0) { + $plugins = array_merge($plugins, $additionalPlugins); + } + $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins); + } + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $streamFactory = \Http\Discovery\Psr17FactoryDiscovery::findStreamFactory(); + $normalizers = array(new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(), new \Mediaopt\DHL\Api\Authentication\Normalizer\JaneObjectNormalizer()); + if (count($additionalNormalizers) > 0) { + $normalizers = array_merge($normalizers, $additionalNormalizers); + } + $serializer = new \Symfony\Component\Serializer\Serializer($normalizers, array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode(array('json_decode_associative' => true))))); + return new static($httpClient, $requestFactory, $serializer, $streamFactory); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Endpoint/DispenseToken.php b/src/modules/mo/mo_dhl/Api/Authentication/Endpoint/DispenseToken.php new file mode 100644 index 00000000..86f41882 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Endpoint/DispenseToken.php @@ -0,0 +1,85 @@ +grant_type=password + + This currently is the only grant type supported. + + * username __REQUIRED__. The resource owner username. Aka username for business customer portal + + * password __REQUIRED__. The resource owner password. Aka password for business customer portal + + * + * @param \Mediaopt\DHL\Api\Authentication\Model\TokenPostBody $requestBody + */ + public function __construct(\Mediaopt\DHL\Api\Authentication\Model\TokenPostBody $requestBody) + { + $this->body = $requestBody; + } + use \Mediaopt\DHL\Api\Authentication\Runtime\Client\EndpointTrait; + public function getMethod() : string + { + return 'POST'; + } + public function getUri() : string + { + return '/token'; + } + public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array + { + if ($this->body instanceof \Mediaopt\DHL\Api\Authentication\Model\TokenPostBody) { + return array(array('Content-Type' => array('application/x-www-form-urlencoded')), http_build_query($serializer->normalize($this->body, 'json'))); + } + return array(array(), null); + } + public function getExtraHeaders() : array + { + return array('Accept' => array('application/json')); + } + /** + * {@inheritdoc} + * + * @throws \Mediaopt\DHL\Api\Authentication\Exception\DispenseTokenBadRequestException + * @throws \Mediaopt\DHL\Api\Authentication\Exception\DispenseTokenUnauthorizedException + * @throws \Mediaopt\DHL\Api\Authentication\Exception\DispenseTokenForbiddenException + * + * @return null|\Mediaopt\DHL\Api\Authentication\Model\TokenResponse + */ + protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) + { + $status = $response->getStatusCode(); + $body = (string) $response->getBody(); + if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { + return $serializer->deserialize($body, 'Mediaopt\\DHL\\Api\\Authentication\\Model\\TokenResponse', 'json'); + } + if (400 === $status) { + throw new \Mediaopt\DHL\Api\Authentication\Exception\DispenseTokenBadRequestException($response); + } + if (401 === $status) { + throw new \Mediaopt\DHL\Api\Authentication\Exception\DispenseTokenUnauthorizedException($response); + } + if (403 === $status) { + throw new \Mediaopt\DHL\Api\Authentication\Exception\DispenseTokenForbiddenException($response); + } + } + public function getAuthenticationScopes() : array + { + return array('bearerAuth', 'basicAuth', 'apiKey'); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Endpoint/Get.php b/src/modules/mo/mo_dhl/Api/Authentication/Endpoint/Get.php new file mode 100644 index 00000000..a00f648d --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Endpoint/Get.php @@ -0,0 +1,42 @@ + array('application/json')); + } + /** + * {@inheritdoc} + * + * + * @return null|\Mediaopt\DHL\Api\Authentication\Model\GetResponse200 + */ + protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) + { + $status = $response->getStatusCode(); + $body = (string) $response->getBody(); + if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { + return $serializer->deserialize($body, 'Mediaopt\\DHL\\Api\\Authentication\\Model\\GetResponse200', 'json'); + } + } + public function getAuthenticationScopes() : array + { + return array('bearerAuth', 'basicAuth', 'apiKey'); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Endpoint/Hello.php b/src/modules/mo/mo_dhl/Api/Authentication/Endpoint/Hello.php new file mode 100644 index 00000000..7415e535 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Endpoint/Hello.php @@ -0,0 +1,54 @@ + array('application/json')); + } + /** + * {@inheritdoc} + * + * @throws \Mediaopt\DHL\Api\Authentication\Exception\HelloBadRequestException + * @throws \Mediaopt\DHL\Api\Authentication\Exception\HelloUnauthorizedException + * @throws \Mediaopt\DHL\Api\Authentication\Exception\HelloForbiddenException + * + * @return null|\Mediaopt\DHL\Api\Authentication\Model\TokenResponse + */ + protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) + { + $status = $response->getStatusCode(); + $body = (string) $response->getBody(); + if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { + return $serializer->deserialize($body, 'Mediaopt\\DHL\\Api\\Authentication\\Model\\TokenResponse', 'json'); + } + if (400 === $status) { + throw new \Mediaopt\DHL\Api\Authentication\Exception\HelloBadRequestException($response); + } + if (401 === $status) { + throw new \Mediaopt\DHL\Api\Authentication\Exception\HelloUnauthorizedException($response); + } + if (403 === $status) { + throw new \Mediaopt\DHL\Api\Authentication\Exception\HelloForbiddenException($response); + } + } + public function getAuthenticationScopes() : array + { + return array('bearerAuth', 'basicAuth', 'apiKey'); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Exception/ApiException.php b/src/modules/mo/mo_dhl/Api/Authentication/Exception/ApiException.php new file mode 100644 index 00000000..2fd8c8b9 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Exception/ApiException.php @@ -0,0 +1,7 @@ +response = $response; + } + public function getResponse() : ?\Psr\Http\Message\ResponseInterface + { + return $this->response; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Exception/DispenseTokenForbiddenException.php b/src/modules/mo/mo_dhl/Api/Authentication/Exception/DispenseTokenForbiddenException.php new file mode 100644 index 00000000..71313223 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Exception/DispenseTokenForbiddenException.php @@ -0,0 +1,21 @@ +response = $response; + } + public function getResponse() : ?\Psr\Http\Message\ResponseInterface + { + return $this->response; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Exception/DispenseTokenUnauthorizedException.php b/src/modules/mo/mo_dhl/Api/Authentication/Exception/DispenseTokenUnauthorizedException.php new file mode 100644 index 00000000..2a1d214e --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Exception/DispenseTokenUnauthorizedException.php @@ -0,0 +1,21 @@ +response = $response; + } + public function getResponse() : ?\Psr\Http\Message\ResponseInterface + { + return $this->response; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Exception/ForbiddenException.php b/src/modules/mo/mo_dhl/Api/Authentication/Exception/ForbiddenException.php new file mode 100644 index 00000000..ca9f9bf3 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Exception/ForbiddenException.php @@ -0,0 +1,11 @@ +response = $response; + } + public function getResponse() : ?\Psr\Http\Message\ResponseInterface + { + return $this->response; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Exception/HelloForbiddenException.php b/src/modules/mo/mo_dhl/Api/Authentication/Exception/HelloForbiddenException.php new file mode 100644 index 00000000..6052fe35 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Exception/HelloForbiddenException.php @@ -0,0 +1,21 @@ +response = $response; + } + public function getResponse() : ?\Psr\Http\Message\ResponseInterface + { + return $this->response; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Exception/HelloUnauthorizedException.php b/src/modules/mo/mo_dhl/Api/Authentication/Exception/HelloUnauthorizedException.php new file mode 100644 index 00000000..bdadc153 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Exception/HelloUnauthorizedException.php @@ -0,0 +1,21 @@ +response = $response; + } + public function getResponse() : ?\Psr\Http\Message\ResponseInterface + { + return $this->response; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Exception/ServerException.php b/src/modules/mo/mo_dhl/Api/Authentication/Exception/ServerException.php new file mode 100644 index 00000000..a70cb121 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Exception/ServerException.php @@ -0,0 +1,7 @@ +initialized); + } + /** + * + * + * @var GetResponse200Amp + */ + protected $amp; + /** + * + * + * @return GetResponse200Amp + */ + public function getAmp() : GetResponse200Amp + { + return $this->amp; + } + /** + * + * + * @param GetResponse200Amp $amp + * + * @return self + */ + public function setAmp(GetResponse200Amp $amp) : self + { + $this->initialized['amp'] = true; + $this->amp = $amp; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Model/GetResponse200Amp.php b/src/modules/mo/mo_dhl/Api/Authentication/Model/GetResponse200Amp.php new file mode 100644 index 00000000..6d49ec7c --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Model/GetResponse200Amp.php @@ -0,0 +1,127 @@ +initialized); + } + /** + * + * + * @var string + */ + protected $name; + /** + * Sandbox version is >= Prod version + * + * @var string + */ + protected $version; + /** + * + * + * @var string + */ + protected $rev; + /** + * + * + * @var string + */ + protected $env; + /** + * + * + * @return string + */ + public function getName() : string + { + return $this->name; + } + /** + * + * + * @param string $name + * + * @return self + */ + public function setName(string $name) : self + { + $this->initialized['name'] = true; + $this->name = $name; + return $this; + } + /** + * Sandbox version is >= Prod version + * + * @return string + */ + public function getVersion() : string + { + return $this->version; + } + /** + * Sandbox version is >= Prod version + * + * @param string $version + * + * @return self + */ + public function setVersion(string $version) : self + { + $this->initialized['version'] = true; + $this->version = $version; + return $this; + } + /** + * + * + * @return string + */ + public function getRev() : string + { + return $this->rev; + } + /** + * + * + * @param string $rev + * + * @return self + */ + public function setRev(string $rev) : self + { + $this->initialized['rev'] = true; + $this->rev = $rev; + return $this; + } + /** + * + * + * @return string + */ + public function getEnv() : string + { + return $this->env; + } + /** + * + * + * @param string $env + * + * @return self + */ + public function setEnv(string $env) : self + { + $this->initialized['env'] = true; + $this->env = $env; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Model/TokenPostBody.php b/src/modules/mo/mo_dhl/Api/Authentication/Model/TokenPostBody.php new file mode 100644 index 00000000..e5ccf6e7 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Model/TokenPostBody.php @@ -0,0 +1,155 @@ +initialized); + } + /** + * + * + * @var string + */ + protected $grantType; + /** + * GKP user name. Required for grant_type=password. + * + * @var string + */ + protected $username; + /** + * GKP password. Required for grant_type=password. + * + * @var string + */ + protected $password; + /** + * + * + * @var string + */ + protected $clientId; + /** + * + * + * @var string + */ + protected $clientSecret; + /** + * + * + * @return string + */ + public function getGrantType() : string + { + return $this->grantType; + } + /** + * + * + * @param string $grantType + * + * @return self + */ + public function setGrantType(string $grantType) : self + { + $this->initialized['grantType'] = true; + $this->grantType = $grantType; + return $this; + } + /** + * GKP user name. Required for grant_type=password. + * + * @return string + */ + public function getUsername() : string + { + return $this->username; + } + /** + * GKP user name. Required for grant_type=password. + * + * @param string $username + * + * @return self + */ + public function setUsername(string $username) : self + { + $this->initialized['username'] = true; + $this->username = $username; + return $this; + } + /** + * GKP password. Required for grant_type=password. + * + * @return string + */ + public function getPassword() : string + { + return $this->password; + } + /** + * GKP password. Required for grant_type=password. + * + * @param string $password + * + * @return self + */ + public function setPassword(string $password) : self + { + $this->initialized['password'] = true; + $this->password = $password; + return $this; + } + /** + * + * + * @return string + */ + public function getClientId() : string + { + return $this->clientId; + } + /** + * + * + * @param string $clientId + * + * @return self + */ + public function setClientId(string $clientId) : self + { + $this->initialized['clientId'] = true; + $this->clientId = $clientId; + return $this; + } + /** + * + * + * @return string + */ + public function getClientSecret() : string + { + return $this->clientSecret; + } + /** + * + * + * @param string $clientSecret + * + * @return self + */ + public function setClientSecret(string $clientSecret) : self + { + $this->initialized['clientSecret'] = true; + $this->clientSecret = $clientSecret; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Model/TokenResponse.php b/src/modules/mo/mo_dhl/Api/Authentication/Model/TokenResponse.php new file mode 100644 index 00000000..57579ba7 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Model/TokenResponse.php @@ -0,0 +1,99 @@ +initialized); + } + /** + * + * + * @var string + */ + protected $accessToken; + /** + * Will be set to 'Bearer' + * + * @var string + */ + protected $tokenType; + /** + * Seconds + * + * @var int + */ + protected $expiresIn; + /** + * + * + * @return string + */ + public function getAccessToken() : string + { + return $this->accessToken; + } + /** + * + * + * @param string $accessToken + * + * @return self + */ + public function setAccessToken(string $accessToken) : self + { + $this->initialized['accessToken'] = true; + $this->accessToken = $accessToken; + return $this; + } + /** + * Will be set to 'Bearer' + * + * @return string + */ + public function getTokenType() : string + { + return $this->tokenType; + } + /** + * Will be set to 'Bearer' + * + * @param string $tokenType + * + * @return self + */ + public function setTokenType(string $tokenType) : self + { + $this->initialized['tokenType'] = true; + $this->tokenType = $tokenType; + return $this; + } + /** + * Seconds + * + * @return int + */ + public function getExpiresIn() : int + { + return $this->expiresIn; + } + /** + * Seconds + * + * @param int $expiresIn + * + * @return self + */ + public function setExpiresIn(int $expiresIn) : self + { + $this->initialized['expiresIn'] = true; + $this->expiresIn = $expiresIn; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/GetResponse200AmpNormalizer.php b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/GetResponse200AmpNormalizer.php new file mode 100644 index 00000000..54b7afd5 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/GetResponse200AmpNormalizer.php @@ -0,0 +1,96 @@ +setName($data['name']); + unset($data['name']); + } + if (\array_key_exists('version', $data)) { + $object->setVersion($data['version']); + unset($data['version']); + } + if (\array_key_exists('rev', $data)) { + $object->setRev($data['rev']); + unset($data['rev']); + } + if (\array_key_exists('env', $data)) { + $object->setEnv($data['env']); + unset($data['env']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('name') && null !== $object->getName()) { + $data['name'] = $object->getName(); + } + if ($object->isInitialized('version') && null !== $object->getVersion()) { + $data['version'] = $object->getVersion(); + } + if ($object->isInitialized('rev') && null !== $object->getRev()) { + $data['rev'] = $object->getRev(); + } + if ($object->isInitialized('env') && null !== $object->getEnv()) { + $data['env'] = $object->getEnv(); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\Authentication\\Model\\GetResponse200Amp' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/GetResponse200Normalizer.php b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/GetResponse200Normalizer.php new file mode 100644 index 00000000..852e2771 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/GetResponse200Normalizer.php @@ -0,0 +1,75 @@ +setAmp($this->denormalizer->denormalize($data['amp'], 'Mediaopt\\DHL\\Api\\Authentication\\Model\\GetResponse200Amp', 'json', $context)); + unset($data['amp']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('amp') && null !== $object->getAmp()) { + $data['amp'] = $this->normalizer->normalize($object->getAmp(), 'json', $context); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\Authentication\\Model\\GetResponse200' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/JaneObjectNormalizer.php b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/JaneObjectNormalizer.php new file mode 100644 index 00000000..e021810c --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/JaneObjectNormalizer.php @@ -0,0 +1,62 @@ + 'Mediaopt\\DHL\\Api\\Authentication\\Normalizer\\TokenResponseNormalizer', 'Mediaopt\\DHL\\Api\\Authentication\\Model\\GetResponse200' => 'Mediaopt\\DHL\\Api\\Authentication\\Normalizer\\GetResponse200Normalizer', 'Mediaopt\\DHL\\Api\\Authentication\\Model\\GetResponse200Amp' => 'Mediaopt\\DHL\\Api\\Authentication\\Normalizer\\GetResponse200AmpNormalizer', 'Mediaopt\\DHL\\Api\\Authentication\\Model\\TokenPostBody' => 'Mediaopt\\DHL\\Api\\Authentication\\Normalizer\\TokenPostBodyNormalizer', '\\Jane\\Component\\JsonSchemaRuntime\\Reference' => '\\Mediaopt\\DHL\\Api\\Authentication\\Runtime\\Normalizer\\ReferenceNormalizer'), $normalizersCache = array(); + public function supportsDenormalization($data, $type, $format = null, array $context = array()) : bool + { + return array_key_exists($type, $this->normalizers); + } + public function supportsNormalization($data, $format = null, array $context = array()) : bool + { + return is_object($data) && array_key_exists(get_class($data), $this->normalizers); + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $normalizerClass = $this->normalizers[get_class($object)]; + $normalizer = $this->getNormalizer($normalizerClass); + return $normalizer->normalize($object, $format, $context); + } + /** + * @return mixed + */ + public function denormalize($data, $class, $format = null, array $context = array()) + { + $denormalizerClass = $this->normalizers[$class]; + $denormalizer = $this->getNormalizer($denormalizerClass); + return $denormalizer->denormalize($data, $class, $format, $context); + } + private function getNormalizer(string $normalizerClass) + { + return $this->normalizersCache[$normalizerClass] ?? $this->initNormalizer($normalizerClass); + } + private function initNormalizer(string $normalizerClass) + { + $normalizer = new $normalizerClass(); + $normalizer->setNormalizer($this->normalizer); + $normalizer->setDenormalizer($this->denormalizer); + $this->normalizersCache[$normalizerClass] = $normalizer; + return $normalizer; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\Authentication\\Model\\TokenResponse' => false, 'Mediaopt\\DHL\\Api\\Authentication\\Model\\GetResponse200' => false, 'Mediaopt\\DHL\\Api\\Authentication\\Model\\GetResponse200Amp' => false, 'Mediaopt\\DHL\\Api\\Authentication\\Model\\TokenPostBody' => false, '\\Jane\\Component\\JsonSchemaRuntime\\Reference' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/TokenPostBodyNormalizer.php b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/TokenPostBodyNormalizer.php new file mode 100644 index 00000000..aeeb514d --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/TokenPostBodyNormalizer.php @@ -0,0 +1,97 @@ +setGrantType($data['grant_type']); + unset($data['grant_type']); + } + if (\array_key_exists('username', $data)) { + $object->setUsername($data['username']); + unset($data['username']); + } + if (\array_key_exists('password', $data)) { + $object->setPassword($data['password']); + unset($data['password']); + } + if (\array_key_exists('client_id', $data)) { + $object->setClientId($data['client_id']); + unset($data['client_id']); + } + if (\array_key_exists('client_secret', $data)) { + $object->setClientSecret($data['client_secret']); + unset($data['client_secret']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + $data['grant_type'] = $object->getGrantType(); + if ($object->isInitialized('username') && null !== $object->getUsername()) { + $data['username'] = $object->getUsername(); + } + if ($object->isInitialized('password') && null !== $object->getPassword()) { + $data['password'] = $object->getPassword(); + } + $data['client_id'] = $object->getClientId(); + $data['client_secret'] = $object->getClientSecret(); + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\Authentication\\Model\\TokenPostBody' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/TokenResponseNormalizer.php b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/TokenResponseNormalizer.php new file mode 100644 index 00000000..3ff1f7d5 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Normalizer/TokenResponseNormalizer.php @@ -0,0 +1,89 @@ +setAccessToken($data['access_token']); + unset($data['access_token']); + } + if (\array_key_exists('token_type', $data)) { + $object->setTokenType($data['token_type']); + unset($data['token_type']); + } + if (\array_key_exists('expires_in', $data)) { + $object->setExpiresIn($data['expires_in']); + unset($data['expires_in']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('accessToken') && null !== $object->getAccessToken()) { + $data['access_token'] = $object->getAccessToken(); + } + if ($object->isInitialized('tokenType') && null !== $object->getTokenType()) { + $data['token_type'] = $object->getTokenType(); + } + if ($object->isInitialized('expiresIn') && null !== $object->getExpiresIn()) { + $data['expires_in'] = $object->getExpiresIn(); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\Authentication\\Model\\TokenResponse' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/BaseEndpoint.php b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/BaseEndpoint.php new file mode 100644 index 00000000..87e962b8 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/BaseEndpoint.php @@ -0,0 +1,66 @@ +getQueryOptionsResolver()->resolve($this->queryParameters); + $optionsResolved = array_map(function ($value) { + return null !== $value ? $value : ''; + }, $optionsResolved); + return http_build_query($optionsResolved, '', '&', PHP_QUERY_RFC3986); + } + public function getHeaders(array $baseHeaders = []) : array + { + return array_merge($this->getExtraHeaders(), $baseHeaders, $this->getHeadersOptionsResolver()->resolve($this->headerParameters)); + } + protected function getQueryOptionsResolver() : OptionsResolver + { + return new OptionsResolver(); + } + protected function getHeadersOptionsResolver() : OptionsResolver + { + return new OptionsResolver(); + } + // ---------------------------------------------------------------------------------------------------- + // Used for OpenApi2 compatibility + protected function getFormBody() : array + { + return [['Content-Type' => ['application/x-www-form-urlencoded']], http_build_query($this->getFormOptionsResolver()->resolve($this->formParameters))]; + } + protected function getMultipartBody($streamFactory = null) : array + { + $bodyBuilder = new MultipartStreamBuilder($streamFactory); + $formParameters = $this->getFormOptionsResolver()->resolve($this->formParameters); + foreach ($formParameters as $key => $value) { + $bodyBuilder->addResource($key, $value); + } + return [['Content-Type' => ['multipart/form-data; boundary="' . ($bodyBuilder->getBoundary() . '"')]], $bodyBuilder->build()]; + } + protected function getFormOptionsResolver() : OptionsResolver + { + return new OptionsResolver(); + } + protected function getSerializedBody(SerializerInterface $serializer) : array + { + return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')]; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php new file mode 100644 index 00000000..d4204e9f --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php @@ -0,0 +1,82 @@ +httpClient = $httpClient; + $this->requestFactory = $requestFactory; + $this->serializer = $serializer; + $this->streamFactory = $streamFactory; + } + public function executeEndpoint(Endpoint $endpoint, string $fetch = self::FETCH_OBJECT) + { + if (self::FETCH_RESPONSE === $fetch) { + trigger_deprecation('jane-php/open-api-common', '7.3', 'Using %s::%s method with $fetch parameter equals to response is deprecated, use %s::%s instead.', __CLASS__, __METHOD__, __CLASS__, 'executeRawEndpoint'); + return $this->executeRawEndpoint($endpoint); + } + return $endpoint->parseResponse($this->processEndpoint($endpoint), $this->serializer, $fetch); + } + public function executeRawEndpoint(Endpoint $endpoint) : ResponseInterface + { + return $this->processEndpoint($endpoint); + } + private function processEndpoint(Endpoint $endpoint) : ResponseInterface + { + [$bodyHeaders, $body] = $endpoint->getBody($this->serializer, $this->streamFactory); + $queryString = $endpoint->getQueryString(); + $uriGlue = false === strpos($endpoint->getUri(), '?') ? '?' : '&'; + $uri = $queryString !== '' ? $endpoint->getUri() . $uriGlue . $queryString : $endpoint->getUri(); + $request = $this->requestFactory->createRequest($endpoint->getMethod(), $uri); + if ($body) { + if ($body instanceof StreamInterface) { + $request = $request->withBody($body); + } elseif (is_resource($body)) { + $request = $request->withBody($this->streamFactory->createStreamFromResource($body)); + } elseif (strlen($body) <= 4000 && @file_exists($body)) { + // more than 4096 chars will trigger an error + $request = $request->withBody($this->streamFactory->createStreamFromFile($body)); + } else { + $request = $request->withBody($this->streamFactory->createStream($body)); + } + } + foreach ($endpoint->getHeaders($bodyHeaders) as $name => $value) { + $request = $request->withHeader($name, $value); + } + if (count($endpoint->getAuthenticationScopes()) > 0) { + $scopes = []; + foreach ($endpoint->getAuthenticationScopes() as $scope) { + $scopes[] = $scope; + } + $request = $request->withHeader(AuthenticationRegistry::SCOPES_HEADER, $scopes); + } + return $this->httpClient->sendRequest($request); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/CustomQueryResolver.php b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/CustomQueryResolver.php new file mode 100644 index 00000000..c51a5012 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/CustomQueryResolver.php @@ -0,0 +1,9 @@ +hasHeader('Content-Type') ? current($response->getHeader('Content-Type')) : null; + return $this->transformResponseBody($response, $serializer, $contentType); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/CheckArray.php b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/CheckArray.php new file mode 100644 index 00000000..2886e6c5 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/CheckArray.php @@ -0,0 +1,13 @@ +getReferenceUri(); + return $ref; + } + /** + * {@inheritdoc} + */ + public function supportsNormalization($data, $format = null) : bool + { + return $data instanceof Reference; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/ValidationException.php b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/ValidationException.php new file mode 100644 index 00000000..42ecf4e5 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/ValidationException.php @@ -0,0 +1,19 @@ +violationList = $violationList; + parent::__construct(sprintf('Model validation failed with %d errors.', $violationList->count()), 400); + } + public function getViolationList() : ConstraintViolationListInterface + { + return $this->violationList; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/ValidatorTrait.php b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/ValidatorTrait.php new file mode 100644 index 00000000..7f5ec114 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Normalizer/ValidatorTrait.php @@ -0,0 +1,16 @@ +validate($data, $constraint); + if ($violations->count() > 0) { + throw new ValidationException($violations); + } + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Client.php b/src/modules/mo/mo_dhl/Api/MyAccount/Client.php new file mode 100644 index 00000000..29c22789 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Client.php @@ -0,0 +1,58 @@ +executeEndpoint(new \Mediaopt\DHL\Api\MyAccount\Endpoint\GetVersion($accept), $fetch); + } + /** + * + * + * @param array $queryParameters { + * @var string $lang language for localized texts + * } + * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE) + * @throws \Mediaopt\DHL\Api\MyAccount\Exception\GetMyAggregatedUserDataBadRequestException + * @throws \Mediaopt\DHL\Api\MyAccount\Exception\GetMyAggregatedUserDataUnauthorizedException + * + * @return null|\Mediaopt\DHL\Api\MyAccount\Model\AggregatedUserDataResponse|\Psr\Http\Message\ResponseInterface + */ + public function getMyAggregatedUserData(array $queryParameters = array(), string $fetch = self::FETCH_OBJECT) + { + return $this->executeEndpoint(new \Mediaopt\DHL\Api\MyAccount\Endpoint\GetMyAggregatedUserData($queryParameters), $fetch); + } + public static function create($httpClient = null, array $additionalPlugins = array(), array $additionalNormalizers = array()) + { + if (null === $httpClient) { + $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); + $plugins = array(); + $uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri('https://api-eu.dhl.com/parcel/de/account/myaccount/v1'); + $plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri); + $plugins[] = new \Http\Client\Common\Plugin\AddPathPlugin($uri); + if (count($additionalPlugins) > 0) { + $plugins = array_merge($plugins, $additionalPlugins); + } + $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins); + } + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $streamFactory = \Http\Discovery\Psr17FactoryDiscovery::findStreamFactory(); + $normalizers = array(new \Symfony\Component\Serializer\Normalizer\ArrayDenormalizer(), new \Mediaopt\DHL\Api\MyAccount\Normalizer\JaneObjectNormalizer()); + if (count($additionalNormalizers) > 0) { + $normalizers = array_merge($normalizers, $additionalNormalizers); + } + $serializer = new \Symfony\Component\Serializer\Serializer($normalizers, array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(new \Symfony\Component\Serializer\Encoder\JsonEncode(), new \Symfony\Component\Serializer\Encoder\JsonDecode(array('json_decode_associative' => true))))); + return new static($httpClient, $requestFactory, $serializer, $streamFactory); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetMyAggregatedUserData.php b/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetMyAggregatedUserData.php new file mode 100644 index 00000000..aadae3a1 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetMyAggregatedUserData.php @@ -0,0 +1,70 @@ +queryParameters = $queryParameters; + } + use \Mediaopt\DHL\Api\MyAccount\Runtime\Client\EndpointTrait; + public function getMethod() : string + { + return 'GET'; + } + public function getUri() : string + { + return '/user'; + } + public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array + { + return array(array(), null); + } + public function getExtraHeaders() : array + { + return array('Accept' => array('application/json')); + } + protected function getQueryOptionsResolver() : \Symfony\Component\OptionsResolver\OptionsResolver + { + $optionsResolver = parent::getQueryOptionsResolver(); + $optionsResolver->setDefined(array('lang')); + $optionsResolver->setRequired(array('lang')); + $optionsResolver->setDefaults(array()); + $optionsResolver->addAllowedTypes('lang', array('string')); + return $optionsResolver; + } + /** + * {@inheritdoc} + * + * @throws \Mediaopt\DHL\Api\MyAccount\Exception\GetMyAggregatedUserDataBadRequestException + * @throws \Mediaopt\DHL\Api\MyAccount\Exception\GetMyAggregatedUserDataUnauthorizedException + * + * @return null|\Mediaopt\DHL\Api\MyAccount\Model\AggregatedUserDataResponse + */ + protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) + { + $status = $response->getStatusCode(); + $body = (string) $response->getBody(); + if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { + return $serializer->deserialize($body, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\AggregatedUserDataResponse', 'json'); + } + if (is_null($contentType) === false && (400 === $status && mb_strpos($contentType, 'application/json') !== false)) { + throw new \Mediaopt\DHL\Api\MyAccount\Exception\GetMyAggregatedUserDataBadRequestException($serializer->deserialize($body, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\RequestStatus', 'json'), $response); + } + if (401 === $status) { + throw new \Mediaopt\DHL\Api\MyAccount\Exception\GetMyAggregatedUserDataUnauthorizedException($response); + } + } + public function getAuthenticationScopes() : array + { + return array('security_auth'); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetVersion.php b/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetVersion.php new file mode 100644 index 00000000..3509b802 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetVersion.php @@ -0,0 +1,56 @@ +accept = $accept; + } + use \Mediaopt\DHL\Api\MyAccount\Runtime\Client\EndpointTrait; + public function getMethod() : string + { + return 'GET'; + } + public function getUri() : string + { + return '/'; + } + public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = null) : array + { + return array(array(), null); + } + public function getExtraHeaders() : array + { + return array('Accept' => array('application/json')); + } + /** + * {@inheritdoc} + * + * @throws \Mediaopt\DHL\Api\MyAccount\Exception\GetVersionUnauthorizedException + * + * @return null|\Mediaopt\DHL\Api\MyAccount\Model\ApiVersionResponse + */ + protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $response, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) + { + $status = $response->getStatusCode(); + $body = (string) $response->getBody(); + if (is_null($contentType) === false && (200 === $status && mb_strpos($contentType, 'application/json') !== false)) { + return $serializer->deserialize($body, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponse', 'json'); + } + if (401 === $status) { + throw new \Mediaopt\DHL\Api\MyAccount\Exception\GetVersionUnauthorizedException($response); + } + } + public function getAuthenticationScopes() : array + { + return array('security_auth'); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Exception/ApiException.php b/src/modules/mo/mo_dhl/Api/MyAccount/Exception/ApiException.php new file mode 100644 index 00000000..f62ab31f --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Exception/ApiException.php @@ -0,0 +1,7 @@ +requestStatus = $requestStatus; + $this->response = $response; + } + public function getRequestStatus() : \Mediaopt\DHL\Api\MyAccount\Model\RequestStatus + { + return $this->requestStatus; + } + public function getResponse() : \Psr\Http\Message\ResponseInterface + { + return $this->response; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Exception/GetMyAggregatedUserDataUnauthorizedException.php b/src/modules/mo/mo_dhl/Api/MyAccount/Exception/GetMyAggregatedUserDataUnauthorizedException.php new file mode 100644 index 00000000..69460668 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Exception/GetMyAggregatedUserDataUnauthorizedException.php @@ -0,0 +1,20 @@ +response = $response; + } + public function getResponse() : ?\Psr\Http\Message\ResponseInterface + { + return $this->response; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Exception/GetVersionUnauthorizedException.php b/src/modules/mo/mo_dhl/Api/MyAccount/Exception/GetVersionUnauthorizedException.php new file mode 100644 index 00000000..cf78c5f6 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Exception/GetVersionUnauthorizedException.php @@ -0,0 +1,20 @@ +response = $response; + } + public function getResponse() : ?\Psr\Http\Message\ResponseInterface + { + return $this->response; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Exception/ServerException.php b/src/modules/mo/mo_dhl/Api/MyAccount/Exception/ServerException.php new file mode 100644 index 00000000..67f86924 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Exception/ServerException.php @@ -0,0 +1,7 @@ +initialized); + } + /** + * The use profile data + * + * @var User + */ + protected $user; + /** + * The customer's ship customer config, if user has ship role + * + * @var Shipping + */ + protected $shippingRights; + /** + * The use profile data + * + * @return User + */ + public function getUser() : User + { + return $this->user; + } + /** + * The use profile data + * + * @param User $user + * + * @return self + */ + public function setUser(User $user) : self + { + $this->initialized['user'] = true; + $this->user = $user; + return $this; + } + /** + * The customer's ship customer config, if user has ship role + * + * @return Shipping + */ + public function getShippingRights() : Shipping + { + return $this->shippingRights; + } + /** + * The customer's ship customer config, if user has ship role + * + * @param Shipping $shippingRights + * + * @return self + */ + public function setShippingRights(Shipping $shippingRights) : self + { + $this->initialized['shippingRights'] = true; + $this->shippingRights = $shippingRights; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponse.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponse.php new file mode 100644 index 00000000..7c1c1fd5 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponse.php @@ -0,0 +1,71 @@ +initialized); + } + /** + * + * + * @var ApiVersionResponseAmp + */ + protected $amp; + /** + * + * + * @var ApiVersionResponseBackend + */ + protected $backend; + /** + * + * + * @return ApiVersionResponseAmp + */ + public function getAmp() : ApiVersionResponseAmp + { + return $this->amp; + } + /** + * + * + * @param ApiVersionResponseAmp $amp + * + * @return self + */ + public function setAmp(ApiVersionResponseAmp $amp) : self + { + $this->initialized['amp'] = true; + $this->amp = $amp; + return $this; + } + /** + * + * + * @return ApiVersionResponseBackend + */ + public function getBackend() : ApiVersionResponseBackend + { + return $this->backend; + } + /** + * + * + * @param ApiVersionResponseBackend $backend + * + * @return self + */ + public function setBackend(ApiVersionResponseBackend $backend) : self + { + $this->initialized['backend'] = true; + $this->backend = $backend; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseAmp.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseAmp.php new file mode 100644 index 00000000..b07727ca --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseAmp.php @@ -0,0 +1,127 @@ +initialized); + } + /** + * name of api + * + * @var string + */ + protected $name; + /** + * environment + * + * @var string + */ + protected $env; + /** + * version of api + * + * @var string + */ + protected $version; + /** + * revision + * + * @var string + */ + protected $rev; + /** + * name of api + * + * @return string + */ + public function getName() : string + { + return $this->name; + } + /** + * name of api + * + * @param string $name + * + * @return self + */ + public function setName(string $name) : self + { + $this->initialized['name'] = true; + $this->name = $name; + return $this; + } + /** + * environment + * + * @return string + */ + public function getEnv() : string + { + return $this->env; + } + /** + * environment + * + * @param string $env + * + * @return self + */ + public function setEnv(string $env) : self + { + $this->initialized['env'] = true; + $this->env = $env; + return $this; + } + /** + * version of api + * + * @return string + */ + public function getVersion() : string + { + return $this->version; + } + /** + * version of api + * + * @param string $version + * + * @return self + */ + public function setVersion(string $version) : self + { + $this->initialized['version'] = true; + $this->version = $version; + return $this; + } + /** + * revision + * + * @return string + */ + public function getRev() : string + { + return $this->rev; + } + /** + * revision + * + * @param string $rev + * + * @return self + */ + public function setRev(string $rev) : self + { + $this->initialized['rev'] = true; + $this->rev = $rev; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseBackend.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseBackend.php new file mode 100644 index 00000000..8cdfc490 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseBackend.php @@ -0,0 +1,71 @@ +initialized); + } + /** + * environment + * + * @var string + */ + protected $env; + /** + * version of backend + * + * @var string + */ + protected $version; + /** + * environment + * + * @return string + */ + public function getEnv() : string + { + return $this->env; + } + /** + * environment + * + * @param string $env + * + * @return self + */ + public function setEnv(string $env) : self + { + $this->initialized['env'] = true; + $this->env = $env; + return $this; + } + /** + * version of backend + * + * @return string + */ + public function getVersion() : string + { + return $this->version; + } + /** + * version of backend + * + * @param string $version + * + * @return self + */ + public function setVersion(string $version) : self + { + $this->initialized['version'] = true; + $this->version = $version; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseHTML.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseHTML.php new file mode 100644 index 00000000..11b7430a --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseHTML.php @@ -0,0 +1,43 @@ +initialized); + } + /** + * + * + * @var ApiVersionResponseHTMLAmp + */ + protected $amp; + /** + * + * + * @return ApiVersionResponseHTMLAmp + */ + public function getAmp() : ApiVersionResponseHTMLAmp + { + return $this->amp; + } + /** + * + * + * @param ApiVersionResponseHTMLAmp $amp + * + * @return self + */ + public function setAmp(ApiVersionResponseHTMLAmp $amp) : self + { + $this->initialized['amp'] = true; + $this->amp = $amp; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseHTMLAmp.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseHTMLAmp.php new file mode 100644 index 00000000..d0e278f2 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/ApiVersionResponseHTMLAmp.php @@ -0,0 +1,127 @@ +initialized); + } + /** + * name of api + * + * @var string + */ + protected $name; + /** + * environment + * + * @var string + */ + protected $env; + /** + * version of api + * + * @var string + */ + protected $version; + /** + * revision + * + * @var string + */ + protected $rev; + /** + * name of api + * + * @return string + */ + public function getName() : string + { + return $this->name; + } + /** + * name of api + * + * @param string $name + * + * @return self + */ + public function setName(string $name) : self + { + $this->initialized['name'] = true; + $this->name = $name; + return $this; + } + /** + * environment + * + * @return string + */ + public function getEnv() : string + { + return $this->env; + } + /** + * environment + * + * @param string $env + * + * @return self + */ + public function setEnv(string $env) : self + { + $this->initialized['env'] = true; + $this->env = $env; + return $this; + } + /** + * version of api + * + * @return string + */ + public function getVersion() : string + { + return $this->version; + } + /** + * version of api + * + * @param string $version + * + * @return self + */ + public function setVersion(string $version) : self + { + $this->initialized['version'] = true; + $this->version = $version; + return $this; + } + /** + * revision + * + * @return string + */ + public function getRev() : string + { + return $this->rev; + } + /** + * revision + * + * @param string $rev + * + * @return self + */ + public function setRev(string $rev) : self + { + $this->initialized['rev'] = true; + $this->rev = $rev; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/Detail.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/Detail.php new file mode 100644 index 00000000..6e03dde1 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/Detail.php @@ -0,0 +1,127 @@ +initialized); + } + /** + * contract billing number + * + * @var string + */ + protected $billingNumber; + /** + * booking text + * + * @var string + */ + protected $bookingText; + /** + * go green + * + * @var bool + */ + protected $goGreen; + /** + * The customer's ship customer config product data + * + * @var Product + */ + protected $product; + /** + * contract billing number + * + * @return string + */ + public function getBillingNumber() : string + { + return $this->billingNumber; + } + /** + * contract billing number + * + * @param string $billingNumber + * + * @return self + */ + public function setBillingNumber(string $billingNumber) : self + { + $this->initialized['billingNumber'] = true; + $this->billingNumber = $billingNumber; + return $this; + } + /** + * booking text + * + * @return string + */ + public function getBookingText() : string + { + return $this->bookingText; + } + /** + * booking text + * + * @param string $bookingText + * + * @return self + */ + public function setBookingText(string $bookingText) : self + { + $this->initialized['bookingText'] = true; + $this->bookingText = $bookingText; + return $this; + } + /** + * go green + * + * @return bool + */ + public function getGoGreen() : bool + { + return $this->goGreen; + } + /** + * go green + * + * @param bool $goGreen + * + * @return self + */ + public function setGoGreen(bool $goGreen) : self + { + $this->initialized['goGreen'] = true; + $this->goGreen = $goGreen; + return $this; + } + /** + * The customer's ship customer config product data + * + * @return Product + */ + public function getProduct() : Product + { + return $this->product; + } + /** + * The customer's ship customer config product data + * + * @param Product $product + * + * @return self + */ + public function setProduct(Product $product) : self + { + $this->initialized['product'] = true; + $this->product = $product; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/Product.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/Product.php new file mode 100644 index 00000000..30a3285b --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/Product.php @@ -0,0 +1,99 @@ +initialized); + } + /** + * language independent key of product + * + * @var string + */ + protected $key; + /** + * name of product + * + * @var string + */ + protected $name; + /** + * services + * + * @var Service[] + */ + protected $services; + /** + * language independent key of product + * + * @return string + */ + public function getKey() : string + { + return $this->key; + } + /** + * language independent key of product + * + * @param string $key + * + * @return self + */ + public function setKey(string $key) : self + { + $this->initialized['key'] = true; + $this->key = $key; + return $this; + } + /** + * name of product + * + * @return string + */ + public function getName() : string + { + return $this->name; + } + /** + * name of product + * + * @param string $name + * + * @return self + */ + public function setName(string $name) : self + { + $this->initialized['name'] = true; + $this->name = $name; + return $this; + } + /** + * services + * + * @return Service[] + */ + public function getServices() : array + { + return $this->services; + } + /** + * services + * + * @param Service[] $services + * + * @return self + */ + public function setServices(array $services) : self + { + $this->initialized['services'] = true; + $this->services = $services; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/RequestStatus.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/RequestStatus.php new file mode 100644 index 00000000..5ec44040 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/RequestStatus.php @@ -0,0 +1,127 @@ +initialized); + } + /** + * http status code + * + * @var int + */ + protected $statusCode; + /** + * http status reason + * + * @var string + */ + protected $title; + /** + * description of error reason + * + * @var string + */ + protected $detail; + /** + * source of error + * + * @var string + */ + protected $instance; + /** + * http status code + * + * @return int + */ + public function getStatusCode() : int + { + return $this->statusCode; + } + /** + * http status code + * + * @param int $statusCode + * + * @return self + */ + public function setStatusCode(int $statusCode) : self + { + $this->initialized['statusCode'] = true; + $this->statusCode = $statusCode; + return $this; + } + /** + * http status reason + * + * @return string + */ + public function getTitle() : string + { + return $this->title; + } + /** + * http status reason + * + * @param string $title + * + * @return self + */ + public function setTitle(string $title) : self + { + $this->initialized['title'] = true; + $this->title = $title; + return $this; + } + /** + * description of error reason + * + * @return string + */ + public function getDetail() : string + { + return $this->detail; + } + /** + * description of error reason + * + * @param string $detail + * + * @return self + */ + public function setDetail(string $detail) : self + { + $this->initialized['detail'] = true; + $this->detail = $detail; + return $this; + } + /** + * source of error + * + * @return string + */ + public function getInstance() : string + { + return $this->instance; + } + /** + * source of error + * + * @param string $instance + * + * @return self + */ + public function setInstance(string $instance) : self + { + $this->initialized['instance'] = true; + $this->instance = $instance; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/Service.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/Service.php new file mode 100644 index 00000000..eb058b0f --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/Service.php @@ -0,0 +1,71 @@ +initialized); + } + /** + * language indenpendent key of service + * + * @var string + */ + protected $key; + /** + * name of service + * + * @var string + */ + protected $name; + /** + * language indenpendent key of service + * + * @return string + */ + public function getKey() : string + { + return $this->key; + } + /** + * language indenpendent key of service + * + * @param string $key + * + * @return self + */ + public function setKey(string $key) : self + { + $this->initialized['key'] = true; + $this->key = $key; + return $this; + } + /** + * name of service + * + * @return string + */ + public function getName() : string + { + return $this->name; + } + /** + * name of service + * + * @param string $name + * + * @return self + */ + public function setName(string $name) : self + { + $this->initialized['name'] = true; + $this->name = $name; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/Shipping.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/Shipping.php new file mode 100644 index 00000000..7dc4189c --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/Shipping.php @@ -0,0 +1,43 @@ +initialized); + } + /** + * customer's ship customer config details + * + * @var Detail[] + */ + protected $details; + /** + * customer's ship customer config details + * + * @return Detail[] + */ + public function getDetails() : array + { + return $this->details; + } + /** + * customer's ship customer config details + * + * @param Detail[] $details + * + * @return self + */ + public function setDetails(array $details) : self + { + $this->initialized['details'] = true; + $this->details = $details; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Model/User.php b/src/modules/mo/mo_dhl/Api/MyAccount/Model/User.php new file mode 100644 index 00000000..b8154119 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Model/User.php @@ -0,0 +1,43 @@ +initialized); + } + /** + * user's password is valid until this timestamp + * + * @var \DateTime + */ + protected $passwordValidUntil; + /** + * user's password is valid until this timestamp + * + * @return \DateTime + */ + public function getPasswordValidUntil() : \DateTime + { + return $this->passwordValidUntil; + } + /** + * user's password is valid until this timestamp + * + * @param \DateTime $passwordValidUntil + * + * @return self + */ + public function setPasswordValidUntil(\DateTime $passwordValidUntil) : self + { + $this->initialized['passwordValidUntil'] = true; + $this->passwordValidUntil = $passwordValidUntil; + return $this; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/AggregatedUserDataResponseNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/AggregatedUserDataResponseNormalizer.php new file mode 100644 index 00000000..8532d1a7 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/AggregatedUserDataResponseNormalizer.php @@ -0,0 +1,80 @@ +setUser($this->denormalizer->denormalize($data['user'], 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\User', 'json', $context)); + unset($data['user']); + } + if (\array_key_exists('shippingRights', $data)) { + $object->setShippingRights($this->denormalizer->denormalize($data['shippingRights'], 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Shipping', 'json', $context)); + unset($data['shippingRights']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + $data['user'] = $this->normalizer->normalize($object->getUser(), 'json', $context); + if ($object->isInitialized('shippingRights') && null !== $object->getShippingRights()) { + $data['shippingRights'] = $this->normalizer->normalize($object->getShippingRights(), 'json', $context); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\AggregatedUserDataResponse' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseAmpNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseAmpNormalizer.php new file mode 100644 index 00000000..217b99b1 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseAmpNormalizer.php @@ -0,0 +1,96 @@ +setName($data['name']); + unset($data['name']); + } + if (\array_key_exists('env', $data)) { + $object->setEnv($data['env']); + unset($data['env']); + } + if (\array_key_exists('version', $data)) { + $object->setVersion($data['version']); + unset($data['version']); + } + if (\array_key_exists('rev', $data)) { + $object->setRev($data['rev']); + unset($data['rev']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('name') && null !== $object->getName()) { + $data['name'] = $object->getName(); + } + if ($object->isInitialized('env') && null !== $object->getEnv()) { + $data['env'] = $object->getEnv(); + } + if ($object->isInitialized('version') && null !== $object->getVersion()) { + $data['version'] = $object->getVersion(); + } + if ($object->isInitialized('rev') && null !== $object->getRev()) { + $data['rev'] = $object->getRev(); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseAmp' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseBackendNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseBackendNormalizer.php new file mode 100644 index 00000000..8d3a9130 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseBackendNormalizer.php @@ -0,0 +1,82 @@ +setEnv($data['env']); + unset($data['env']); + } + if (\array_key_exists('version', $data)) { + $object->setVersion($data['version']); + unset($data['version']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('env') && null !== $object->getEnv()) { + $data['env'] = $object->getEnv(); + } + if ($object->isInitialized('version') && null !== $object->getVersion()) { + $data['version'] = $object->getVersion(); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseBackend' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseHTMLAmpNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseHTMLAmpNormalizer.php new file mode 100644 index 00000000..0c3271e7 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseHTMLAmpNormalizer.php @@ -0,0 +1,96 @@ +setName($data['name']); + unset($data['name']); + } + if (\array_key_exists('env', $data)) { + $object->setEnv($data['env']); + unset($data['env']); + } + if (\array_key_exists('version', $data)) { + $object->setVersion($data['version']); + unset($data['version']); + } + if (\array_key_exists('rev', $data)) { + $object->setRev($data['rev']); + unset($data['rev']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('name') && null !== $object->getName()) { + $data['name'] = $object->getName(); + } + if ($object->isInitialized('env') && null !== $object->getEnv()) { + $data['env'] = $object->getEnv(); + } + if ($object->isInitialized('version') && null !== $object->getVersion()) { + $data['version'] = $object->getVersion(); + } + if ($object->isInitialized('rev') && null !== $object->getRev()) { + $data['rev'] = $object->getRev(); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseHTMLAmp' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseHTMLNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseHTMLNormalizer.php new file mode 100644 index 00000000..1423b041 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseHTMLNormalizer.php @@ -0,0 +1,75 @@ +setAmp($this->denormalizer->denormalize($data['amp'], 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseHTMLAmp', 'json', $context)); + unset($data['amp']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('amp') && null !== $object->getAmp()) { + $data['amp'] = $this->normalizer->normalize($object->getAmp(), 'json', $context); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseHTML' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseNormalizer.php new file mode 100644 index 00000000..96d3d252 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ApiVersionResponseNormalizer.php @@ -0,0 +1,82 @@ +setAmp($this->denormalizer->denormalize($data['amp'], 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseAmp', 'json', $context)); + unset($data['amp']); + } + if (\array_key_exists('backend', $data)) { + $object->setBackend($this->denormalizer->denormalize($data['backend'], 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseBackend', 'json', $context)); + unset($data['backend']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('amp') && null !== $object->getAmp()) { + $data['amp'] = $this->normalizer->normalize($object->getAmp(), 'json', $context); + } + if ($object->isInitialized('backend') && null !== $object->getBackend()) { + $data['backend'] = $this->normalizer->normalize($object->getBackend(), 'json', $context); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponse' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/DetailNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/DetailNormalizer.php new file mode 100644 index 00000000..4a19b448 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/DetailNormalizer.php @@ -0,0 +1,96 @@ +setBillingNumber($data['billingNumber']); + unset($data['billingNumber']); + } + if (\array_key_exists('bookingText', $data)) { + $object->setBookingText($data['bookingText']); + unset($data['bookingText']); + } + if (\array_key_exists('goGreen', $data)) { + $object->setGoGreen($data['goGreen']); + unset($data['goGreen']); + } + if (\array_key_exists('product', $data)) { + $object->setProduct($this->denormalizer->denormalize($data['product'], 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Product', 'json', $context)); + unset($data['product']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('billingNumber') && null !== $object->getBillingNumber()) { + $data['billingNumber'] = $object->getBillingNumber(); + } + if ($object->isInitialized('bookingText') && null !== $object->getBookingText()) { + $data['bookingText'] = $object->getBookingText(); + } + if ($object->isInitialized('goGreen') && null !== $object->getGoGreen()) { + $data['goGreen'] = $object->getGoGreen(); + } + if ($object->isInitialized('product') && null !== $object->getProduct()) { + $data['product'] = $this->normalizer->normalize($object->getProduct(), 'json', $context); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\Detail' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/JaneObjectNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/JaneObjectNormalizer.php new file mode 100644 index 00000000..21211dd9 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/JaneObjectNormalizer.php @@ -0,0 +1,62 @@ + 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\ApiVersionResponseNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseAmp' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\ApiVersionResponseAmpNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseBackend' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\ApiVersionResponseBackendNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseHTML' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\ApiVersionResponseHTMLNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseHTMLAmp' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\ApiVersionResponseHTMLAmpNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\AggregatedUserDataResponse' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\AggregatedUserDataResponseNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Detail' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\DetailNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Product' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\ProductNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Service' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\ServiceNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Shipping' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\ShippingNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\User' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\UserNormalizer', 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\RequestStatus' => 'Mediaopt\\DHL\\Api\\MyAccount\\Normalizer\\RequestStatusNormalizer', '\\Jane\\Component\\JsonSchemaRuntime\\Reference' => '\\Mediaopt\\DHL\\Api\\MyAccount\\Runtime\\Normalizer\\ReferenceNormalizer'), $normalizersCache = array(); + public function supportsDenormalization($data, $type, $format = null, array $context = array()) : bool + { + return array_key_exists($type, $this->normalizers); + } + public function supportsNormalization($data, $format = null, array $context = array()) : bool + { + return is_object($data) && array_key_exists(get_class($data), $this->normalizers); + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $normalizerClass = $this->normalizers[get_class($object)]; + $normalizer = $this->getNormalizer($normalizerClass); + return $normalizer->normalize($object, $format, $context); + } + /** + * @return mixed + */ + public function denormalize($data, $class, $format = null, array $context = array()) + { + $denormalizerClass = $this->normalizers[$class]; + $denormalizer = $this->getNormalizer($denormalizerClass); + return $denormalizer->denormalize($data, $class, $format, $context); + } + private function getNormalizer(string $normalizerClass) + { + return $this->normalizersCache[$normalizerClass] ?? $this->initNormalizer($normalizerClass); + } + private function initNormalizer(string $normalizerClass) + { + $normalizer = new $normalizerClass(); + $normalizer->setNormalizer($this->normalizer); + $normalizer->setDenormalizer($this->denormalizer); + $this->normalizersCache[$normalizerClass] = $normalizer; + return $normalizer; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponse' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseAmp' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseBackend' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseHTML' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\ApiVersionResponseHTMLAmp' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\AggregatedUserDataResponse' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Detail' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Product' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Service' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Shipping' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\User' => false, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\RequestStatus' => false, '\\Jane\\Component\\JsonSchemaRuntime\\Reference' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ProductNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ProductNormalizer.php new file mode 100644 index 00000000..c9bd0623 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ProductNormalizer.php @@ -0,0 +1,97 @@ +setKey($data['key']); + unset($data['key']); + } + if (\array_key_exists('name', $data)) { + $object->setName($data['name']); + unset($data['name']); + } + if (\array_key_exists('services', $data)) { + $values = array(); + foreach ($data['services'] as $value) { + $values[] = $this->denormalizer->denormalize($value, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Service', 'json', $context); + } + $object->setServices($values); + unset($data['services']); + } + foreach ($data as $key => $value_1) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value_1; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('key') && null !== $object->getKey()) { + $data['key'] = $object->getKey(); + } + if ($object->isInitialized('name') && null !== $object->getName()) { + $data['name'] = $object->getName(); + } + if ($object->isInitialized('services') && null !== $object->getServices()) { + $values = array(); + foreach ($object->getServices() as $value) { + $values[] = $this->normalizer->normalize($value, 'json', $context); + } + $data['services'] = $values; + } + foreach ($object as $key => $value_1) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value_1; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\Product' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/RequestStatusNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/RequestStatusNormalizer.php new file mode 100644 index 00000000..b291fb5f --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/RequestStatusNormalizer.php @@ -0,0 +1,96 @@ +setStatusCode($data['statusCode']); + unset($data['statusCode']); + } + if (\array_key_exists('title', $data)) { + $object->setTitle($data['title']); + unset($data['title']); + } + if (\array_key_exists('detail', $data)) { + $object->setDetail($data['detail']); + unset($data['detail']); + } + if (\array_key_exists('instance', $data)) { + $object->setInstance($data['instance']); + unset($data['instance']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('statusCode') && null !== $object->getStatusCode()) { + $data['statusCode'] = $object->getStatusCode(); + } + if ($object->isInitialized('title') && null !== $object->getTitle()) { + $data['title'] = $object->getTitle(); + } + if ($object->isInitialized('detail') && null !== $object->getDetail()) { + $data['detail'] = $object->getDetail(); + } + if ($object->isInitialized('instance') && null !== $object->getInstance()) { + $data['instance'] = $object->getInstance(); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\RequestStatus' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ServiceNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ServiceNormalizer.php new file mode 100644 index 00000000..118c4aab --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ServiceNormalizer.php @@ -0,0 +1,82 @@ +setKey($data['key']); + unset($data['key']); + } + if (\array_key_exists('name', $data)) { + $object->setName($data['name']); + unset($data['name']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('key') && null !== $object->getKey()) { + $data['key'] = $object->getKey(); + } + if ($object->isInitialized('name') && null !== $object->getName()) { + $data['name'] = $object->getName(); + } + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\Service' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ShippingNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ShippingNormalizer.php new file mode 100644 index 00000000..57a1e049 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/ShippingNormalizer.php @@ -0,0 +1,83 @@ +denormalizer->denormalize($value, 'Mediaopt\\DHL\\Api\\MyAccount\\Model\\Detail', 'json', $context); + } + $object->setDetails($values); + unset($data['details']); + } + foreach ($data as $key => $value_1) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value_1; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + if ($object->isInitialized('details') && null !== $object->getDetails()) { + $values = array(); + foreach ($object->getDetails() as $value) { + $values[] = $this->normalizer->normalize($value, 'json', $context); + } + $data['details'] = $values; + } + foreach ($object as $key => $value_1) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value_1; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\Shipping' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/UserNormalizer.php b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/UserNormalizer.php new file mode 100644 index 00000000..f550514c --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Normalizer/UserNormalizer.php @@ -0,0 +1,73 @@ +setPasswordValidUntil(\DateTime::createFromFormat('Y-m-d\\TH:i:sP', $data['passwordValidUntil'])); + unset($data['passwordValidUntil']); + } + foreach ($data as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $object[$key] = $value; + } + } + return $object; + } + /** + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = array()) + { + $data = array(); + $data['passwordValidUntil'] = $object->getPasswordValidUntil()->format('Y-m-d\\TH:i:sP'); + foreach ($object as $key => $value) { + if (preg_match('/.*/', (string) $key)) { + $data[$key] = $value; + } + } + return $data; + } + public function getSupportedTypes(?string $format = null) : array + { + return array('Mediaopt\\DHL\\Api\\MyAccount\\Model\\User' => false); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/BaseEndpoint.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/BaseEndpoint.php new file mode 100644 index 00000000..4488ef78 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/BaseEndpoint.php @@ -0,0 +1,66 @@ +getQueryOptionsResolver()->resolve($this->queryParameters); + $optionsResolved = array_map(function ($value) { + return null !== $value ? $value : ''; + }, $optionsResolved); + return http_build_query($optionsResolved, '', '&', PHP_QUERY_RFC3986); + } + public function getHeaders(array $baseHeaders = []) : array + { + return array_merge($this->getExtraHeaders(), $baseHeaders, $this->getHeadersOptionsResolver()->resolve($this->headerParameters)); + } + protected function getQueryOptionsResolver() : OptionsResolver + { + return new OptionsResolver(); + } + protected function getHeadersOptionsResolver() : OptionsResolver + { + return new OptionsResolver(); + } + // ---------------------------------------------------------------------------------------------------- + // Used for OpenApi2 compatibility + protected function getFormBody() : array + { + return [['Content-Type' => ['application/x-www-form-urlencoded']], http_build_query($this->getFormOptionsResolver()->resolve($this->formParameters))]; + } + protected function getMultipartBody($streamFactory = null) : array + { + $bodyBuilder = new MultipartStreamBuilder($streamFactory); + $formParameters = $this->getFormOptionsResolver()->resolve($this->formParameters); + foreach ($formParameters as $key => $value) { + $bodyBuilder->addResource($key, $value); + } + return [['Content-Type' => ['multipart/form-data; boundary="' . ($bodyBuilder->getBoundary() . '"')]], $bodyBuilder->build()]; + } + protected function getFormOptionsResolver() : OptionsResolver + { + return new OptionsResolver(); + } + protected function getSerializedBody(SerializerInterface $serializer) : array + { + return [['Content-Type' => ['application/json']], $serializer->serialize($this->body, 'json')]; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php new file mode 100644 index 00000000..d0909901 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php @@ -0,0 +1,82 @@ +httpClient = $httpClient; + $this->requestFactory = $requestFactory; + $this->serializer = $serializer; + $this->streamFactory = $streamFactory; + } + public function executeEndpoint(Endpoint $endpoint, string $fetch = self::FETCH_OBJECT) + { + if (self::FETCH_RESPONSE === $fetch) { + trigger_deprecation('jane-php/open-api-common', '7.3', 'Using %s::%s method with $fetch parameter equals to response is deprecated, use %s::%s instead.', __CLASS__, __METHOD__, __CLASS__, 'executeRawEndpoint'); + return $this->executeRawEndpoint($endpoint); + } + return $endpoint->parseResponse($this->processEndpoint($endpoint), $this->serializer, $fetch); + } + public function executeRawEndpoint(Endpoint $endpoint) : ResponseInterface + { + return $this->processEndpoint($endpoint); + } + private function processEndpoint(Endpoint $endpoint) : ResponseInterface + { + [$bodyHeaders, $body] = $endpoint->getBody($this->serializer, $this->streamFactory); + $queryString = $endpoint->getQueryString(); + $uriGlue = false === strpos($endpoint->getUri(), '?') ? '?' : '&'; + $uri = $queryString !== '' ? $endpoint->getUri() . $uriGlue . $queryString : $endpoint->getUri(); + $request = $this->requestFactory->createRequest($endpoint->getMethod(), $uri); + if ($body) { + if ($body instanceof StreamInterface) { + $request = $request->withBody($body); + } elseif (is_resource($body)) { + $request = $request->withBody($this->streamFactory->createStreamFromResource($body)); + } elseif (strlen($body) <= 4000 && @file_exists($body)) { + // more than 4096 chars will trigger an error + $request = $request->withBody($this->streamFactory->createStreamFromFile($body)); + } else { + $request = $request->withBody($this->streamFactory->createStream($body)); + } + } + foreach ($endpoint->getHeaders($bodyHeaders) as $name => $value) { + $request = $request->withHeader($name, $value); + } + if (count($endpoint->getAuthenticationScopes()) > 0) { + $scopes = []; + foreach ($endpoint->getAuthenticationScopes() as $scope) { + $scopes[] = $scope; + } + $request = $request->withHeader(AuthenticationRegistry::SCOPES_HEADER, $scopes); + } + return $this->httpClient->sendRequest($request); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/CustomQueryResolver.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/CustomQueryResolver.php new file mode 100644 index 00000000..d0b6e56e --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/CustomQueryResolver.php @@ -0,0 +1,9 @@ +hasHeader('Content-Type') ? current($response->getHeader('Content-Type')) : null; + return $this->transformResponseBody($response, $serializer, $contentType); + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/CheckArray.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/CheckArray.php new file mode 100644 index 00000000..911750b9 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/CheckArray.php @@ -0,0 +1,13 @@ +getReferenceUri(); + return $ref; + } + /** + * {@inheritdoc} + */ + public function supportsNormalization($data, $format = null) : bool + { + return $data instanceof Reference; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/ValidationException.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/ValidationException.php new file mode 100644 index 00000000..36824d49 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/ValidationException.php @@ -0,0 +1,19 @@ +violationList = $violationList; + parent::__construct(sprintf('Model validation failed with %d errors.', $violationList->count()), 400); + } + public function getViolationList() : ConstraintViolationListInterface + { + return $this->violationList; + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/ValidatorTrait.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/ValidatorTrait.php new file mode 100644 index 00000000..77242346 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Normalizer/ValidatorTrait.php @@ -0,0 +1,16 @@ +validate($data, $constraint); + if ($violations->count() > 0) { + throw new ValidationException($violations); + } + } +} \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Main.php b/src/modules/mo/mo_dhl/Main.php index ae54e74a..60cb481d 100644 --- a/src/modules/mo/mo_dhl/Main.php +++ b/src/modules/mo/mo_dhl/Main.php @@ -164,4 +164,12 @@ public function buildParcelShipping(): Client { return $this->getConfigurator()->buildParcelShipping($this->getLogger()); } + + /** + * @return Client + */ + public function buildAuthentication(): Api\Authentication\Client + { + return $this->getConfigurator()->buildAuthentication($this->getLogger()); + } } From 0361359443abd89c8822f535a6af0a146223ffbb Mon Sep 17 00:00:00 2001 From: bohdan Date: Tue, 14 Nov 2023 15:14:55 +0100 Subject: [PATCH 02/16] #34741 account api wip --- composer.lock | 317 ++++++++++-------- src/modules/mo/mo_dhl/Adapter/DHLAdapter.php | 6 +- .../mo/mo_dhl/Adapter/DHLConfigurator.php | 49 +++ src/modules/mo/mo_dhl/Api/Authentication.php | 29 ++ .../Authentication/Runtime/Client/Client.php | 2 + src/modules/mo/mo_dhl/Api/Credentials.php | 23 ++ src/modules/mo/mo_dhl/Api/MyAccount.php | 39 +++ .../Api/MyAccount/Runtime/Client/Client.php | 7 + .../Runtime/Client/EndpointTrait.php | 1 + .../Controller/Admin/ModuleConfiguration.php | 24 ++ .../views/admin/de/module_lang.php | 1 + .../views/admin/de/module_options.php | 6 + .../views/admin/en/module_lang.php | 1 + .../views/admin/en/module_options.php | 6 + src/modules/mo/mo_dhl/Configurator.php | 81 +++++ src/modules/mo/mo_dhl/Main.php | 6 +- src/modules/mo/mo_dhl/bootstrap.php | 2 + src/modules/mo/mo_dhl/metadata.php | 16 + ...e_config_admin_module_config_var_types.tpl | 3 + 19 files changed, 468 insertions(+), 151 deletions(-) create mode 100644 src/modules/mo/mo_dhl/Api/Authentication.php create mode 100644 src/modules/mo/mo_dhl/Api/MyAccount.php create mode 100644 src/modules/mo/mo_dhl/bootstrap.php diff --git a/composer.lock b/composer.lock index 5554129e..ddf81c98 100644 --- a/composer.lock +++ b/composer.lock @@ -490,16 +490,16 @@ }, { "name": "jane-php/json-schema", - "version": "v7.5.3", + "version": "v7.5.4", "source": { "type": "git", "url": "https://github.com/janephp/json-schema.git", - "reference": "fc485e6fe1edfd905b80a0591f11a30af4bbeb3e" + "reference": "8abf13ced439c2f32d583d697ab99ea16c700b0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/janephp/json-schema/zipball/fc485e6fe1edfd905b80a0591f11a30af4bbeb3e", - "reference": "fc485e6fe1edfd905b80a0591f11a30af4bbeb3e", + "url": "https://api.github.com/repos/janephp/json-schema/zipball/8abf13ced439c2f32d583d697ab99ea16c700b0b", + "reference": "8abf13ced439c2f32d583d697ab99ea16c700b0b", "shasum": "" }, "require": { @@ -560,27 +560,27 @@ ], "description": "Generate a serializable / deserializable object model given a json schema", "support": { - "source": "https://github.com/janephp/json-schema/tree/v7.5.3" + "source": "https://github.com/janephp/json-schema/tree/v7.5.4" }, - "time": "2023-08-04T08:41:58+00:00" + "time": "2023-09-08T13:25:01+00:00" }, { "name": "jane-php/json-schema-runtime", - "version": "v7.5.3", + "version": "v7.5.4", "source": { "type": "git", "url": "https://github.com/janephp/json-schema-runtime.git", - "reference": "0c48480e1fccda01908085cd985346aa0ce7651b" + "reference": "02e5a960f5e6db8cba1f711ca10a0d589174402f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/janephp/json-schema-runtime/zipball/0c48480e1fccda01908085cd985346aa0ce7651b", - "reference": "0c48480e1fccda01908085cd985346aa0ce7651b", + "url": "https://api.github.com/repos/janephp/json-schema-runtime/zipball/02e5a960f5e6db8cba1f711ca10a0d589174402f", + "reference": "02e5a960f5e6db8cba1f711ca10a0d589174402f", "shasum": "" }, "require": { "ext-json": "*", - "league/uri": "^6.0", + "league/uri": "^6.0 || ^7.0", "php": "^7.2 || ^8.0", "php-jsonpointer/php-jsonpointer": "^3.0 || ^4.0", "symfony/serializer": "^4.4 || ^5.0 || ^6.0", @@ -622,22 +622,22 @@ ], "description": "Jane runtime Library", "support": { - "source": "https://github.com/janephp/json-schema-runtime/tree/v7.5.3" + "source": "https://github.com/janephp/json-schema-runtime/tree/v7.5.4" }, - "time": "2023-01-24T07:25:29+00:00" + "time": "2023-09-08T13:25:01+00:00" }, { "name": "jane-php/open-api-3", - "version": "v7.5.3", + "version": "v7.5.4", "source": { "type": "git", "url": "https://github.com/janephp/open-api-3.git", - "reference": "8a66e329fd30d9818f7ad46aa64444d5d1717337" + "reference": "b337a11ae3393f79a28c0ee7a8ad7f58e010a1a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/janephp/open-api-3/zipball/8a66e329fd30d9818f7ad46aa64444d5d1717337", - "reference": "8a66e329fd30d9818f7ad46aa64444d5d1717337", + "url": "https://api.github.com/repos/janephp/open-api-3/zipball/b337a11ae3393f79a28c0ee7a8ad7f58e010a1a6", + "reference": "b337a11ae3393f79a28c0ee7a8ad7f58e010a1a6", "shasum": "" }, "require": { @@ -697,22 +697,22 @@ "swagger" ], "support": { - "source": "https://github.com/janephp/open-api-3/tree/v7.5.3" + "source": "https://github.com/janephp/open-api-3/tree/v7.5.4" }, - "time": "2023-08-04T08:41:58+00:00" + "time": "2023-08-24T10:12:49+00:00" }, { "name": "jane-php/open-api-common", - "version": "v7.5.3", + "version": "v7.5.4", "source": { "type": "git", "url": "https://github.com/janephp/open-api-common.git", - "reference": "45774edbab5d63db778031e2556aad40722a03a5" + "reference": "e48862e01188076a7d7ba4a1df451b448bd1af64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/janephp/open-api-common/zipball/45774edbab5d63db778031e2556aad40722a03a5", - "reference": "45774edbab5d63db778031e2556aad40722a03a5", + "url": "https://api.github.com/repos/janephp/open-api-common/zipball/e48862e01188076a7d7ba4a1df451b448bd1af64", + "reference": "e48862e01188076a7d7ba4a1df451b448bd1af64", "shasum": "" }, "require": { @@ -765,13 +765,13 @@ "utility" ], "support": { - "source": "https://github.com/janephp/open-api-common/tree/v7.5.3" + "source": "https://github.com/janephp/open-api-common/tree/v7.5.4" }, - "time": "2023-03-09T16:50:42+00:00" + "time": "2023-09-08T13:25:01+00:00" }, { "name": "jane-php/open-api-runtime", - "version": "v7.5.3", + "version": "v7.5.4", "source": { "type": "git", "url": "https://github.com/janephp/open-api-runtime.git", @@ -828,7 +828,7 @@ ], "description": "Jane OpenAPI Runtime Library, dependencies and utility class for a library generated by jane/openapi", "support": { - "source": "https://github.com/janephp/open-api-runtime/tree/v7.5.3" + "source": "https://github.com/janephp/open-api-runtime/tree/v7.5.4" }, "time": "2021-12-16T13:26:58+00:00" }, @@ -1293,16 +1293,16 @@ }, { "name": "php-http/curl-client", - "version": "2.3.0", + "version": "2.3.1", "source": { "type": "git", "url": "https://github.com/php-http/curl-client.git", - "reference": "f7352c0796549949900d28fe991e19c90572386a" + "reference": "085570be588f7cbdc4601e78886eea5b7051ad71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/curl-client/zipball/f7352c0796549949900d28fe991e19c90572386a", - "reference": "f7352c0796549949900d28fe991e19c90572386a", + "url": "https://api.github.com/repos/php-http/curl-client/zipball/085570be588f7cbdc4601e78886eea5b7051ad71", + "reference": "085570be588f7cbdc4601e78886eea5b7051ad71", "shasum": "" }, "require": { @@ -1313,7 +1313,7 @@ "php-http/message": "^1.2", "psr/http-client": "^1.0", "psr/http-factory-implementation": "^1.0", - "symfony/options-resolver": "^3.4 || ^4.0 || ^5.0 || ^6.0" + "symfony/options-resolver": "^3.4 || ^4.0 || ^5.0 || ^6.0 || ^7.0" }, "provide": { "php-http/async-client-implementation": "1.0", @@ -1324,6 +1324,7 @@ "guzzlehttp/psr7": "^1.0", "laminas/laminas-diactoros": "^2.0", "php-http/client-integration-tests": "^3.0", + "php-http/message-factory": "^1.1", "phpunit/phpunit": "^7.5 || ^9.4" }, "type": "library", @@ -1351,9 +1352,9 @@ ], "support": { "issues": "https://github.com/php-http/curl-client/issues", - "source": "https://github.com/php-http/curl-client/tree/2.3.0" + "source": "https://github.com/php-http/curl-client/tree/2.3.1" }, - "time": "2023-04-28T14:56:41+00:00" + "time": "2023-11-03T15:32:00+00:00" }, { "name": "php-http/discovery", @@ -1672,31 +1673,26 @@ }, { "name": "php-http/promise", - "version": "1.1.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/php-http/promise.git", - "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88" + "reference": "44a67cb59f708f826f3bec35f22030b3edb90119" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/promise/zipball/4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", - "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "url": "https://api.github.com/repos/php-http/promise/zipball/44a67cb59f708f826f3bec35f22030b3edb90119", + "reference": "44a67cb59f708f826f3bec35f22030b3edb90119", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "friends-of-phpspec/phpspec-code-coverage": "^4.3.2", - "phpspec/phpspec": "^5.1.2 || ^6.2" + "friends-of-phpspec/phpspec-code-coverage": "^4.3.2 || ^6.3", + "phpspec/phpspec": "^5.1.2 || ^6.2 || ^7.4" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, "autoload": { "psr-4": { "Http\\Promise\\": "src/" @@ -1723,9 +1719,9 @@ ], "support": { "issues": "https://github.com/php-http/promise/issues", - "source": "https://github.com/php-http/promise/tree/1.1.0" + "source": "https://github.com/php-http/promise/tree/1.2.1" }, - "time": "2020-07-07T09:29:14+00:00" + "time": "2023-11-08T12:57:08+00:00" }, { "name": "php-jsonpointer/php-jsonpointer", @@ -1833,16 +1829,16 @@ }, { "name": "psr/http-client", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { @@ -1879,9 +1875,9 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client/tree/1.0.2" + "source": "https://github.com/php-fig/http-client" }, - "time": "2023-04-10T20:12:12+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", @@ -2957,16 +2953,16 @@ }, { "name": "symfony/serializer", - "version": "v5.4.28", + "version": "v5.4.30", "source": { "type": "git", "url": "https://github.com/symfony/serializer.git", - "reference": "701e2b8d48a3a627ffe128b38fbe6c4cf3ddcb3c" + "reference": "ceadb4e08830e69738d313b667cfb426269f67f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/serializer/zipball/701e2b8d48a3a627ffe128b38fbe6c4cf3ddcb3c", - "reference": "701e2b8d48a3a627ffe128b38fbe6c4cf3ddcb3c", + "url": "https://api.github.com/repos/symfony/serializer/zipball/ceadb4e08830e69738d313b667cfb426269f67f6", + "reference": "ceadb4e08830e69738d313b667cfb426269f67f6", "shasum": "" }, "require": { @@ -3040,7 +3036,7 @@ "description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/serializer/tree/v5.4.28" + "source": "https://github.com/symfony/serializer/tree/v5.4.30" }, "funding": [ { @@ -3056,7 +3052,7 @@ "type": "tidelift" } ], - "time": "2023-08-24T14:14:18+00:00" + "time": "2023-10-25T18:53:19+00:00" }, { "name": "symfony/service-contracts", @@ -3143,16 +3139,16 @@ }, { "name": "symfony/string", - "version": "v5.4.26", + "version": "v5.4.29", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "1181fe9270e373537475e826873b5867b863883c" + "reference": "e41bdc93def20eaf3bfc1537c4e0a2b0680a152d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/1181fe9270e373537475e826873b5867b863883c", - "reference": "1181fe9270e373537475e826873b5867b863883c", + "url": "https://api.github.com/repos/symfony/string/zipball/e41bdc93def20eaf3bfc1537c4e0a2b0680a152d", + "reference": "e41bdc93def20eaf3bfc1537c4e0a2b0680a152d", "shasum": "" }, "require": { @@ -3209,7 +3205,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.26" + "source": "https://github.com/symfony/string/tree/v5.4.29" }, "funding": [ { @@ -3225,7 +3221,7 @@ "type": "tidelift" } ], - "time": "2023-06-28T12:46:07+00:00" + "time": "2023-09-13T11:47:41+00:00" }, { "name": "symfony/translation-contracts", @@ -3307,16 +3303,16 @@ }, { "name": "symfony/validator", - "version": "v5.4.28", + "version": "v5.4.30", "source": { "type": "git", "url": "https://github.com/symfony/validator.git", - "reference": "0acdcb86a8fc5ffd71c3b060184d2ed20a76a2c9" + "reference": "ce65d7802d78e43d46669bfa08521bf6104880f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/validator/zipball/0acdcb86a8fc5ffd71c3b060184d2ed20a76a2c9", - "reference": "0acdcb86a8fc5ffd71c3b060184d2ed20a76a2c9", + "url": "https://api.github.com/repos/symfony/validator/zipball/ce65d7802d78e43d46669bfa08521bf6104880f0", + "reference": "ce65d7802d78e43d46669bfa08521bf6104880f0", "shasum": "" }, "require": { @@ -3399,7 +3395,7 @@ "description": "Provides tools to validate values", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/validator/tree/v5.4.28" + "source": "https://github.com/symfony/validator/tree/v5.4.30" }, "funding": [ { @@ -3415,20 +3411,20 @@ "type": "tidelift" } ], - "time": "2023-08-14T13:04:17+00:00" + "time": "2023-10-27T07:38:31+00:00" }, { "name": "symfony/var-dumper", - "version": "v5.4.28", + "version": "v5.4.29", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "684b36ff415e1381d4a943c3ca2502cd2debad73" + "reference": "6172e4ae3534d25ee9e07eb487c20be7760fcc65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/684b36ff415e1381d4a943c3ca2502cd2debad73", - "reference": "684b36ff415e1381d4a943c3ca2502cd2debad73", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/6172e4ae3534d25ee9e07eb487c20be7760fcc65", + "reference": "6172e4ae3534d25ee9e07eb487c20be7760fcc65", "shasum": "" }, "require": { @@ -3488,7 +3484,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.4.28" + "source": "https://github.com/symfony/var-dumper/tree/v5.4.29" }, "funding": [ { @@ -3504,20 +3500,20 @@ "type": "tidelift" } ], - "time": "2023-08-24T13:38:36+00:00" + "time": "2023-09-12T10:09:58+00:00" }, { "name": "symfony/yaml", - "version": "v5.4.23", + "version": "v5.4.30", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "4cd2e3ea301aadd76a4172756296fe552fb45b0b" + "reference": "c6980e82a6656f6ebfabfd82f7585794cb122554" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/4cd2e3ea301aadd76a4172756296fe552fb45b0b", - "reference": "4cd2e3ea301aadd76a4172756296fe552fb45b0b", + "url": "https://api.github.com/repos/symfony/yaml/zipball/c6980e82a6656f6ebfabfd82f7585794cb122554", + "reference": "c6980e82a6656f6ebfabfd82f7585794cb122554", "shasum": "" }, "require": { @@ -3563,7 +3559,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.4.23" + "source": "https://github.com/symfony/yaml/tree/v5.4.30" }, "funding": [ { @@ -3579,22 +3575,22 @@ "type": "tidelift" } ], - "time": "2023-04-23T19:33:36+00:00" + "time": "2023-10-27T18:36:14+00:00" } ], "packages-dev": [ { "name": "doctrine/deprecations", - "version": "v1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -3626,9 +3622,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + "source": "https://github.com/doctrine/deprecations/tree/1.1.2" }, - "time": "2023-06-03T09:27:29+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "doctrine/instantiator", @@ -4284,16 +4280,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.23.1", + "version": "1.24.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26" + "reference": "bcad8d995980440892759db0c32acae7c8e79442" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", + "reference": "bcad8d995980440892759db0c32acae7c8e79442", "shasum": "" }, "require": { @@ -4325,9 +4321,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" }, - "time": "2023-08-03T16:32:59+00:00" + "time": "2023-09-26T12:28:12+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4714,12 +4710,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "9160fb2612003a99a28abbd588519d5ab3a77024" + "reference": "c94f18868ecd2096eb16794d766a6371f42a846c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/9160fb2612003a99a28abbd588519d5ab3a77024", - "reference": "9160fb2612003a99a28abbd588519d5ab3a77024", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/c94f18868ecd2096eb16794d766a6371f42a846c", + "reference": "c94f18868ecd2096eb16794d766a6371f42a846c", "shasum": "" }, "conflict": { @@ -4739,6 +4735,7 @@ "anchorcms/anchor-cms": "<=0.12.7", "andreapollastri/cipi": "<=3.1.15", "andrewhaine/silverstripe-form-capture": ">=0.2,<=0.2.3|>=1,<1.0.2|>=2,<2.2.5", + "apache-solr-for-typo3/solr": "<2.8.3", "apereo/phpcas": "<1.6", "api-platform/core": ">=2.2,<2.2.10|>=2.3,<2.3.6|>=2.6,<2.7.10|>=3,<3.0.12|>=3.1,<3.1.3", "appwrite/server-ce": "<=1.2.1", @@ -4755,13 +4752,14 @@ "azuracast/azuracast": "<0.18.3", "backdrop/backdrop": "<1.24.2", "backpack/crud": "<3.4.9", + "bacula-web/bacula-web": "<8.0.0.0-RC2-dev", "badaso/core": "<2.7", "bagisto/bagisto": "<0.1.5", "barrelstrength/sprout-base-email": "<1.2.7", "barrelstrength/sprout-forms": "<3.9", "barryvdh/laravel-translation-manager": "<0.6.2", "barzahlen/barzahlen-php": "<2.0.1", - "baserproject/basercms": "<4.7.5", + "baserproject/basercms": "<4.8", "bassjobsen/bootstrap-3-typeahead": ">4.0.2", "bigfork/silverstripe-form-capture": ">=3,<3.1.1", "billz/raspap-webgui": "<=2.9.2", @@ -4775,7 +4773,7 @@ "brotkrueml/schema": "<1.13.1|>=2,<2.5.1", "brotkrueml/typo3-matomo-integration": "<1.3.2", "buddypress/buddypress": "<7.2.1", - "bugsnag/bugsnag-laravel": ">=2,<2.0.2", + "bugsnag/bugsnag-laravel": "<2.0.2", "bytefury/crater": "<6.0.2", "cachethq/cachet": "<2.5.1", "cakephp/cakephp": "<3.10.3|>=4,<4.0.10|>=4.1,<4.1.4|>=4.2,<4.2.12|>=4.3,<4.3.11|>=4.4,<4.4.10", @@ -4785,17 +4783,19 @@ "cart2quote/module-quotation": ">=4.1.6,<=4.4.5|>=5,<5.4.4", "cartalyst/sentry": "<=2.1.6", "catfan/medoo": "<1.7.5", + "cecil/cecil": "<7.47.1", "centreon/centreon": "<22.10.0.0-beta1", "cesnet/simplesamlphp-module-proxystatistics": "<3.1", "chriskacerguis/codeigniter-restserver": "<=2.7.1", + "civicrm/civicrm-core": ">=4.2,<4.2.9|>=4.3,<4.3.3", "cockpit-hq/cockpit": "<=2.6.3", "codeception/codeception": "<3.1.3|>=4,<4.1.22", "codeigniter/framework": "<3.1.9", - "codeigniter4/framework": "<4.3.5", + "codeigniter4/framework": "<=4.4.2", "codeigniter4/shield": "<1.0.0.0-beta4", "codiad/codiad": "<=2.8.4", - "composer/composer": "<1.10.26|>=2,<2.2.12|>=2.3,<2.3.5", - "concrete5/concrete5": "<9.2", + "composer/composer": "<1.10.27|>=2,<2.2.22|>=2.3,<2.6.4", + "concrete5/concrete5": "<=9.2.1", "concrete5/core": "<8.5.8|>=9,<9.1", "contao-components/mediaelement": ">=2.14.2,<2.21.1", "contao/contao": ">=4,<4.4.56|>=4.5,<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4", @@ -4810,6 +4810,7 @@ "czproject/git-php": "<4.0.3", "darylldoyle/safe-svg": "<1.9.10", "datadog/dd-trace": ">=0.30,<0.30.2", + "datatables/datatables": "<1.10.10", "david-garcia/phpwhois": "<=4.3.1", "dbrisinajumi/d2files": "<1", "dcat/laravel-admin": "<=2.1.3.0-beta", @@ -4817,18 +4818,18 @@ "derhansen/sf_event_mgt": "<4.3.1|>=5,<5.1.1", "desperado/xml-bundle": "<=0.1.7", "directmailteam/direct-mail": "<5.2.4", - "doctrine/annotations": ">=1,<1.2.7", - "doctrine/cache": ">=1,<1.3.2|>=1.4,<1.4.2", - "doctrine/common": ">=2,<2.4.3|>=2.5,<2.5.1", + "doctrine/annotations": "<1.2.7", + "doctrine/cache": "<1.3.2|>=1.4,<1.4.2", + "doctrine/common": "<2.4.3|>=2.5,<2.5.1", "doctrine/dbal": ">=2,<2.0.8|>=2.1,<2.1.2|>=3,<3.1.4", "doctrine/doctrine-bundle": "<1.5.2", "doctrine/doctrine-module": "<=0.7.1", - "doctrine/mongodb-odm": ">=1,<1.0.2", - "doctrine/mongodb-odm-bundle": ">=2,<3.0.1", + "doctrine/mongodb-odm": "<1.0.2", + "doctrine/mongodb-odm-bundle": "<3.0.1", "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1|>=2.8.3,<2.8.4", - "dolibarr/dolibarr": "<17.0.1", + "dolibarr/dolibarr": "<18.0.2", "dompdf/dompdf": "<2.0.2|==2.0.2", - "drupal/core": ">=7,<7.96|>=8,<9.4.14|>=9.5,<9.5.8|>=10,<10.0.8", + "drupal/core": "<9.4.14|>=9.5,<9.5.8|>=10,<10.0.8", "drupal/drupal": ">=6,<6.38|>=7,<7.80|>=8,<8.9.16|>=9,<9.1.12|>=9.2,<9.2.4", "dweeves/magmi": "<=0.7.24", "ecodev/newsletter": "<=4", @@ -4840,6 +4841,7 @@ "enshrined/svg-sanitize": "<0.15", "erusev/parsedown": "<1.7.2", "ether/logs": "<3.0.4", + "evolutioncms/evolution": "<=3.2.3", "exceedone/exment": "<4.4.3|>=5,<5.0.3", "exceedone/laravel-admin": "<2.2.3|==3", "ezsystems/demobundle": ">=5.4,<5.4.6.1-dev", @@ -4850,12 +4852,13 @@ "ezsystems/ezplatform-admin-ui": ">=1.3,<1.3.5|>=1.4,<1.4.6|>=1.5,<1.5.29|>=2.3,<2.3.26", "ezsystems/ezplatform-admin-ui-assets": ">=4,<4.2.1|>=5,<5.0.1|>=5.1,<5.1.1", "ezsystems/ezplatform-graphql": ">=1.0.0.0-RC1-dev,<1.0.13|>=2.0.0.0-beta1,<2.3.12", - "ezsystems/ezplatform-kernel": "<1.2.5.1-dev|>=1.3,<1.3.26", + "ezsystems/ezplatform-kernel": "<1.2.5.1-dev|>=1.3,<1.3.34", "ezsystems/ezplatform-rest": ">=1.2,<=1.2.2|>=1.3,<1.3.8", "ezsystems/ezplatform-richtext": ">=2.3,<2.3.7.1-dev", + "ezsystems/ezplatform-solr-search-engine": ">=1.7,<1.7.12|>=2,<2.0.2|>=3.3,<3.3.15", "ezsystems/ezplatform-user": ">=1,<1.0.1", - "ezsystems/ezpublish-kernel": "<6.13.8.2-dev|>=7,<7.5.30", - "ezsystems/ezpublish-legacy": "<=2017.12.7.3|>=2018.06,<=2019.03.5.1", + "ezsystems/ezpublish-kernel": "<6.13.8.2-dev|>=7,<7.5.31", + "ezsystems/ezpublish-legacy": "<=2017.12.7.3|>=2018.6,<=2019.03.5.1", "ezsystems/platform-ui-assets-bundle": ">=4.2,<4.2.3", "ezsystems/repository-forms": ">=2.3,<2.3.2.1-dev|>=2.5,<2.5.15", "ezyang/htmlpurifier": "<4.1.1", @@ -4873,9 +4876,11 @@ "flarum/mentions": "<1.6.3", "flarum/sticky": ">=0.1.0.0-beta14,<=0.1.0.0-beta15", "flarum/tags": "<=0.1.0.0-beta13", + "floriangaerber/magnesium": "<0.3.1", "fluidtypo3/vhs": "<5.1.1", "fof/byobu": ">=0.3.0.0-beta2,<1.1.7", "fof/upload": "<1.2.3", + "foodcoopshop/foodcoopshop": ">=3.2,<3.6.1", "fooman/tcpdf": "<6.2.22", "forkcms/forkcms": "<5.11.1", "fossar/tcpdf-parser": "<6.2.22", @@ -4885,7 +4890,8 @@ "friendsofsymfony/rest-bundle": ">=1.2,<1.2.2", "friendsofsymfony/user-bundle": ">=1.2,<1.3.5", "friendsoftypo3/mediace": ">=7.6.2,<7.6.5", - "froala/wysiwyg-editor": "<3.2.7", + "friendsoftypo3/openid": ">=4.5,<4.5.31|>=4.7,<4.7.16|>=6,<6.0.11|>=6.1,<6.1.6", + "froala/wysiwyg-editor": "<3.2.7|>=4.0.1,<=4.1.1", "froxlor/froxlor": "<2.1", "fuel/core": "<1.8.1", "funadmin/funadmin": "<=3.2|>=3.3.2,<=3.3.3", @@ -4897,7 +4903,7 @@ "getkirby/panel": "<2.5.14", "getkirby/starterkit": "<=3.7.0.2", "gilacms/gila": "<=1.11.4", - "gleez/cms": "<=1.2", + "gleez/cms": "<=1.2|==2", "globalpayments/php-sdk": "<2", "gogentooss/samlbase": "<1.2.7", "google/protobuf": "<3.15", @@ -4905,6 +4911,7 @@ "gree/jose": "<2.2.1", "gregwar/rst": "<1.0.3", "grumpydictator/firefly-iii": "<6", + "gugoan/economizzer": "<=0.9.0.0-beta1", "guzzlehttp/guzzle": "<6.5.8|>=7,<7.4.5", "guzzlehttp/psr7": "<1.9.1|>=2,<2.4.5", "haffner/jh_captcha": "<=2.1.3|>=3,<=3.0.2", @@ -4918,9 +4925,10 @@ "httpsoft/http-message": "<1.0.12", "hyn/multi-tenant": ">=5.6,<5.7.2", "ibexa/admin-ui": ">=4.2,<4.2.3", - "ibexa/core": ">=4,<4.0.7|>=4.1,<4.1.4|>=4.2,<4.2.3", + "ibexa/core": ">=4,<4.0.7|>=4.1,<4.1.4|>=4.2,<4.2.3|>=4.5,<4.5.4", "ibexa/graphql": ">=2.5,<2.5.31|>=3.3,<3.3.28|>=4.2,<4.2.3", "ibexa/post-install": "<=1.0.4", + "ibexa/solr": ">=4.5,<4.5.4", "ibexa/user": ">=4,<4.4.3", "icecoder/icecoder": "<=8.1", "idno/known": "<=1.3.1", @@ -4930,23 +4938,25 @@ "illuminate/encryption": ">=4,<=4.0.11|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.40|>=5.6,<5.6.15", "illuminate/view": "<6.20.42|>=7,<7.30.6|>=8,<8.75", "impresscms/impresscms": "<=1.4.5", - "in2code/femanager": "<5.5.3|>=6,<6.3.4|>=7,<7.1", + "in2code/femanager": "<5.5.3|>=6,<6.3.4|>=7,<7.2.2", "in2code/ipandlanguageredirect": "<5.1.2", "in2code/lux": "<17.6.1|>=18,<24.0.2", "innologi/typo3-appointments": "<2.0.6", - "intelliants/subrion": "<=4.2.1", + "intelliants/subrion": "<4.2.2", "islandora/islandora": ">=2,<2.4.1", "ivankristianto/phpwhois": "<=4.3", "jackalope/jackalope-doctrine-dbal": "<1.7.4", "james-heinrich/getid3": "<1.9.21", + "james-heinrich/phpthumb": "<1.7.12", "jasig/phpcas": "<1.3.3", "jcbrand/converse.js": "<3.3.3", + "joomla/application": "<1.0.13", "joomla/archive": "<1.1.12|>=2,<2.0.1", "joomla/filesystem": "<1.6.2|>=2,<2.0.1", "joomla/filter": "<1.4.4|>=2,<2.0.1", "joomla/framework": ">=2.5.4,<=3.8.12", "joomla/input": ">=2,<2.0.2", - "joomla/joomla-cms": "<3.9.12", + "joomla/joomla-cms": ">=2.5,<3.9.12", "joomla/session": "<1.3.1", "joyqi/hyper-down": "<=2.4.27", "jsdecena/laracom": "<2.0.9", @@ -4955,10 +4965,10 @@ "kelvinmo/simplexrd": "<3.1.1", "kevinpapst/kimai2": "<1.16.7", "khodakhah/nodcms": "<=3", - "kimai/kimai": "<1.1", + "kimai/kimai": "<=2.1", "kitodo/presentation": "<3.2.3|>=3.3,<3.3.4", "klaviyo/magento2-extension": ">=1,<3", - "knplabs/knp-snappy": "<1.4.2", + "knplabs/knp-snappy": "<=1.4.2", "kohana/core": "<3.3.3", "krayin/laravel-crm": "<1.2.2", "kreait/firebase-php": ">=3.2,<3.8.1", @@ -4989,7 +4999,7 @@ "magento/magento1ee": ">=1,<1.14.4.3-dev", "magento/product-community-edition": ">=2,<2.2.10|>=2.3,<2.3.2.0-patch2", "maikuolan/phpmussel": ">=1,<1.6", - "mantisbt/mantisbt": "<=2.25.5", + "mantisbt/mantisbt": "<=2.25.7", "marcwillmann/turn": "<0.3.3", "matyhtf/framework": "<3.0.6", "mautic/core": "<4.3", @@ -5000,14 +5010,16 @@ "melisplatform/melis-front": "<5.0.1", "mezzio/mezzio-swoole": "<3.7|>=4,<4.3", "mgallegos/laravel-jqgrid": "<=1.3", - "microweber/microweber": "<=1.3.4", + "microweber/microweber": "<2.0.3", "miniorange/miniorange-saml": "<1.4.3", "mittwald/typo3_forum": "<1.2.1", "mobiledetect/mobiledetectlib": "<2.8.32", "modx/revolution": "<=2.8.3.0-patch", "mojo42/jirafeau": "<4.4", + "mongodb/mongodb": ">=1,<1.9.2", "monolog/monolog": ">=1.8,<1.12", "moodle/moodle": "<4.2.0.0-RC2-dev|==4.2", + "mos/cimage": "<0.7.19", "movim/moxl": ">=0.8,<=0.10", "mpdf/mpdf": "<=7.1.7", "mustache/mustache": ">=2,<2.14.1", @@ -5017,11 +5029,13 @@ "neos/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.12|>=3.1,<3.1.10|>=3.2,<3.2.13|>=3.3,<3.3.13|>=4,<4.0.6", "neos/form": ">=1.2,<4.3.3|>=5,<5.0.9|>=5.1,<5.1.3", "neos/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4|>=2.3,<2.9.99|>=3,<3.0.20|>=3.1,<3.1.18|>=3.2,<3.2.14|>=3.3,<5.3.10|>=7,<7.0.9|>=7.1,<7.1.7|>=7.2,<7.2.6|>=7.3,<7.3.4|>=8,<8.0.2", + "neos/neos-ui": "<=8.3.3", "neos/swiftmailer": ">=4.1,<4.1.99|>=5.4,<5.4.5", "netgen/tagsbundle": ">=3.4,<3.4.11|>=4,<4.0.15", "nette/application": ">=2,<2.0.19|>=2.1,<2.1.13|>=2.2,<2.2.10|>=2.3,<2.3.14|>=2.4,<2.4.16|>=3,<3.0.6", "nette/nette": ">=2,<2.0.19|>=2.1,<2.1.13", "nilsteampassnet/teampass": "<3.0.10", + "nonfiction/nterchange": "<4.1.1", "notrinos/notrinos-erp": "<=0.7", "noumo/easyii": "<=0.9", "nukeviet/nukeviet": "<4.5.02", @@ -5033,15 +5047,16 @@ "october/october": "<=3.4.4", "october/rain": "<1.0.472|>=1.1,<1.1.2", "october/system": "<1.0.476|>=1.1,<1.1.12|>=2,<2.2.34|>=3,<3.0.66", + "omeka/omeka-s": "<4.0.3", "onelogin/php-saml": "<2.10.4", "oneup/uploader-bundle": "<1.9.3|>=2,<2.1.5", "open-web-analytics/open-web-analytics": "<1.7.4", - "opencart/opencart": "<=3.0.3.7", + "opencart/opencart": "<=3.0.3.7|>=4,<4.0.2.3-dev", "openid/php-openid": "<2.3", - "openmage/magento-lts": "<19.4.22|>=20,<20.0.19", + "openmage/magento-lts": "<=19.5|>=20,<=20.1", "opensource-workshop/connect-cms": "<1.7.2|>=2,<2.3.2", "orchid/platform": ">=9,<9.4.4|>=14.0.0.0-alpha4,<14.5", - "oro/commerce": ">=4.1,<5.0.6", + "oro/commerce": ">=4.1,<5.0.11|>=5.1,<5.1.1", "oro/crm": ">=1.7,<1.7.4|>=3.1,<4.1.17|>=4.2,<4.2.7", "oro/platform": ">=1.7,<1.7.4|>=3.1,<3.1.29|>=4.1,<4.1.17|>=4.2,<4.2.8", "oxid-esales/oxideshop-ce": "<4.5", @@ -5075,20 +5090,22 @@ "phpxmlrpc/extras": "<0.6.1", "phpxmlrpc/phpxmlrpc": "<4.9.2", "pi/pi": "<=2.5", - "pimcore/admin-ui-classic-bundle": "<1.0.3", + "pimcore/admin-ui-classic-bundle": "<1.2", "pimcore/customer-management-framework-bundle": "<3.4.2", "pimcore/data-hub": "<1.2.4", + "pimcore/demo": "<10.3", "pimcore/perspective-editor": "<1.5.1", - "pimcore/pimcore": "<10.6.8", + "pimcore/pimcore": "<11.1", "pixelfed/pixelfed": "<=0.11.4", "pocketmine/bedrock-protocol": "<8.0.2", - "pocketmine/pocketmine-mp": "<4.22.3|>=5,<5.2.1", + "pocketmine/pocketmine-mp": "<=4.23|>=5,<5.3.1", "pressbooks/pressbooks": "<5.18", "prestashop/autoupgrade": ">=4,<4.10.1", + "prestashop/blockreassurance": "<=5.1.3", "prestashop/blockwishlist": ">=2,<2.1.1", "prestashop/contactform": ">=1.0.1,<4.3", "prestashop/gamification": "<2.3.2", - "prestashop/prestashop": "<=8.1", + "prestashop/prestashop": "<8.1.2", "prestashop/productcomments": "<5.0.2", "prestashop/ps_emailsubscription": "<2.6.1", "prestashop/ps_facetedsearch": "<3.4.1", @@ -5098,11 +5115,12 @@ "propel/propel": ">=2.0.0.0-alpha1,<=2.0.0.0-alpha7", "propel/propel1": ">=1,<=1.7.1", "pterodactyl/panel": "<1.7", - "ptheofan/yii2-statemachine": ">=2", + "ptheofan/yii2-statemachine": ">=2.0.0.0-RC1-dev,<=2", "ptrofimov/beanstalk_console": "<1.7.14", "pusher/pusher-php-server": "<2.2.1", "pwweb/laravel-core": "<=0.3.6.0-beta", "pyrocms/pyrocms": "<=3.9.1", + "rainlab/blog-plugin": "<1.4.1", "rainlab/debugbar-plugin": "<3.1", "rainlab/user-plugin": "<=1.4.5", "rankmath/seo-by-rank-math": "<=1.0.95", @@ -5137,7 +5155,7 @@ "silverstripe/comments": ">=1.3,<1.9.99|>=2,<2.9.99|>=3,<3.1.1", "silverstripe/forum": "<=0.6.1|>=0.7,<=0.7.3", "silverstripe/framework": "<4.13.14|>=5,<5.0.13", - "silverstripe/graphql": "<3.5.2|>=4.0.0.0-alpha1,<4.0.0.0-alpha2|>=4.1.1,<4.1.2|>=4.2.2,<4.2.3", + "silverstripe/graphql": "<3.8.2|>=4,<4.1.3|>=4.2,<4.2.5|>=4.3,<4.3.4|>=5,<5.0.3", "silverstripe/hybridsessions": ">=1,<2.4.1|>=2.5,<2.5.1", "silverstripe/recipe-cms": ">=4.5,<4.5.3", "silverstripe/registry": ">=2.1,<2.1.2|>=2.2,<2.2.1", @@ -5155,16 +5173,16 @@ "simplesamlphp/simplesamlphp-module-openidprovider": "<0.9", "simplito/elliptic-php": "<1.0.6", "sitegeist/fluid-components": "<3.5", - "sjbr/sr-freecap": "<=2.5.2", + "sjbr/sr-freecap": "<2.4.6|>=2.5,<2.5.3", "slim/psr7": "<1.4.1|>=1.5,<1.5.1|>=1.6,<1.6.1", "slim/slim": "<2.6", "slub/slub-events": "<3.0.3", "smarty/smarty": "<3.1.48|>=4,<4.3.1", - "snipe/snipe-it": "<=6.0.14", + "snipe/snipe-it": "<=6.2.2", "socalnick/scn-social-auth": "<1.15.2", "socialiteproviders/steam": "<1.1", "spatie/browsershot": "<3.57.4", - "spipu/html2pdf": "<5.2.4", + "spipu/html2pdf": "<5.2.8", "spoon/library": "<1.4.1", "spoonity/tcpdf": "<6.2.22", "squizlabs/php_codesniffer": ">=1,<2.8.1|>=3,<3.0.1", @@ -5173,7 +5191,6 @@ "stormpath/sdk": "<9.9.99", "studio-42/elfinder": "<2.1.62", "subhh/libconnect": "<7.0.8|>=8,<8.1", - "subrion/cms": "<=4.2.1", "sukohi/surpass": "<1", "sulu/sulu": "<1.6.44|>=2,<2.2.18|>=2.3,<2.3.8|==2.4.0.0-RC1|>=2.5,<2.5.10", "sumocoders/framework-user-bundle": "<1.4", @@ -5214,6 +5231,7 @@ "symfony/serializer": ">=2,<2.0.11|>=4.1,<4.4.35|>=5,<5.3.12", "symfony/symfony": "<4.4.50|>=5,<5.4.20|>=6,<6.0.20|>=6.1,<6.1.12|>=6.2,<6.2.6", "symfony/translation": ">=2,<2.0.17", + "symfony/ux-autocomplete": "<2.11.2", "symfony/validator": ">=2,<2.0.24|>=2.1,<2.1.12|>=2.2,<2.2.5|>=2.3,<2.3.3", "symfony/var-exporter": ">=4.2,<4.2.12|>=4.3,<4.3.8", "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", @@ -5228,9 +5246,9 @@ "thelia/thelia": ">=2.1,<2.1.3", "theonedemon/phpwhois": "<=4.2.5", "thinkcmf/thinkcmf": "<=5.1.7", - "thorsten/phpmyfaq": "<3.2.0.0-beta2", + "thorsten/phpmyfaq": "<3.2.2", "tikiwiki/tiki-manager": "<=17.1", - "tinymce/tinymce": "<5.10.7|>=6,<6.3.1", + "tinymce/tinymce": "<5.10.8|>=6,<6.7.1", "tinymighty/wiki-seo": "<1.2.2", "titon/framework": "<9.9.99", "tobiasbg/tablepress": "<=2.0.0.0-RC1", @@ -5238,11 +5256,11 @@ "topthink/think": "<=6.1.1", "topthink/thinkphp": "<=3.2.3", "tpwd/ke_search": "<4.0.3|>=4.1,<4.6.6|>=5,<5.0.2", - "tribalsystems/zenario": "<=9.3.57595", + "tribalsystems/zenario": "<=9.4.59197", "truckersmp/phpwhois": "<=4.3.1", "ttskch/pagination-service-provider": "<1", "twig/twig": "<1.44.7|>=2,<2.15.3|>=3,<3.4.3", - "typo3/cms": "<8.7.38|>=9,<9.5.29|>=10,<10.4.35|>=11,<11.5.23|>=12,<12.2", + "typo3/cms": "<9.5.29|>=10,<10.4.35|>=11,<11.5.23|>=12,<12.2", "typo3/cms-backend": ">=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", "typo3/cms-core": "<8.7.51|>=9,<9.5.42|>=10,<10.4.39|>=11,<11.5.30|>=12,<12.4.4", "typo3/cms-extbase": "<6.2.24|>=7,<7.6.8|==8.1.1", @@ -5255,6 +5273,7 @@ "typo3/swiftmailer": ">=4.1,<4.1.99|>=5.4,<5.4.5", "typo3fluid/fluid": ">=2,<2.0.8|>=2.1,<2.1.7|>=2.2,<2.2.4|>=2.3,<2.3.7|>=2.4,<2.4.4|>=2.5,<2.5.11|>=2.6,<2.6.10", "ua-parser/uap-php": "<3.8", + "uasoft-indonesia/badaso": "<=2.9.7", "unisharp/laravel-filemanager": "<=2.5.1", "userfrosting/userfrosting": ">=0.3.1,<4.6.3", "usmanhalalit/pixie": "<1.0.3|>=2,<2.0.2", @@ -5265,7 +5284,7 @@ "vrana/adminer": "<4.8.1", "waldhacker/hcaptcha": "<2.1.2", "wallabag/tcpdf": "<6.2.22", - "wallabag/wallabag": "<=2.6.2", + "wallabag/wallabag": "<2.6.7", "wanglelecc/laracms": "<=1.0.3", "web-auth/webauthn-framework": ">=3.3,<3.3.4", "webbuilders-group/silverstripe-kapost-bridge": "<0.4", @@ -5302,7 +5321,7 @@ "yourls/yourls": "<=1.8.2", "zencart/zencart": "<=1.5.7.0-beta", "zendesk/zendesk_api_client_php": "<2.2.11", - "zendframework/zend-cache": ">=2.4,<2.4.8|>=2.5,<2.5.3", + "zendframework/zend-cache": "<2.4.8|>=2.5,<2.5.3", "zendframework/zend-captcha": ">=2,<2.4.9|>=2.5,<2.5.2", "zendframework/zend-crypt": ">=2,<2.4.9|>=2.5,<2.5.2", "zendframework/zend-db": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.10|>=2.3,<2.3.5", @@ -5321,12 +5340,20 @@ "zendframework/zend-xmlrpc": ">=2.1,<2.1.6|>=2.2,<2.2.6", "zendframework/zendframework": "<=3", "zendframework/zendframework1": "<1.12.20", - "zendframework/zendopenid": ">=2,<2.0.2", + "zendframework/zendopenid": "<2.0.2", + "zendframework/zendrest": "<2.0.2", + "zendframework/zendservice-amazon": "<2.0.3", + "zendframework/zendservice-api": "<1", + "zendframework/zendservice-audioscrobbler": "<2.0.2", + "zendframework/zendservice-nirvanix": "<2.0.2", + "zendframework/zendservice-slideshare": "<2.0.2", + "zendframework/zendservice-technorati": "<2.0.2", + "zendframework/zendservice-windowsazure": "<2.0.2", "zendframework/zendxml": "<1.0.1", "zenstruck/collection": "<0.2.1", "zetacomponents/mail": "<1.8.2", "zf-commons/zfc-user": "<1.2.2", - "zfcampus/zf-apigility-doctrine": ">=1,<1.0.3", + "zfcampus/zf-apigility-doctrine": "<1.0.3", "zfr/zfr-oauth2-server-module": "<0.1.2", "zoujingli/thinkadmin": "<6.0.22" }, @@ -5366,7 +5393,7 @@ "type": "tidelift" } ], - "time": "2023-08-23T09:04:12+00:00" + "time": "2023-11-08T20:04:29+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", diff --git a/src/modules/mo/mo_dhl/Adapter/DHLAdapter.php b/src/modules/mo/mo_dhl/Adapter/DHLAdapter.php index 0efc230b..551a1b06 100644 --- a/src/modules/mo/mo_dhl/Adapter/DHLAdapter.php +++ b/src/modules/mo/mo_dhl/Adapter/DHLAdapter.php @@ -220,11 +220,11 @@ public function buildParcelShipping() /** - * @return \Mediaopt\DHL\Api\Authentication\Client + * @return \Mediaopt\DHL\Api\MyAccount\Client */ - public function buildAuthentication() + public function buildMyAccount() { - return $this->getSdk()->buildAuthentication(); + return $this->getSdk()->buildMyAccount(); } /** diff --git a/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php b/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php index 73717626..75f197e4 100644 --- a/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php +++ b/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php @@ -66,6 +66,14 @@ class DHLConfigurator extends \Mediaopt\DHL\Configurator const TEST_STANDORTSUCHE_API_PASSWORD = 'kAPjq3yHFgY6QD3sHEtv61dQCAgoXLyK'; + const TEST_AUTHENTICATION_CLIENT_ID = 'kAPjq3yHFgY6QD3sHEtv61dQCAgoXLyK'; + + const TEST_AUTHENTICATION_CLIENT_SECRET = 'YdZnAljhgbcOXOKD'; + + const TEST_AUTHENTICATION_USERNAME = 'user-valid'; + + const TEST_AUTHENTICATION_PASSWORD = 'SandboxPasswort2023!'; + /** * @return mixed */ @@ -179,6 +187,47 @@ protected function getCustomerParcelShippingPassword() : self::TEST_PARCEL_SHIPPING_PASSWORD; } + /** + * @return string + */ + protected function getAuthenticationClientId() + { + return $this->isProductionEnvironment() + ? (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('mo_dhl__authentication_client_id') ?: '') + : self::TEST_AUTHENTICATION_CLIENT_ID; + } + + + /** + * @return string + */ + protected function getAuthenticationClientSecret() + { + return $this->isProductionEnvironment() + ? (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('mo_dhl__authentication_client_secret') ?: '') + : self::TEST_AUTHENTICATION_CLIENT_SECRET; + } + + /** + * @return string + */ + protected function getAuthenticationUsername() + { + return $this->isProductionEnvironment() + ? (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('mo_dhl__account_user') ?: '') + : self::TEST_AUTHENTICATION_USERNAME; + } + + /** + * @return string + */ + protected function getAuthenticationPassword() + { + return $this->isProductionEnvironment() + ? (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('mo_dhl__account_password') ?: '') + : self::TEST_AUTHENTICATION_PASSWORD; + } + /** * @return string */ diff --git a/src/modules/mo/mo_dhl/Api/Authentication.php b/src/modules/mo/mo_dhl/Api/Authentication.php new file mode 100644 index 00000000..43fac759 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/Authentication.php @@ -0,0 +1,29 @@ +setClientId($credentials->getUsername()); + $tokenPostBody->setClientSecret($credentials->getPassword()); + $tokenPostBody->setUsername($userPass->getUsername()); + $tokenPostBody->setPassword($userPass->getPassword()); + $tokenPostBody->setGrantType(self::DEFAULT_GRANT_TYPE); + + $token = $client->dispenseToken($tokenPostBody); + + return $token->getAccessToken(); + } +} diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php index d4204e9f..0df22e17 100644 --- a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php +++ b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php @@ -54,6 +54,8 @@ private function processEndpoint(Endpoint $endpoint) : ResponseInterface $queryString = $endpoint->getQueryString(); $uriGlue = false === strpos($endpoint->getUri(), '?') ? '?' : '&'; $uri = $queryString !== '' ? $endpoint->getUri() . $uriGlue . $queryString : $endpoint->getUri(); + //todo 34741 how to provide url here? + $uri = 'https://api-sandbox.dhl.com/parcel/de/account/auth/ropc/v1' . $uri; $request = $this->requestFactory->createRequest($endpoint->getMethod(), $uri); if ($body) { if ($body instanceof StreamInterface) { diff --git a/src/modules/mo/mo_dhl/Api/Credentials.php b/src/modules/mo/mo_dhl/Api/Credentials.php index 0de8b0e6..8039c104 100644 --- a/src/modules/mo/mo_dhl/Api/Credentials.php +++ b/src/modules/mo/mo_dhl/Api/Credentials.php @@ -188,6 +188,29 @@ public static function createProductionParcelShippingCredentials($username, $pas return new static('https://api-eu.dhl.com/parcel/de/shipping/v2', $username, $password, null, false, ['api-key' => $apiKey]); } + /** + * @param string $username + * @param string $password + * @param string $apiKey + * @return static + */ + public static function createProductionAuthenticationCredentials($clientId, $clientSecret) + { + //todo 34741 prod endpoint + return new static('', $clientId, $clientSecret, null, true); + } + + /** + * @param string $username + * @param string $password + * @param string $apiKey + * @return static + */ + public static function createSandboxAuthenticationCredentials($clientId, $clientSecret) + { + return new static('https://api-eu.dhl.com/parcel/de/account/auth/ropc/v1', $clientId, $clientSecret, null, false); + } + /** * @param string $username * @param string $password diff --git a/src/modules/mo/mo_dhl/Api/MyAccount.php b/src/modules/mo/mo_dhl/Api/MyAccount.php new file mode 100644 index 00000000..b355e5e2 --- /dev/null +++ b/src/modules/mo/mo_dhl/Api/MyAccount.php @@ -0,0 +1,39 @@ +logger = $logger; + } + + public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise + { + $context = [ + 'method' => $request->getMethod(), + 'url' => (string)$request->getUri(), + 'body' => $request->getBody()->getContents(), + ]; + $this->logger->debug('MyAccount Call', $context); + return $next($request); + } + }; + } +} diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php index d0909901..2ec986c2 100644 --- a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php @@ -38,6 +38,12 @@ public function __construct(ClientInterface $httpClient, RequestFactoryInterface } public function executeEndpoint(Endpoint $endpoint, string $fetch = self::FETCH_OBJECT) { + debug($endpoint->getUri()); + debug($endpoint->getQueryString()); + //debug($endpoint->getBody()); + debug($endpoint->getAuthenticationScopes()); + debug($endpoint->getHeaders()); + if (self::FETCH_RESPONSE === $fetch) { trigger_deprecation('jane-php/open-api-common', '7.3', 'Using %s::%s method with $fetch parameter equals to response is deprecated, use %s::%s instead.', __CLASS__, __METHOD__, __CLASS__, 'executeRawEndpoint'); return $this->executeRawEndpoint($endpoint); @@ -75,6 +81,7 @@ private function processEndpoint(Endpoint $endpoint) : ResponseInterface foreach ($endpoint->getAuthenticationScopes() as $scope) { $scopes[] = $scope; } + debug($scopes); $request = $request->withHeader(AuthenticationRegistry::SCOPES_HEADER, $scopes); } return $this->httpClient->sendRequest($request); diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/EndpointTrait.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/EndpointTrait.php index 9a04d1a0..fed5d1d2 100644 --- a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/EndpointTrait.php +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/EndpointTrait.php @@ -9,6 +9,7 @@ trait EndpointTrait protected abstract function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null); public function parseResponse(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) { + debug($response->getBody()->getContents()); $contentType = $response->hasHeader('Content-Type') ? current($response->getHeader('Content-Type')) : null; return $this->transformResponseBody($response, $serializer, $contentType); } diff --git a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php index 47527b24..2d98984e 100644 --- a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php +++ b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php @@ -9,6 +9,7 @@ */ use Mediaopt\DHL\Adapter\ParcelShippingConverter; +use Mediaopt\DHL\Api\Authentication\Model\TokenPostBody; use Mediaopt\DHL\Api\GKV; use Mediaopt\DHL\Api\GKV\CountryType; use Mediaopt\DHL\Api\GKV\NameType; @@ -202,6 +203,29 @@ public function moSaveAndCheckLogin() } + /** + */ + public function moAuthentication() + { + try { + $this->save(); + $adapter = new \Mediaopt\DHL\Adapter\DHLAdapter(); + $myAccount = $adapter->buildMyAccount(); + + $version = $myAccount->getVersion(); + $userData = $myAccount->getMyAggregatedUserData(['lang' => 'en']); + + debug($version); + debug($userData); + print_r($userData); + print_r($version); + //debug($version->getBody()); + + } catch (\Exception $e) { + $this->displayErrors($e); + } + } + /** */ public function moSaveAndCheckInternetmarkeLogin() diff --git a/src/modules/mo/mo_dhl/Application/views/admin/de/module_lang.php b/src/modules/mo/mo_dhl/Application/views/admin/de/module_lang.php index 6a0ea463..19c2e872 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/de/module_lang.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/de/module_lang.php @@ -38,6 +38,7 @@ 'MO_DHL__PAYMENTS_DHL' => 'DHL', 'MO_DHL__EXCLUDED' => 'Ausschließen', 'MO_DHL_SAVE_AND_CHECK' => 'Speichern und Zugangsdaten prüfen', + 'MO_DHL_AUTHENTICATION' => 'Speichern und Authentication prüfen', 'MO_DHL__NO_DELIVERYSET' => 'Bitte konfigurieren Sie mindestens eine Versandsart zur Nutzung der SHL Services', 'MO_DHL__CHECKING_DELIVERYSET' => 'Teste Versandart ', 'MO_DHL__CORRECT_CREDENTIALS' => 'Zugangsdaten korrekt', diff --git a/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php b/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php index e5701f6a..a8a4f24a 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php @@ -16,6 +16,12 @@ 'SHOP_MODULE_mo_dhl__merchant_ekp' => 'EKP', 'HELP_SHOP_MODULE_mo_dhl__merchant_ekp' => 'Die EKP ist Ihre DHL Kundennummer', + 'SHOP_MODULE_mo_dhl__authentication_client_id' => 'Client ID', + 'HELP_SHOP_MODULE_mo_dhl__authentication_client_id' => 'Ihr Client ID für der Account API.', + 'SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Client Secret', + 'HELP_SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Ihr Client Secret für der Account API.', + 'SHOP_MODULE_mo_dhl__authentication_check' => '', + 'SHOP_MODULE_GROUP_mo_dhl__portokasse' => 'Portokasse', 'SHOP_MODULE_mo_dhl__portokasse_user' => 'Portokasse Benutzername (für Internetmarke und Warenpost)', 'HELP_SHOP_MODULE_mo_dhl__portokasse_user' => 'Ihre E-Mail Adresse für die Portokasse. Noch kein Kunde? Dann registrieren Sie sich hier.', diff --git a/src/modules/mo/mo_dhl/Application/views/admin/en/module_lang.php b/src/modules/mo/mo_dhl/Application/views/admin/en/module_lang.php index 4369d557..8640dd8e 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/en/module_lang.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/en/module_lang.php @@ -38,6 +38,7 @@ 'MO_DHL__PAYMENTS_DHL' => 'DHL', 'MO_DHL__EXCLUDED' => 'Excluded', 'MO_DHL_SAVE_AND_CHECK' => 'Save and check credentials', + 'MO_DHL_AUTHENTICATION' => 'Save and check authentication', 'MO_DHL__NO_DELIVERYSET' => 'Please configure at least one shipping method to use the dhl services', 'MO_DHL__CHECKING_DELIVERYSET' => 'Testing shipping method ', 'MO_DHL__CORRECT_CREDENTIALS' => 'Credentials are corrent', diff --git a/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php b/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php index 70c3082a..df14717e 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php @@ -17,6 +17,12 @@ 'SHOP_MODULE_mo_dhl__merchant_ekp' => 'EKP', 'HELP_SHOP_MODULE_mo_dhl__merchant_ekp' => 'The EKP is your DHL customer number', + 'SHOP_MODULE_mo_dhl__authentication_client_id' => 'Client ID', + 'HELP_SHOP_MODULE_mo_dhl__authentication_client_id' => 'Your Client ID for the Account API.', + 'SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Client Secret', + 'HELP_SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Your Client Secret for the Account API.', + 'SHOP_MODULE_mo_dhl__authentication_check' => '', + 'SHOP_MODULE_GROUP_mo_dhl__portokasse' => 'Portokasse', 'SHOP_MODULE_mo_dhl__portokasse_user' => 'Portokasse Username (for Internetmarke and Warenpost)', 'HELP_SHOP_MODULE_mo_dhl__portokasse_user' => 'Your E-Mail Adress for the Portokasse. Not a customer yet? Then register here.', diff --git a/src/modules/mo/mo_dhl/Configurator.php b/src/modules/mo/mo_dhl/Configurator.php index e14868ab..c6063b77 100644 --- a/src/modules/mo/mo_dhl/Configurator.php +++ b/src/modules/mo/mo_dhl/Configurator.php @@ -6,9 +6,11 @@ use GuzzleHttp\ClientInterface; use Http\Client\Common\Plugin; use Http\Promise\Promise; +use Mediaopt\DHL\Api\Authentication; use Mediaopt\DHL\Api\Credentials; use Mediaopt\DHL\Api\Internetmarke; use Mediaopt\DHL\Api\InternetmarkeRefund; +use Mediaopt\DHL\Api\MyAccount; use Mediaopt\DHL\Api\ParcelShipping\Authentication\ApiKeyAuthentication; use Mediaopt\DHL\Api\ParcelShipping\Authentication\BasicAuthAuthentication; use Mediaopt\DHL\Api\ProdWSService; @@ -89,6 +91,30 @@ protected function buildParcelShippingCredentials(): Credentials : Credentials::createSandboxParcelShippingCredentials($username, $password, $apiKey); } + /** + * @return Credentials + */ + protected function buildAuthenticationCredentials(): Credentials + { + $clientId = $this->getAuthenticationClientId(); + $clientSecret = $this->getAuthenticationClientSecret(); + return $this->isProductionEnvironment() + ? Credentials::createProductionAuthenticationCredentials($clientId, $clientSecret) + : Credentials::createSandboxAuthenticationCredentials($clientId, $clientSecret); + } + + /** + * @return Credentials + */ + protected function buildAuthenticationUserCredentials(): Credentials + { + $username = $this->getAuthenticationUsername(); + $password = $this->getAuthenticationPassword(); + return $this->isProductionEnvironment() + ? Credentials::createProductionAuthenticationCredentials($username, $password) + : Credentials::createSandboxAuthenticationCredentials($username, $password); + } + /** * @return Credentials */ @@ -166,6 +192,26 @@ abstract protected function getCustomerParcelShippingUsername(); */ abstract protected function getCustomerParcelShippingPassword(); + /** + * @return string + */ + abstract protected function getAuthenticationClientId(); + + /** + * @return string + */ + abstract protected function getAuthenticationClientSecret(); + + /** + * @return string + */ + abstract protected function getAuthenticationUsername(); + + /** + * @return string + */ + abstract protected function getAuthenticationPassword(); + /** * @return string */ @@ -350,6 +396,41 @@ public function handleRequest(RequestInterface $request, callable $next, callabl return \Mediaopt\DHL\Api\ParcelShipping\Client::create($httpClient); } + /** + * @param LoggerInterface $logger + * @return Api\MyAccount\Client + */ + public function buildMyAccount(LoggerInterface $logger): Api\MyAccount\Client + { + $token = $this->buildAuthenticationToken($logger) ; + $credentials = $this->buildAuthenticationCredentials(); + $bearerAuthentication = new Authentication\Authentication\BearerAuthAuthentication($token); + $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); + $uri = \Http\Discovery\Psr17FactoryDiscovery::findUriFactory()->createUri($credentials->getEndpoint()); + + $plugins = [ + new \Http\Client\Common\Plugin\AddHostPlugin($uri), + new \Http\Client\Common\Plugin\AddPathPlugin($uri), + new \Jane\Component\OpenApiRuntime\Client\Plugin\AuthenticationRegistry([$bearerAuthentication]), + MyAccount::getMyAccountLoggingPlugin($logger), + ]; + $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins); + + return \Mediaopt\DHL\Api\MyAccount\Client::create($httpClient); + } + + /** + * @param LoggerInterface $logger + * @return string + */ + private function buildAuthenticationToken(LoggerInterface $logger): string + { + $credentials = $this->buildAuthenticationCredentials(); + $userPass = $this->buildAuthenticationUserCredentials(); + $authClient = Authentication\Client::create(); + return Authentication::getToken($authClient, $credentials, $userPass); + } + /** * @param LoggerInterface|null $logger * @return Internetmarke diff --git a/src/modules/mo/mo_dhl/Main.php b/src/modules/mo/mo_dhl/Main.php index 60cb481d..4225192c 100644 --- a/src/modules/mo/mo_dhl/Main.php +++ b/src/modules/mo/mo_dhl/Main.php @@ -166,10 +166,10 @@ public function buildParcelShipping(): Client } /** - * @return Client + * @return Api\MyAccount\Client */ - public function buildAuthentication(): Api\Authentication\Client + public function buildMyAccount(): Api\MyAccount\Client { - return $this->getConfigurator()->buildAuthentication($this->getLogger()); + return $this->getConfigurator()->buildMyAccount($this->getLogger()); } } diff --git a/src/modules/mo/mo_dhl/bootstrap.php b/src/modules/mo/mo_dhl/bootstrap.php new file mode 100644 index 00000000..bbcb1829 --- /dev/null +++ b/src/modules/mo/mo_dhl/bootstrap.php @@ -0,0 +1,2 @@ + 'bool', 'value' => 'false', ], + [ + 'group' => 'mo_dhl__account', + 'name' => 'mo_dhl__authentication_client_id', + 'type' => 'str', + ], + [ + 'group' => 'mo_dhl__account', + 'name' => 'mo_dhl__authentication_client_secret', + 'type' => 'str', + ], + [ + 'group' => 'mo_dhl__account', + 'name' => 'mo_dhl__authentication_check', + 'type' => 'bool', + 'value' => 'false', + ], [ 'group' => 'mo_dhl__portokasse', 'name' => 'mo_dhl__portokasse_user', diff --git a/src/modules/mo/mo_dhl/views/admin/blocks/module_config_admin_module_config_var_types.tpl b/src/modules/mo/mo_dhl/views/admin/blocks/module_config_admin_module_config_var_types.tpl index 82ab9466..0e96823b 100644 --- a/src/modules/mo/mo_dhl/views/admin/blocks/module_config_admin_module_config_var_types.tpl +++ b/src/modules/mo/mo_dhl/views/admin/blocks/module_config_admin_module_config_var_types.tpl @@ -9,6 +9,9 @@ [{elseif $module_var == 'mo_dhl__account_check'}] +[{elseif $module_var == 'mo_dhl__authentication_check'}] + [{elseif $module_var == 'mo_dhl__internetmarke_check'}] From fc621edd58fb6e69e57b5859818e0bf13adfb4c7 Mon Sep 17 00:00:00 2001 From: bohdan Date: Tue, 21 Nov 2023 14:12:01 +0100 Subject: [PATCH 03/16] #34741 account api --- .../Authentication/Runtime/Client/Client.php | 2 -- src/modules/mo/mo_dhl/Api/Credentials.php | 21 ++++++++++++++++--- .../Endpoint/GetMyAggregatedUserData.php | 2 +- .../Api/MyAccount/Endpoint/GetVersion.php | 2 +- .../Api/MyAccount/Runtime/Client/Client.php | 7 ------- .../Runtime/Client/EndpointTrait.php | 1 - .../Controller/Admin/ModuleConfiguration.php | 9 +------- src/modules/mo/mo_dhl/Configurator.php | 20 ++++++++++++++++-- 8 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php index 0df22e17..d4204e9f 100644 --- a/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php +++ b/src/modules/mo/mo_dhl/Api/Authentication/Runtime/Client/Client.php @@ -54,8 +54,6 @@ private function processEndpoint(Endpoint $endpoint) : ResponseInterface $queryString = $endpoint->getQueryString(); $uriGlue = false === strpos($endpoint->getUri(), '?') ? '?' : '&'; $uri = $queryString !== '' ? $endpoint->getUri() . $uriGlue . $queryString : $endpoint->getUri(); - //todo 34741 how to provide url here? - $uri = 'https://api-sandbox.dhl.com/parcel/de/account/auth/ropc/v1' . $uri; $request = $this->requestFactory->createRequest($endpoint->getMethod(), $uri); if ($body) { if ($body instanceof StreamInterface) { diff --git a/src/modules/mo/mo_dhl/Api/Credentials.php b/src/modules/mo/mo_dhl/Api/Credentials.php index 8039c104..509e3b36 100644 --- a/src/modules/mo/mo_dhl/Api/Credentials.php +++ b/src/modules/mo/mo_dhl/Api/Credentials.php @@ -196,8 +196,7 @@ public static function createProductionParcelShippingCredentials($username, $pas */ public static function createProductionAuthenticationCredentials($clientId, $clientSecret) { - //todo 34741 prod endpoint - return new static('', $clientId, $clientSecret, null, true); + return new static('https://api-eu.dhl.com/parcel/de/account/auth/ropc/v1', $clientId, $clientSecret, null, false); } /** @@ -208,7 +207,23 @@ public static function createProductionAuthenticationCredentials($clientId, $cli */ public static function createSandboxAuthenticationCredentials($clientId, $clientSecret) { - return new static('https://api-eu.dhl.com/parcel/de/account/auth/ropc/v1', $clientId, $clientSecret, null, false); + return new static('https://api-sandbox.dhl.com/parcel/de/account/auth/ropc/v1', $clientId, $clientSecret, null, true); + } + + /** + * @return static + */ + public static function createProductionMyAccountCredentials() + { + return new static('https://api-eu.dhl.com/parcel/de/account/myaccount/v1', null, null, null, false); + } + + /** + * @return static + */ + public static function createSandboxMyAccountCredentials() + { + return new static('https://api-sandbox.dhl.com/parcel/de/account/myaccount/v1', null, null, null, true); } /** diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetMyAggregatedUserData.php b/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetMyAggregatedUserData.php index aadae3a1..18008eb4 100644 --- a/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetMyAggregatedUserData.php +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetMyAggregatedUserData.php @@ -65,6 +65,6 @@ protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $re } public function getAuthenticationScopes() : array { - return array('security_auth'); + return array('bearerAuth'); } } \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetVersion.php b/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetVersion.php index 3509b802..74d12c8d 100644 --- a/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetVersion.php +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Endpoint/GetVersion.php @@ -51,6 +51,6 @@ protected function transformResponseBody(\Psr\Http\Message\ResponseInterface $re } public function getAuthenticationScopes() : array { - return array('security_auth'); + return array('bearerAuth'); } } \ No newline at end of file diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php index 2ec986c2..d0909901 100644 --- a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/Client.php @@ -38,12 +38,6 @@ public function __construct(ClientInterface $httpClient, RequestFactoryInterface } public function executeEndpoint(Endpoint $endpoint, string $fetch = self::FETCH_OBJECT) { - debug($endpoint->getUri()); - debug($endpoint->getQueryString()); - //debug($endpoint->getBody()); - debug($endpoint->getAuthenticationScopes()); - debug($endpoint->getHeaders()); - if (self::FETCH_RESPONSE === $fetch) { trigger_deprecation('jane-php/open-api-common', '7.3', 'Using %s::%s method with $fetch parameter equals to response is deprecated, use %s::%s instead.', __CLASS__, __METHOD__, __CLASS__, 'executeRawEndpoint'); return $this->executeRawEndpoint($endpoint); @@ -81,7 +75,6 @@ private function processEndpoint(Endpoint $endpoint) : ResponseInterface foreach ($endpoint->getAuthenticationScopes() as $scope) { $scopes[] = $scope; } - debug($scopes); $request = $request->withHeader(AuthenticationRegistry::SCOPES_HEADER, $scopes); } return $this->httpClient->sendRequest($request); diff --git a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/EndpointTrait.php b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/EndpointTrait.php index fed5d1d2..9a04d1a0 100644 --- a/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/EndpointTrait.php +++ b/src/modules/mo/mo_dhl/Api/MyAccount/Runtime/Client/EndpointTrait.php @@ -9,7 +9,6 @@ trait EndpointTrait protected abstract function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null); public function parseResponse(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) { - debug($response->getBody()->getContents()); $contentType = $response->hasHeader('Content-Type') ? current($response->getHeader('Content-Type')) : null; return $this->transformResponseBody($response, $serializer, $contentType); } diff --git a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php index 2d98984e..98ca6a92 100644 --- a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php +++ b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php @@ -211,15 +211,8 @@ public function moAuthentication() $this->save(); $adapter = new \Mediaopt\DHL\Adapter\DHLAdapter(); $myAccount = $adapter->buildMyAccount(); - + $userData = $myAccount->getMyAggregatedUserData(['lang' => 'de']); $version = $myAccount->getVersion(); - $userData = $myAccount->getMyAggregatedUserData(['lang' => 'en']); - - debug($version); - debug($userData); - print_r($userData); - print_r($version); - //debug($version->getBody()); } catch (\Exception $e) { $this->displayErrors($e); diff --git a/src/modules/mo/mo_dhl/Configurator.php b/src/modules/mo/mo_dhl/Configurator.php index c6063b77..ec7a10d6 100644 --- a/src/modules/mo/mo_dhl/Configurator.php +++ b/src/modules/mo/mo_dhl/Configurator.php @@ -115,6 +115,16 @@ protected function buildAuthenticationUserCredentials(): Credentials : Credentials::createSandboxAuthenticationCredentials($username, $password); } + /** + * @return Credentials + */ + protected function buildMyAccountCredentials(): Credentials + { + return $this->isProductionEnvironment() + ? Credentials::createProductionMyAccountCredentials() + : Credentials::createSandboxMyAccountCredentials(); + } + /** * @return Credentials */ @@ -403,7 +413,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl public function buildMyAccount(LoggerInterface $logger): Api\MyAccount\Client { $token = $this->buildAuthenticationToken($logger) ; - $credentials = $this->buildAuthenticationCredentials(); + $credentials = $this->buildMyAccountCredentials(); $bearerAuthentication = new Authentication\Authentication\BearerAuthAuthentication($token); $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); $uri = \Http\Discovery\Psr17FactoryDiscovery::findUriFactory()->createUri($credentials->getEndpoint()); @@ -427,7 +437,13 @@ private function buildAuthenticationToken(LoggerInterface $logger): string { $credentials = $this->buildAuthenticationCredentials(); $userPass = $this->buildAuthenticationUserCredentials(); - $authClient = Authentication\Client::create(); + $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); + $plugins = array(); + $uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri($credentials->getEndpoint()); + $plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri); + $plugins[] = new \Http\Client\Common\Plugin\AddPathPlugin($uri); + $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins); + $authClient = Authentication\Client::create($httpClient); return Authentication::getToken($authClient, $credentials, $userPass); } From 67269a2fbe2153a921ca0be971c8ec9a6991a90b Mon Sep 17 00:00:00 2001 From: Jonathan Yeboah <10155597+JonYeb@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:22:20 +0100 Subject: [PATCH 04/16] #34741 create shipping methods --- .../Controller/Admin/ModuleConfiguration.php | 90 +++++++++++++++++-- 1 file changed, 82 insertions(+), 8 deletions(-) diff --git a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php index 98ca6a92..bca655e4 100644 --- a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php +++ b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php @@ -8,6 +8,7 @@ * @copyright 2016 Mediaopt GmbH */ +use Mediaopt\DHL\Adapter\DHLAdapter; use Mediaopt\DHL\Adapter\ParcelShippingConverter; use Mediaopt\DHL\Api\Authentication\Model\TokenPostBody; use Mediaopt\DHL\Api\GKV; @@ -25,6 +26,7 @@ use Mediaopt\DHL\Api\GKV\ValidateShipmentOrderType; use Mediaopt\DHL\Api\GKV\Version; use Mediaopt\DHL\Api\Internetmarke; +use Mediaopt\DHL\Api\MyAccount\Model\Detail; use Mediaopt\DHL\Api\ParcelShipping\Client; use Mediaopt\DHL\Application\Model\DeliverySetList; use Mediaopt\DHL\Controller\Admin\ErrorDisplayTrait; @@ -54,6 +56,30 @@ class ModuleConfiguration extends ModuleConfiguration_parent 'mo_dhl__wunschtag_surcharge_text' => 'MO_DHL__WUNSCHTAG_COSTS', ]; + /** + * @var string[] + */ + const INTERNAL_PROCESSES = [ + 'PAKET' => 'DHL PAKET', + 'PAKET_INTERNATIONAL' => 'PAKET INTERNATIONAL', + 'EUROPAKET' => 'DHL EUROPAKET', + 'WARENPOST' => 'Warenpost', + 'WARENPOST_INTERNATIONAL'=> 'Warenpost International', + ]; + + /** + * @var string[] + */ + const INTERNAL_PROCESSES_INVERSE = [ + 'DHL PAKET' => 'PAKET', + 'PAKET INTERNATIONAL' => 'PAKET_INTERNATIONAL', + 'DHL EUROPAKET' => 'EUROPAKET', + 'Warenpost' => 'WARENPOST', + 'Warenpost International' => 'WARENPOST_INTERNATIONAL', + ]; + + var $SHIPPING_METHODS = []; + /** * @extend * @return string @@ -178,7 +204,7 @@ public function moSaveAndCheckLogin() { try { $this->save(); - $adapter = new \Mediaopt\DHL\Adapter\DHLAdapter(); + $adapter = new DHLAdapter(); if (Registry::getConfig()->getConfigParam('mo_dhl__account_sandbox')) { Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__CHECK_FOR_SANDBOX_NOT_POSSIBLE'); return; @@ -203,16 +229,64 @@ public function moSaveAndCheckLogin() } + /** + * @param Detail $detail + * @return bool + */ + public function checkForShippingAlreadyExist(Detail $detail): bool + { + if (count(array_keys($this->SHIPPING_METHODS)) === 0) { + $this->SHIPPING_METHODS = Registry::get(\OxidEsales\Eshop\Application\Model\DeliverySetList::class)->getDeliverySetList(null, null); + } + + $shippingExist = false; + + foreach($this->SHIPPING_METHODS as $key => $value) { + $shippingExist = $shippingExist || (self::INTERNAL_PROCESSES[$value->oxdeliveryset__mo_dhl_process->value] === $detail->getProduct()->getName()); + } + return $shippingExist; + } + + /** + * @param Detail $detail + * @return void + */ + private function createNewShippingMethod(Detail $detail): void + { + if (!array_key_exists($detail->getProduct()->getName(), self::INTERNAL_PROCESSES_INVERSE)) { + return; + } + $oDelSet = oxNew(DeliverySet::class); + $aParams = []; + $aParams["oxdeliveryset__oxid"] = null; + $aParams["oxdeliveryset__oxtitle"] = $detail->getBookingText(); + $aParams["oxdeliveryset__mo_dhl_process"] = self::INTERNAL_PROCESSES_INVERSE[$detail->getProduct()->getName()]; + $aParams["oxdeliveryset__mo_dhl_participation"] = substr($detail->getBillingNumber(), -2); + + $oDelSet->setLanguage(0); + $oDelSet->assign($aParams); + $oDelSet = Registry::getUtilsFile()->processFiles($oDelSet); + $oDelSet->save(); + } + /** */ - public function moAuthentication() + public function moAuthentication(): void { try { $this->save(); - $adapter = new \Mediaopt\DHL\Adapter\DHLAdapter(); + $adapter = new DHLAdapter(); $myAccount = $adapter->buildMyAccount(); $userData = $myAccount->getMyAggregatedUserData(['lang' => 'de']); - $version = $myAccount->getVersion(); + + $details = $userData->getShippingRights()->getDetails(); + $size = count($details); + + for ($i=0; $i<$size; $i++) { + if (!$this->checkForShippingAlreadyExist($details[$i])) { + $this->createNewShippingMethod($details[$i]); + } + } } catch (\Exception $e) { $this->displayErrors($e); @@ -225,7 +299,7 @@ public function moSaveAndCheckInternetmarkeLogin() { try { $this->save(); - $adapter = new \Mediaopt\DHL\Adapter\DHLAdapter(); + $adapter = new DHLAdapter(); $this->checkInternetmarke($adapter->buildInternetmarke()); } catch (\Exception $e) { $this->displayErrors($e); @@ -278,9 +352,9 @@ public function moDHLGetPlaceholder(string $textVarName, int $langId): string } /** - * @param \Mediaopt\DHL\Adapter\DHLAdapter $adapter + * @param DHLAdapter $adapter */ - private function checkWunschpaket(\Mediaopt\DHL\Adapter\DHLAdapter $adapter) + private function checkWunschpaket(DHLAdapter $adapter) { try { $days = $adapter->buildWunschpaket()->getPreferredDays('12045'); @@ -372,7 +446,7 @@ private function checkShippingAPIs(\Mediaopt\DHL\Api\GKV $gkv, Client $parcelShi /** * @param \Mediaopt\DHL\Api\GKV $gkv - * @param \OxidEsales\Eshop\Application\Model\DeliverySet $deliveryset + * @param DeliverySet $deliveryset * @return Shipment */ protected function createTestShipment(\Mediaopt\DHL\Api\GKV $gkv, $deliveryset): Shipment From c2bf0f5ebc4ee998b5106c60d073f6f7bc6e2cb9 Mon Sep 17 00:00:00 2001 From: Jonathan Yeboah <10155597+JonYeb@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:25:04 +0100 Subject: [PATCH 05/16] #34741 prettify array assignment --- .../Controller/Admin/ModuleConfiguration.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php index bca655e4..4fcb5512 100644 --- a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php +++ b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php @@ -257,11 +257,12 @@ private function createNewShippingMethod(Detail $detail): void return; } $oDelSet = oxNew(DeliverySet::class); - $aParams = []; - $aParams["oxdeliveryset__oxid"] = null; - $aParams["oxdeliveryset__oxtitle"] = $detail->getBookingText(); - $aParams["oxdeliveryset__mo_dhl_process"] = self::INTERNAL_PROCESSES_INVERSE[$detail->getProduct()->getName()]; - $aParams["oxdeliveryset__mo_dhl_participation"] = substr($detail->getBillingNumber(), -2); + $aParams = [ + "oxdeliveryset__oxid" => null, + "oxdeliveryset__oxtitle" => $detail->getBookingText(), + "oxdeliveryset__mo_dhl_process" => self::INTERNAL_PROCESSES_INVERSE[$detail->getProduct()->getName()], + "oxdeliveryset__mo_dhl_participation" => substr($detail->getBillingNumber(), -2) + ]; $oDelSet->setLanguage(0); $oDelSet->assign($aParams); From 9ac5fb2031f31927319f220c40a8de1e1d8d7401 Mon Sep 17 00:00:00 2001 From: bohdan Date: Wed, 21 Feb 2024 12:36:15 +0100 Subject: [PATCH 06/16] #34741 version update --- Changelog.md | 3 +++ src/modules/mo/mo_dhl/metadata.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index b5c4aeda..12191f42 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## 1.7.5 +* Account API implementation + ## 1.7.4 * replaced deprecated shipping confirmation service in REST API diff --git a/src/modules/mo/mo_dhl/metadata.php b/src/modules/mo/mo_dhl/metadata.php index 9ee2edc1..c158a9d6 100644 --- a/src/modules/mo/mo_dhl/metadata.php +++ b/src/modules/mo/mo_dhl/metadata.php @@ -17,7 +17,7 @@ 'en' => '

Enable features providing Post & Paket Delivery to your OXID shop.

' . '

Handbook

', ], 'thumbnail' => 'logo.png', - 'version' => '1.7.4', + 'version' => '1.7.5', 'author' => 'mediaopt.', 'url' => 'http://www.mediaopt.de', 'email' => 'shopsoftware@deutschepost.de', From c2ae187ca549eab588fda1f5692530ed3f7f22e6 Mon Sep 17 00:00:00 2001 From: bohdan Date: Wed, 21 Feb 2024 12:46:09 +0100 Subject: [PATCH 07/16] #34741 test update --- tests/TestConfigurator.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/TestConfigurator.php b/tests/TestConfigurator.php index 0847869a..0898ba6f 100644 --- a/tests/TestConfigurator.php +++ b/tests/TestConfigurator.php @@ -216,6 +216,38 @@ protected function getCustomerProdWSMandantId() return \Mediaopt\DHL\Adapter\DHLConfigurator::PRODWS_MANDANT_ID; } + /** + * @return string + */ + protected function getAuthenticationClientId() + { + return \Mediaopt\DHL\Adapter\DHLConfigurator::TEST_AUTHENTICATION_CLIENT_ID; + } + + /** + * @return string + */ + protected function getAuthenticationClientSecret() + { + return \Mediaopt\DHL\Adapter\DHLConfigurator::TEST_AUTHENTICATION_CLIENT_SECRET; + } + + /** + * @return string + */ + protected function getAuthenticationUsername() + { + return \Mediaopt\DHL\Adapter\DHLConfigurator::TEST_AUTHENTICATION_USERNAME; + } + + /** + * @return string + */ + protected function getAuthenticationPassword() + { + return \Mediaopt\DHL\Adapter\DHLConfigurator::TEST_AUTHENTICATION_PASSWORD; + } + /** * @return bool */ From 8454522c27a9d57f49c2386164cc9af79a73fee1 Mon Sep 17 00:00:00 2001 From: bohdan Date: Wed, 21 Feb 2024 12:50:58 +0100 Subject: [PATCH 08/16] #34741 test update --- tests/ConfiguratorTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/ConfiguratorTest.php b/tests/ConfiguratorTest.php index b7d3ee03..d955bdd1 100644 --- a/tests/ConfiguratorTest.php +++ b/tests/ConfiguratorTest.php @@ -38,6 +38,10 @@ protected function getConfiguratorMock() 'getProdWSLogin', 'getProdWSPassword', 'getCustomerProdWSMandantId', + 'getAuthenticationClientId', + 'getAuthenticationClientSecret', + 'getAuthenticationUsername', + 'getAuthenticationPassword', 'getMapsApiKey', 'buildLogHandler', 'getEkp', From bb03d1d3328576c4cb7956ebbfc14d4fded86ef6 Mon Sep 17 00:00:00 2001 From: bohdan Date: Thu, 7 Mar 2024 09:45:35 +0100 Subject: [PATCH 09/16] #34741 fix after CR --- .../mo/mo_dhl/Application/views/admin/de/module_lang.php | 2 +- .../mo/mo_dhl/Application/views/admin/de/module_options.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/mo/mo_dhl/Application/views/admin/de/module_lang.php b/src/modules/mo/mo_dhl/Application/views/admin/de/module_lang.php index 19c2e872..7105a469 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/de/module_lang.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/de/module_lang.php @@ -38,7 +38,7 @@ 'MO_DHL__PAYMENTS_DHL' => 'DHL', 'MO_DHL__EXCLUDED' => 'Ausschließen', 'MO_DHL_SAVE_AND_CHECK' => 'Speichern und Zugangsdaten prüfen', - 'MO_DHL_AUTHENTICATION' => 'Speichern und Authentication prüfen', + 'MO_DHL_AUTHENTICATION' => 'Speichern und fehlende Versandarten für meinen Account hinzufügen', 'MO_DHL__NO_DELIVERYSET' => 'Bitte konfigurieren Sie mindestens eine Versandsart zur Nutzung der SHL Services', 'MO_DHL__CHECKING_DELIVERYSET' => 'Teste Versandart ', 'MO_DHL__CORRECT_CREDENTIALS' => 'Zugangsdaten korrekt', diff --git a/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php b/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php index a8a4f24a..e3fc121c 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php @@ -17,9 +17,9 @@ 'HELP_SHOP_MODULE_mo_dhl__merchant_ekp' => 'Die EKP ist Ihre DHL Kundennummer', 'SHOP_MODULE_mo_dhl__authentication_client_id' => 'Client ID', - 'HELP_SHOP_MODULE_mo_dhl__authentication_client_id' => 'Ihr Client ID für der Account API.', + 'HELP_SHOP_MODULE_mo_dhl__authentication_client_id' => 'Ihre Client ID für der Account API.', 'SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Client Secret', - 'HELP_SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Ihr Client Secret für der Account API.', + 'HELP_SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Ihre Client Secret für der Account API.', 'SHOP_MODULE_mo_dhl__authentication_check' => '', 'SHOP_MODULE_GROUP_mo_dhl__portokasse' => 'Portokasse', From 40232d531624ebd27ce0bdddec386234547163b1 Mon Sep 17 00:00:00 2001 From: bohdan Date: Thu, 7 Mar 2024 10:15:43 +0100 Subject: [PATCH 10/16] #34741 fix after CR --- .../mo/mo_dhl/Adapter/DHLConfigurator.php | 27 +++++-------------- .../views/admin/de/module_options.php | 8 ++---- .../views/admin/en/module_options.php | 8 ++---- src/modules/mo/mo_dhl/Configurator.php | 15 ++++------- src/modules/mo/mo_dhl/metadata.php | 12 +-------- tests/ConfiguratorTest.php | 5 ++-- tests/TestConfigurator.php | 14 +++------- 7 files changed, 21 insertions(+), 68 deletions(-) diff --git a/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php b/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php index 75f197e4..b9e7f990 100644 --- a/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php +++ b/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php @@ -64,9 +64,7 @@ class DHLConfigurator extends \Mediaopt\DHL\Configurator const STANDORTSUCHE_API_KEY_NAME = 'DHL-API-Key'; - const TEST_STANDORTSUCHE_API_PASSWORD = 'kAPjq3yHFgY6QD3sHEtv61dQCAgoXLyK'; - - const TEST_AUTHENTICATION_CLIENT_ID = 'kAPjq3yHFgY6QD3sHEtv61dQCAgoXLyK'; + const TEST_API_KEY_AND_SECRET_FOR_DEVELOPER_API = 'kAPjq3yHFgY6QD3sHEtv61dQCAgoXLyK'; const TEST_AUTHENTICATION_CLIENT_SECRET = 'YdZnAljhgbcOXOKD'; @@ -125,17 +123,17 @@ protected function getStandortsucheKeyName() /** * @return string */ - protected function getProdStandortsuchePassword() + protected function getProdApiKeyAndSecretForDeveloperAPI() { - return \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('mo_dhl__prod_standortsuche_password') ?: ''; + return \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('mo_dhl__api_key_and_secret_for_developer_api') ?: ''; } /** * @return string */ - protected function getSandboxStandortsuchePassword() + protected function getSandboxApiKeyAndSecretForDeveloperAPI() { - return self::TEST_STANDORTSUCHE_API_PASSWORD; + return self::TEST_API_KEY_AND_SECRET_FOR_DEVELOPER_API; } /** @@ -187,25 +185,12 @@ protected function getCustomerParcelShippingPassword() : self::TEST_PARCEL_SHIPPING_PASSWORD; } - /** - * @return string - */ - protected function getAuthenticationClientId() - { - return $this->isProductionEnvironment() - ? (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('mo_dhl__authentication_client_id') ?: '') - : self::TEST_AUTHENTICATION_CLIENT_ID; - } - - /** * @return string */ protected function getAuthenticationClientSecret() { - return $this->isProductionEnvironment() - ? (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('mo_dhl__authentication_client_secret') ?: '') - : self::TEST_AUTHENTICATION_CLIENT_SECRET; + return self::TEST_AUTHENTICATION_CLIENT_SECRET; } /** diff --git a/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php b/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php index e3fc121c..0fe944e6 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php @@ -16,10 +16,6 @@ 'SHOP_MODULE_mo_dhl__merchant_ekp' => 'EKP', 'HELP_SHOP_MODULE_mo_dhl__merchant_ekp' => 'Die EKP ist Ihre DHL Kundennummer', - 'SHOP_MODULE_mo_dhl__authentication_client_id' => 'Client ID', - 'HELP_SHOP_MODULE_mo_dhl__authentication_client_id' => 'Ihre Client ID für der Account API.', - 'SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Client Secret', - 'HELP_SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Ihre Client Secret für der Account API.', 'SHOP_MODULE_mo_dhl__authentication_check' => '', 'SHOP_MODULE_GROUP_mo_dhl__portokasse' => 'Portokasse', @@ -100,8 +96,8 @@ 'SHOP_MODULE_mo_dhl__retoure_receiver_country_AUT' => 'Österreich', 'SHOP_MODULE_GROUP_mo_dhl__standortsuche' => 'Wunschzustellung - Standortsuche', - 'SHOP_MODULE_mo_dhl__prod_standortsuche_password' => 'DHL Standortsuche Passwort', - 'HELP_SHOP_MODULE_mo_dhl__prod_standortsuche_password' => 'Ihr Passwort für die DHL Standortsuche.', + 'SHOP_MODULE_mo_dhl__api_key_and_secret_for_developer_api' => 'API-Schlüssel und API-Geheimnis für die Entwickler-API', + 'HELP_SHOP_MODULE_mo_dhl__api_key_and_secret_for_developer_api' => 'Bitte erstellen Sie ein Entwicklerkonto und eine App. Aktivieren Sie MyAccountAPI und die einheitliche API für den Standortfinder.', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits' => 'Maximale Trefferanzahl', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits_1' => '1', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits_2' => '2', diff --git a/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php b/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php index df14717e..d493cd2f 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php @@ -17,10 +17,6 @@ 'SHOP_MODULE_mo_dhl__merchant_ekp' => 'EKP', 'HELP_SHOP_MODULE_mo_dhl__merchant_ekp' => 'The EKP is your DHL customer number', - 'SHOP_MODULE_mo_dhl__authentication_client_id' => 'Client ID', - 'HELP_SHOP_MODULE_mo_dhl__authentication_client_id' => 'Your Client ID for the Account API.', - 'SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Client Secret', - 'HELP_SHOP_MODULE_mo_dhl__authentication_client_secret' => 'Your Client Secret for the Account API.', 'SHOP_MODULE_mo_dhl__authentication_check' => '', 'SHOP_MODULE_GROUP_mo_dhl__portokasse' => 'Portokasse', @@ -101,8 +97,8 @@ 'SHOP_MODULE_mo_dhl__retoure_receiver_country_AUT' => 'Austria', 'SHOP_MODULE_GROUP_mo_dhl__standortsuche' => 'Preferred delivery - Parcel shop finder', - 'SHOP_MODULE_mo_dhl__prod_standortsuche_password' => 'DHL Location Finder Password', - 'HELP_SHOP_MODULE_mo_dhl__prod_standortsuche_password' => 'Your Password for the DHL Location Finder API.', + 'SHOP_MODULE_mo_dhl__api_key_and_secret_for_developer_api' => 'Api key and api secret for developer API', + 'HELP_SHOP_MODULE_mo_dhl__api_key_and_secret_for_developer_api' => 'Please create a developer Account and an App. Activate MyAccountAPI and Location Finder Unified API.', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits' => 'Maximum number of hits', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits_1' => '1', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits_2' => '2', diff --git a/src/modules/mo/mo_dhl/Configurator.php b/src/modules/mo/mo_dhl/Configurator.php index ec7a10d6..4ceaf0ff 100644 --- a/src/modules/mo/mo_dhl/Configurator.php +++ b/src/modules/mo/mo_dhl/Configurator.php @@ -56,8 +56,8 @@ protected function buildRestCredentials($forceUseProd = false) protected function buildStandortsucheCredentials($forceUseProd = false) { return $this->isProductionEnvironment() || $forceUseProd - ? Credentials::createStandortsucheEndpoint($this->getStandortsucheKeyName(), $this->getProdStandortsuchePassword()) - : Credentials::createStandortsucheEndpoint($this->getStandortsucheKeyName(), $this->getSandboxStandortsuchePassword()); + ? Credentials::createStandortsucheEndpoint($this->getStandortsucheKeyName(), $this->getProdApiKeyAndSecretForDeveloperAPI()) + : Credentials::createStandortsucheEndpoint($this->getStandortsucheKeyName(), $this->getSandboxApiKeyAndSecretForDeveloperAPI()); } /** @@ -96,7 +96,7 @@ protected function buildParcelShippingCredentials(): Credentials */ protected function buildAuthenticationCredentials(): Credentials { - $clientId = $this->getAuthenticationClientId(); + $clientId = $this->getProdApiKeyAndSecretForDeveloperAPI(); $clientSecret = $this->getAuthenticationClientSecret(); return $this->isProductionEnvironment() ? Credentials::createProductionAuthenticationCredentials($clientId, $clientSecret) @@ -202,11 +202,6 @@ abstract protected function getCustomerParcelShippingUsername(); */ abstract protected function getCustomerParcelShippingPassword(); - /** - * @return string - */ - abstract protected function getAuthenticationClientId(); - /** * @return string */ @@ -305,12 +300,12 @@ abstract protected function getStandortsucheKeyName(); /** * @return string */ - abstract protected function getProdStandortsuchePassword(); + abstract protected function getProdApiKeyAndSecretForDeveloperAPI(); /** * @return string */ - abstract protected function getSandboxStandortsuchePassword(); + abstract protected function getSandboxApiKeyAndSecretForDeveloperAPI(); /** * @return string diff --git a/src/modules/mo/mo_dhl/metadata.php b/src/modules/mo/mo_dhl/metadata.php index 421e036a..1a1d7bd7 100644 --- a/src/modules/mo/mo_dhl/metadata.php +++ b/src/modules/mo/mo_dhl/metadata.php @@ -251,16 +251,6 @@ 'type' => 'bool', 'value' => 'false', ], - [ - 'group' => 'mo_dhl__account', - 'name' => 'mo_dhl__authentication_client_id', - 'type' => 'str', - ], - [ - 'group' => 'mo_dhl__account', - 'name' => 'mo_dhl__authentication_client_secret', - 'type' => 'str', - ], [ 'group' => 'mo_dhl__account', 'name' => 'mo_dhl__authentication_check', @@ -522,7 +512,7 @@ ], [ 'group' => 'mo_dhl__standortsuche', - 'name' => 'mo_dhl__prod_standortsuche_password', + 'name' => 'mo_dhl__api_key_and_secret_for_developer_api', 'type' => 'str', ], [ diff --git a/tests/ConfiguratorTest.php b/tests/ConfiguratorTest.php index d955bdd1..eb166192 100644 --- a/tests/ConfiguratorTest.php +++ b/tests/ConfiguratorTest.php @@ -25,8 +25,8 @@ protected function getConfiguratorMock() 'getCustomerRetoureLogin', 'getCustomerRetourePassword', 'getStandortsucheKeyName', - 'getProdStandortsuchePassword', - 'getSandboxStandortsuchePassword', + 'getProdApiKeyAndSecretForDeveloperAPI', + 'getSandboxApiKeyAndSecretForDeveloperAPI', 'getInternetmarkeProdLogin', 'getInternetmarkeProdSignature', 'getInternetmarkeSandboxLogin', @@ -38,7 +38,6 @@ protected function getConfiguratorMock() 'getProdWSLogin', 'getProdWSPassword', 'getCustomerProdWSMandantId', - 'getAuthenticationClientId', 'getAuthenticationClientSecret', 'getAuthenticationUsername', 'getAuthenticationPassword', diff --git a/tests/TestConfigurator.php b/tests/TestConfigurator.php index 0898ba6f..1a97acf0 100644 --- a/tests/TestConfigurator.php +++ b/tests/TestConfigurator.php @@ -107,7 +107,7 @@ protected function getStandortsucheKeyName() /** * @return string */ - protected function getProdStandortsuchePassword() + protected function getProdApiKeyAndSecretForDeveloperAPI() { return 'PROD_STANDORTSUCHE_API_PASSWORD'; } @@ -115,9 +115,9 @@ protected function getProdStandortsuchePassword() /** * @return string */ - protected function getSandboxStandortsuchePassword() + protected function getSandboxApiKeyAndSecretForDeveloperAPI() { - return \Mediaopt\DHL\Adapter\DHLConfigurator::TEST_STANDORTSUCHE_API_PASSWORD; + return \Mediaopt\DHL\Adapter\DHLConfigurator::TEST_API_KEY_AND_SECRET_FOR_DEVELOPER_API; } /** @@ -216,14 +216,6 @@ protected function getCustomerProdWSMandantId() return \Mediaopt\DHL\Adapter\DHLConfigurator::PRODWS_MANDANT_ID; } - /** - * @return string - */ - protected function getAuthenticationClientId() - { - return \Mediaopt\DHL\Adapter\DHLConfigurator::TEST_AUTHENTICATION_CLIENT_ID; - } - /** * @return string */ From 843250668367e861bd7d2ecf294217f3aab6179d Mon Sep 17 00:00:00 2001 From: Jonathan Yeboah <10155597+JonYeb@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:38:29 +0100 Subject: [PATCH 11/16] #34741 changes according to code review comments --- .../Controller/Admin/ModuleConfiguration.php | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php index 4fcb5512..167623da 100644 --- a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php +++ b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php @@ -230,21 +230,21 @@ public function moSaveAndCheckLogin() } /** - * @param Detail $detail + * @param String $detailName * @return bool */ - public function checkForShippingAlreadyExist(Detail $detail): bool + public function checkForShippingAlreadyExist(String $detailName): bool { - if (count(array_keys($this->SHIPPING_METHODS)) === 0) { + if (count($this->SHIPPING_METHODS) === 0) { $this->SHIPPING_METHODS = Registry::get(\OxidEsales\Eshop\Application\Model\DeliverySetList::class)->getDeliverySetList(null, null); } - $shippingExist = false; - - foreach($this->SHIPPING_METHODS as $key => $value) { - $shippingExist = $shippingExist || (self::INTERNAL_PROCESSES[$value->oxdeliveryset__mo_dhl_process->value] === $detail->getProduct()->getName()); - } - return $shippingExist; + return (bool) array_filter( + $this->SHIPPING_METHODS, + fn($shippingMethod) => + self::INTERNAL_PROCESSES[$shippingMethod->oxdeliveryset__mo_dhl_process->value] === + $detailName + ); } /** @@ -281,13 +281,8 @@ public function moAuthentication(): void $userData = $myAccount->getMyAggregatedUserData(['lang' => 'de']); $details = $userData->getShippingRights()->getDetails(); - $size = count($details); - for ($i=0; $i<$size; $i++) { - if (!$this->checkForShippingAlreadyExist($details[$i])) { - $this->createNewShippingMethod($details[$i]); - } - } + array_map([$this, 'createNewShippingMethod'], array_filter($details, fn($detail) => !$this->checkForShippingAlreadyExist($detail->getProduct()->getName()))); } catch (\Exception $e) { $this->displayErrors($e); From a12182c8011355bdc116cc03007d5fc315c0b35c Mon Sep 17 00:00:00 2001 From: bohdan Date: Mon, 18 Mar 2024 18:57:15 +0100 Subject: [PATCH 12/16] fix after CR --- .../mo/mo_dhl/Adapter/DHLConfigurator.php | 26 +++++++++---------- .../views/admin/de/module_options.php | 2 -- .../views/admin/en/module_options.php | 2 -- src/modules/mo/mo_dhl/Configurator.php | 21 +++++++-------- src/modules/mo/mo_dhl/metadata.php | 5 ---- tests/ConfiguratorTest.php | 4 +-- tests/TestConfigurator.php | 20 +++++++------- 7 files changed, 34 insertions(+), 46 deletions(-) diff --git a/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php b/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php index b9e7f990..c4ba423e 100644 --- a/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php +++ b/src/modules/mo/mo_dhl/Adapter/DHLConfigurator.php @@ -64,9 +64,9 @@ class DHLConfigurator extends \Mediaopt\DHL\Configurator const STANDORTSUCHE_API_KEY_NAME = 'DHL-API-Key'; - const TEST_API_KEY_AND_SECRET_FOR_DEVELOPER_API = 'kAPjq3yHFgY6QD3sHEtv61dQCAgoXLyK'; + const DHL_DEVELOPER_API_KEY = 'kAPjq3yHFgY6QD3sHEtv61dQCAgoXLyK'; - const TEST_AUTHENTICATION_CLIENT_SECRET = 'YdZnAljhgbcOXOKD'; + const DHL_DEVELOPER_API_SECRET = 'YdZnAljhgbcOXOKD'; const TEST_AUTHENTICATION_USERNAME = 'user-valid'; @@ -123,17 +123,9 @@ protected function getStandortsucheKeyName() /** * @return string */ - protected function getProdApiKeyAndSecretForDeveloperAPI() + protected function getStandortsuchePassword() { - return \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('mo_dhl__api_key_and_secret_for_developer_api') ?: ''; - } - - /** - * @return string - */ - protected function getSandboxApiKeyAndSecretForDeveloperAPI() - { - return self::TEST_API_KEY_AND_SECRET_FOR_DEVELOPER_API; + return self::DHL_DEVELOPER_API_KEY; } /** @@ -185,12 +177,20 @@ protected function getCustomerParcelShippingPassword() : self::TEST_PARCEL_SHIPPING_PASSWORD; } + /** + * @return string + */ + protected function getAuthenticationClientId() + { + return self::DHL_DEVELOPER_API_KEY; + } + /** * @return string */ protected function getAuthenticationClientSecret() { - return self::TEST_AUTHENTICATION_CLIENT_SECRET; + return self::DHL_DEVELOPER_API_SECRET; } /** diff --git a/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php b/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php index 0fe944e6..cc14939b 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/de/module_options.php @@ -96,8 +96,6 @@ 'SHOP_MODULE_mo_dhl__retoure_receiver_country_AUT' => 'Österreich', 'SHOP_MODULE_GROUP_mo_dhl__standortsuche' => 'Wunschzustellung - Standortsuche', - 'SHOP_MODULE_mo_dhl__api_key_and_secret_for_developer_api' => 'API-Schlüssel und API-Geheimnis für die Entwickler-API', - 'HELP_SHOP_MODULE_mo_dhl__api_key_and_secret_for_developer_api' => 'Bitte erstellen Sie ein Entwicklerkonto und eine App. Aktivieren Sie MyAccountAPI und die einheitliche API für den Standortfinder.', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits' => 'Maximale Trefferanzahl', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits_1' => '1', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits_2' => '2', diff --git a/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php b/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php index d493cd2f..60654e4f 100644 --- a/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php +++ b/src/modules/mo/mo_dhl/Application/views/admin/en/module_options.php @@ -97,8 +97,6 @@ 'SHOP_MODULE_mo_dhl__retoure_receiver_country_AUT' => 'Austria', 'SHOP_MODULE_GROUP_mo_dhl__standortsuche' => 'Preferred delivery - Parcel shop finder', - 'SHOP_MODULE_mo_dhl__api_key_and_secret_for_developer_api' => 'Api key and api secret for developer API', - 'HELP_SHOP_MODULE_mo_dhl__api_key_and_secret_for_developer_api' => 'Please create a developer Account and an App. Activate MyAccountAPI and Location Finder Unified API.', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits' => 'Maximum number of hits', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits_1' => '1', 'SHOP_MODULE_mo_dhl__standortsuche_maximumHits_2' => '2', diff --git a/src/modules/mo/mo_dhl/Configurator.php b/src/modules/mo/mo_dhl/Configurator.php index 4ceaf0ff..8ca50dbc 100644 --- a/src/modules/mo/mo_dhl/Configurator.php +++ b/src/modules/mo/mo_dhl/Configurator.php @@ -50,14 +50,11 @@ protected function buildRestCredentials($forceUseProd = false) } /** - * @param false $forceUseProd * @return Credentials */ - protected function buildStandortsucheCredentials($forceUseProd = false) + protected function buildStandortsucheCredentials() { - return $this->isProductionEnvironment() || $forceUseProd - ? Credentials::createStandortsucheEndpoint($this->getStandortsucheKeyName(), $this->getProdApiKeyAndSecretForDeveloperAPI()) - : Credentials::createStandortsucheEndpoint($this->getStandortsucheKeyName(), $this->getSandboxApiKeyAndSecretForDeveloperAPI()); + return Credentials::createStandortsucheEndpoint($this->getStandortsucheKeyName(), $this->getStandortsuchePassword()); } /** @@ -96,7 +93,7 @@ protected function buildParcelShippingCredentials(): Credentials */ protected function buildAuthenticationCredentials(): Credentials { - $clientId = $this->getProdApiKeyAndSecretForDeveloperAPI(); + $clientId = $this->getAuthenticationClientId(); $clientSecret = $this->getAuthenticationClientSecret(); return $this->isProductionEnvironment() ? Credentials::createProductionAuthenticationCredentials($clientId, $clientSecret) @@ -202,6 +199,11 @@ abstract protected function getCustomerParcelShippingUsername(); */ abstract protected function getCustomerParcelShippingPassword(); + /** + * @return string + */ + abstract protected function getAuthenticationClientId(); + /** * @return string */ @@ -300,12 +302,7 @@ abstract protected function getStandortsucheKeyName(); /** * @return string */ - abstract protected function getProdApiKeyAndSecretForDeveloperAPI(); - - /** - * @return string - */ - abstract protected function getSandboxApiKeyAndSecretForDeveloperAPI(); + abstract protected function getStandortsuchePassword(); /** * @return string diff --git a/src/modules/mo/mo_dhl/metadata.php b/src/modules/mo/mo_dhl/metadata.php index 1a1d7bd7..cde45ce2 100644 --- a/src/modules/mo/mo_dhl/metadata.php +++ b/src/modules/mo/mo_dhl/metadata.php @@ -510,11 +510,6 @@ 'value' => 'DEU', 'constraints' => 'DEU|AUT', ], - [ - 'group' => 'mo_dhl__standortsuche', - 'name' => 'mo_dhl__api_key_and_secret_for_developer_api', - 'type' => 'str', - ], [ 'group' => 'mo_dhl__standortsuche', 'name' => 'mo_dhl__standortsuche_maximumHits', diff --git a/tests/ConfiguratorTest.php b/tests/ConfiguratorTest.php index eb166192..bdaaef4c 100644 --- a/tests/ConfiguratorTest.php +++ b/tests/ConfiguratorTest.php @@ -25,8 +25,7 @@ protected function getConfiguratorMock() 'getCustomerRetoureLogin', 'getCustomerRetourePassword', 'getStandortsucheKeyName', - 'getProdApiKeyAndSecretForDeveloperAPI', - 'getSandboxApiKeyAndSecretForDeveloperAPI', + 'getStandortsuchePassword', 'getInternetmarkeProdLogin', 'getInternetmarkeProdSignature', 'getInternetmarkeSandboxLogin', @@ -38,6 +37,7 @@ protected function getConfiguratorMock() 'getProdWSLogin', 'getProdWSPassword', 'getCustomerProdWSMandantId', + 'getAuthenticationClientId', 'getAuthenticationClientSecret', 'getAuthenticationUsername', 'getAuthenticationPassword', diff --git a/tests/TestConfigurator.php b/tests/TestConfigurator.php index 1a97acf0..86b1dbb4 100644 --- a/tests/TestConfigurator.php +++ b/tests/TestConfigurator.php @@ -107,19 +107,11 @@ protected function getStandortsucheKeyName() /** * @return string */ - protected function getProdApiKeyAndSecretForDeveloperAPI() + protected function getStandortsuchePassword() { return 'PROD_STANDORTSUCHE_API_PASSWORD'; } - /** - * @return string - */ - protected function getSandboxApiKeyAndSecretForDeveloperAPI() - { - return \Mediaopt\DHL\Adapter\DHLConfigurator::TEST_API_KEY_AND_SECRET_FOR_DEVELOPER_API; - } - /** * @return string */ @@ -216,12 +208,20 @@ protected function getCustomerProdWSMandantId() return \Mediaopt\DHL\Adapter\DHLConfigurator::PRODWS_MANDANT_ID; } + /** + * @return string + */ + protected function getAuthenticationClientId() + { + return \Mediaopt\DHL\Adapter\DHLConfigurator::DHL_DEVELOPER_API_KEY; + } + /** * @return string */ protected function getAuthenticationClientSecret() { - return \Mediaopt\DHL\Adapter\DHLConfigurator::TEST_AUTHENTICATION_CLIENT_SECRET; + return \Mediaopt\DHL\Adapter\DHLConfigurator::DHL_DEVELOPER_API_SECRET; } /** From 9ee0d49e4459be26d5794ea9969467b1544872d2 Mon Sep 17 00:00:00 2001 From: bohdan Date: Tue, 19 Mar 2024 09:27:30 +0100 Subject: [PATCH 13/16] fix after CR --- tests/TestConfigurator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestConfigurator.php b/tests/TestConfigurator.php index 86b1dbb4..e4d34598 100644 --- a/tests/TestConfigurator.php +++ b/tests/TestConfigurator.php @@ -109,7 +109,7 @@ protected function getStandortsucheKeyName() */ protected function getStandortsuchePassword() { - return 'PROD_STANDORTSUCHE_API_PASSWORD'; + return \Mediaopt\DHL\Adapter\DHLConfigurator::DHL_DEVELOPER_API_KEY; } /** From 4e7d910eca195496aa9c6534156c2e6287bf8c2d Mon Sep 17 00:00:00 2001 From: bohdan Date: Mon, 25 Mar 2024 11:53:10 +0100 Subject: [PATCH 14/16] fix after CR --- tests/Api/StandortsucheTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Api/StandortsucheTest.php b/tests/Api/StandortsucheTest.php index ec93acd2..d32f23d7 100644 --- a/tests/Api/StandortsucheTest.php +++ b/tests/Api/StandortsucheTest.php @@ -155,7 +155,7 @@ public function testGettingTheRightCityWithDirtyAddress() public function testGettingEmptyResultOutsideGermany() { - $address = $this->buildAddress('', '', '1100', 'Wien', '', ''); + $address = $this->buildAddress('', '', '75019', 'Paris', '', ''); $list = $this->buildStandortsuche()->getParcellocationByAddress($address); $this->assertEmpty($list->toArray(), 'Got result for non german address: ' . implode(' ', $address->toArray())); } From 34f8cba2f023b80c1b03b663d32b73afbdc1ba07 Mon Sep 17 00:00:00 2001 From: bohdan Date: Mon, 25 Mar 2024 13:08:21 +0100 Subject: [PATCH 15/16] fix after CR --- tests/Api/StandortsucheTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Api/StandortsucheTest.php b/tests/Api/StandortsucheTest.php index d32f23d7..ad27e334 100644 --- a/tests/Api/StandortsucheTest.php +++ b/tests/Api/StandortsucheTest.php @@ -47,7 +47,7 @@ public function buildStandortsuche() */ public function buildSampleAddress() { - return $this->buildAddress('Elbestr.', '28', '12045', 'Berlin', '', 'DEU', 'DE'); + return $this->buildAddress('Wilmersdorfer Str.', '94', '10629', 'Berlin', '', 'DEU', 'DE'); } public function buildSampleAddressString() From 75143fb6d9024ff09429678042eaedb4fae141b0 Mon Sep 17 00:00:00 2001 From: mbe Date: Fri, 19 Apr 2024 09:00:24 +0200 Subject: [PATCH 16/16] #34741 adjust query for existing shipping methods --- .../Controller/Admin/ModuleConfiguration.php | 88 ++++++++++--------- src/modules/mo/mo_dhl/Configurator.php | 2 +- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php index 167623da..a8c9c04a 100644 --- a/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php +++ b/src/modules/mo/mo_dhl/Application/Controller/Admin/ModuleConfiguration.php @@ -10,7 +10,6 @@ use Mediaopt\DHL\Adapter\DHLAdapter; use Mediaopt\DHL\Adapter\ParcelShippingConverter; -use Mediaopt\DHL\Api\Authentication\Model\TokenPostBody; use Mediaopt\DHL\Api\GKV; use Mediaopt\DHL\Api\GKV\CountryType; use Mediaopt\DHL\Api\GKV\NameType; @@ -36,6 +35,9 @@ use Mediaopt\DHL\Shipment\Process; use OxidEsales\Eshop\Application\Model\DeliverySet; use OxidEsales\Eshop\Core\Registry; +use OxidEsales\Eshop\Core\UtilsView; +use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; +use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface; /** @noinspection LongInheritanceChainInspection */ @@ -60,22 +62,22 @@ class ModuleConfiguration extends ModuleConfiguration_parent * @var string[] */ const INTERNAL_PROCESSES = [ - 'PAKET' => 'DHL PAKET', - 'PAKET_INTERNATIONAL' => 'PAKET INTERNATIONAL', - 'EUROPAKET' => 'DHL EUROPAKET', - 'WARENPOST' => 'Warenpost', - 'WARENPOST_INTERNATIONAL'=> 'Warenpost International', + 'PAKET' => 'DHL PAKET', + 'PAKET_INTERNATIONAL' => 'PAKET INTERNATIONAL', + 'EUROPAKET' => 'DHL EUROPAKET', + 'WARENPOST' => 'Warenpost', + 'WARENPOST_INTERNATIONAL' => 'Warenpost International', ]; /** * @var string[] */ const INTERNAL_PROCESSES_INVERSE = [ - 'DHL PAKET' => 'PAKET', - 'PAKET INTERNATIONAL' => 'PAKET_INTERNATIONAL', - 'DHL EUROPAKET' => 'EUROPAKET', - 'Warenpost' => 'WARENPOST', - 'Warenpost International' => 'WARENPOST_INTERNATIONAL', + 'DHL PAKET' => 'PAKET', + 'PAKET INTERNATIONAL' => 'PAKET_INTERNATIONAL', + 'DHL EUROPAKET' => 'EUROPAKET', + 'Warenpost' => 'WARENPOST', + 'Warenpost International' => 'WARENPOST_INTERNATIONAL', ]; var $SHIPPING_METHODS = []; @@ -154,7 +156,7 @@ protected function moReviewFilialroutingAlternativeEmail() return; } Registry::getConfig()->saveShopConfVar('str', $mailVariable, '', '', 'module:mo_dhl'); - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__FILIALROUTING_EMAIL_ERROR'); + Registry::get(UtilsView::class)->addErrorToDisplay('MO_DHL__FILIALROUTING_EMAIL_ERROR'); } /** @@ -176,7 +178,7 @@ protected function moReviewWeightSettings() } } if ($changed) { - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__ERROR_ WEIGHT_WITH_COMMA'); + Registry::get(UtilsView::class)->addErrorToDisplay('MO_DHL__ERROR_ WEIGHT_WITH_COMMA'); } } @@ -194,7 +196,7 @@ protected function moReviewEkp() Ekp::build($ekp); } catch (\InvalidArgumentException $exception) { Registry::getConfig()->saveShopConfVar('str', $ekpVariable, '', '', 'module:mo_dhl'); - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__EKP_ERROR'); + Registry::get(UtilsView::class)->addErrorToDisplay('MO_DHL__EKP_ERROR'); } } @@ -206,7 +208,7 @@ public function moSaveAndCheckLogin() $this->save(); $adapter = new DHLAdapter(); if (Registry::getConfig()->getConfigParam('mo_dhl__account_sandbox')) { - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__CHECK_FOR_SANDBOX_NOT_POSSIBLE'); + Registry::get(UtilsView::class)->addErrorToDisplay('MO_DHL__CHECK_FOR_SANDBOX_NOT_POSSIBLE'); return; } $this->checkWunschpaket($adapter); @@ -215,7 +217,7 @@ public function moSaveAndCheckLogin() return !$deliverySet->oxdeliveryset__mo_dhl_excluded->value; }); if ($deliveries === []) { - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__NO_DELIVERYSET'); + Registry::get(UtilsView::class)->addErrorToDisplay('MO_DHL__NO_DELIVERYSET'); return; } $gkv = $adapter->buildGKV(); @@ -233,18 +235,18 @@ public function moSaveAndCheckLogin() * @param String $detailName * @return bool */ - public function checkForShippingAlreadyExist(String $detailName): bool + public function checkForShippingAlreadyExist(string $detailName): bool { if (count($this->SHIPPING_METHODS) === 0) { - $this->SHIPPING_METHODS = Registry::get(\OxidEsales\Eshop\Application\Model\DeliverySetList::class)->getDeliverySetList(null, null); + /** @var QueryBuilderFactoryInterface $queryBuilder */ + $queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class); + $this->SHIPPING_METHODS = array_map( + fn($shippingMethod) => self::INTERNAL_PROCESSES[$shippingMethod], + $queryBuilder->create()->select('mo_dhl_process')->from('oxdeliveryset')->execute()->fetchFirstColumn() + ); } - return (bool) array_filter( - $this->SHIPPING_METHODS, - fn($shippingMethod) => - self::INTERNAL_PROCESSES[$shippingMethod->oxdeliveryset__mo_dhl_process->value] === - $detailName - ); + return in_array($detailName, $this->SHIPPING_METHODS, true); } /** @@ -258,10 +260,10 @@ private function createNewShippingMethod(Detail $detail): void } $oDelSet = oxNew(DeliverySet::class); $aParams = [ - "oxdeliveryset__oxid" => null, - "oxdeliveryset__oxtitle" => $detail->getBookingText(), - "oxdeliveryset__mo_dhl_process" => self::INTERNAL_PROCESSES_INVERSE[$detail->getProduct()->getName()], - "oxdeliveryset__mo_dhl_participation" => substr($detail->getBillingNumber(), -2) + "oxdeliveryset__oxid" => null, + "oxdeliveryset__oxtitle" => $detail->getBookingText(), + "oxdeliveryset__mo_dhl_process" => self::INTERNAL_PROCESSES_INVERSE[$detail->getProduct()->getName()], + "oxdeliveryset__mo_dhl_participation" => substr($detail->getBillingNumber(), -2) ]; $oDelSet->setLanguage(0); @@ -355,11 +357,11 @@ private function checkWunschpaket(DHLAdapter $adapter) try { $days = $adapter->buildWunschpaket()->getPreferredDays('12045'); } catch (\RuntimeException $e) { - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay($e->getMessage()); + Registry::get(UtilsView::class)->addErrorToDisplay($e->getMessage()); return; } if (empty($days)) { - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__INCORRECT_CREDENTIALS'); + Registry::get(UtilsView::class)->addErrorToDisplay('MO_DHL__INCORRECT_CREDENTIALS'); } } @@ -368,10 +370,10 @@ private function checkInternetmarke(Internetmarke $internetmarke) try { $response = $internetmarke->authenticateUser(); $message = sprintf(Registry::getLang()->translateString('MO_DHL__WALLAT_BALANCE_CHECK'), $response->getWalletBalance() / 100.); - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay($message); + Registry::get(UtilsView::class)->addErrorToDisplay($message); } catch (\RuntimeException $e) { $e = $e->getPrevious() ?: $e; - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay($e->getMessage()); + Registry::get(UtilsView::class)->addErrorToDisplay($e->getMessage()); } } @@ -381,10 +383,10 @@ private function checkInternetmarke(Internetmarke $internetmarke) * @param DeliverySet $deliveryset * @throws \Exception */ - private function checkShippingAPIs(\Mediaopt\DHL\Api\GKV $gkv, Client $parcelShipping, $deliveryset) + private function checkShippingAPIs(GKV $gkv, Client $parcelShipping, $deliveryset) { $lang = Registry::getLang(); - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay($lang->translateString('MO_DHL__CHECKING_DELIVERYSET') . $deliveryset->oxdeliveryset__oxtitle->value); + Registry::get(UtilsView::class)->addErrorToDisplay($lang->translateString('MO_DHL__CHECKING_DELIVERYSET') . $deliveryset->oxdeliveryset__oxtitle->value); try { if (!$deliveryset->oxdeliveryset__mo_dhl_process->value) { throw new \InvalidArgumentException('MO_DHL__ERROR_PROCESS_IS_MISSING'); @@ -404,11 +406,11 @@ private function checkShippingAPIs(\Mediaopt\DHL\Api\GKV $gkv, Client $parcelShi if ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300) { $payload = json_decode($response->getBody()->getContents(), true); if ($payload['status'] == 401) { - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__LOGIN_FAILED'); + Registry::get(UtilsView::class)->addErrorToDisplay('MO_DHL__LOGIN_FAILED'); return; } foreach ($converter->extractErrorsFromResponsePayload($payload) as $error) { - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay($error); + Registry::get(UtilsView::class)->addErrorToDisplay($error); } return; } @@ -417,16 +419,16 @@ private function checkShippingAPIs(\Mediaopt\DHL\Api\GKV $gkv, Client $parcelShi if ($response->getStatus()->getStatusCode() !== 0) { switch ($response->getStatus()->getStatusText()) { case 'login failed': - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__LOGIN_FAILED'); + Registry::get(UtilsView::class)->addErrorToDisplay('MO_DHL__LOGIN_FAILED'); return; default: - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay($response->getStatus()->getStatusText()); + Registry::get(UtilsView::class)->addErrorToDisplay($response->getStatus()->getStatusText()); if (!isset($response->getValidationState()[0])) { return; } $errors = array_unique($response->getValidationState()[0]->getStatus()->getStatusMessage()); foreach ($errors as $error) { - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay($error); + Registry::get(UtilsView::class)->addErrorToDisplay($error); } return; } @@ -434,18 +436,18 @@ private function checkShippingAPIs(\Mediaopt\DHL\Api\GKV $gkv, Client $parcelShi } } catch (\RuntimeException $e) { $e = $e->getPrevious() ?: $e; - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay($e->getMessage()); + Registry::get(UtilsView::class)->addErrorToDisplay($e->getMessage()); return; } - Registry::get(\OxidEsales\Eshop\Core\UtilsView::class)->addErrorToDisplay('MO_DHL__CORRECT_CREDENTIALS'); + Registry::get(UtilsView::class)->addErrorToDisplay('MO_DHL__CORRECT_CREDENTIALS'); } /** - * @param \Mediaopt\DHL\Api\GKV $gkv + * @param GKV $gkv * @param DeliverySet $deliveryset * @return Shipment */ - protected function createTestShipment(\Mediaopt\DHL\Api\GKV $gkv, $deliveryset): Shipment + protected function createTestShipment(GKV $gkv, $deliveryset): Shipment { $process = Process::build($deliveryset->oxdeliveryset__mo_dhl_process->value); $receiverCountryCode = $process->isInternational() ? 'FR' : 'DE'; diff --git a/src/modules/mo/mo_dhl/Configurator.php b/src/modules/mo/mo_dhl/Configurator.php index 8ca50dbc..7eabf125 100644 --- a/src/modules/mo/mo_dhl/Configurator.php +++ b/src/modules/mo/mo_dhl/Configurator.php @@ -431,7 +431,7 @@ private function buildAuthenticationToken(LoggerInterface $logger): string $userPass = $this->buildAuthenticationUserCredentials(); $httpClient = \Http\Discovery\Psr18ClientDiscovery::find(); $plugins = array(); - $uri = \Http\Discovery\Psr17FactoryDiscovery::findUrlFactory()->createUri($credentials->getEndpoint()); + $uri = \Http\Discovery\Psr17FactoryDiscovery::findUriFactory()->createUri($credentials->getEndpoint()); $plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($uri); $plugins[] = new \Http\Client\Common\Plugin\AddPathPlugin($uri); $httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins);