Skip to content

Commit

Permalink
Prepare for the removal of SOAP support
Browse files Browse the repository at this point in the history
  • Loading branch information
firstred committed Apr 10, 2023
1 parent 4e4e8d0 commit d907aed
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/Entity/SOAP/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@
use Firstred\PostNL\Service\BarcodeService;
use Firstred\PostNL\Service\ConfirmingService;
use Firstred\PostNL\Service\LabellingService;
use JetBrains\PhpStorm\Deprecated;

/**
* Class Body.
*
* NOTE: this class has been introduced for deserializing
*
* @since 1.0.0
* @deprecated 1.4.1 SOAP support is going to be removed
*/
#[Deprecated]
class Body extends AbstractEntity
{
/** @var array */
Expand Down
3 changes: 3 additions & 0 deletions src/Entity/SOAP/Envelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Firstred\PostNL\Service\BarcodeService;
use Firstred\PostNL\Service\ConfirmingService;
use Firstred\PostNL\Service\LabellingService;
use JetBrains\PhpStorm\Deprecated;

/**
* Class Envelope.
Expand All @@ -42,7 +43,9 @@
* NOTE: this class has been introduced for deserializing
*
* @since 1.0.0
* @deprecated 1.4.1 SOAP support is going to be removed
*/
#[Deprecated]
class Envelope extends AbstractEntity
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Entity/SOAP/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@
namespace Firstred\PostNL\Entity\SOAP;

use Firstred\PostNL\Entity\AbstractEntity;
use JetBrains\PhpStorm\Deprecated;

/**
* Class Header.
*
* NOTE: this class has been introduced for deserializing
*
* @since 1.0.0
* @deprecated 1.4.1 SOAP support is going to be removed
*/
#[Deprecated]
class Header extends AbstractEntity
{
}
3 changes: 3 additions & 0 deletions src/Entity/SOAP/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace Firstred\PostNL\Entity\SOAP;

use Firstred\PostNL\Entity\AbstractEntity;
use JetBrains\PhpStorm\Deprecated;

/**
* Class Security.
Expand All @@ -35,7 +36,9 @@
* @method Security setUserNameToken(UsernameToken $UserNameToken)
*
* @since 1.0.0
* @deprecated 1.4.1 SOAP support is going to be removed
*/
#[Deprecated]
class Security extends AbstractEntity
{
const SECURITY_NAMESPACE = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/SOAP/UsernameToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* @method UsernameToken setPassword(string|null $Password = null)
*
* @since 1.0.0
* @deprecated 1.4.0
* @deprecated 1.4.0 SOAP support is going to be removed
*/
#[Deprecated]
class UsernameToken extends AbstractEntity
Expand Down
54 changes: 42 additions & 12 deletions src/PostNL.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,17 @@ public function __construct(
public function setToken($apiKey)
{
if ($apiKey instanceof UsernameToken) {
$this->apiKey = $apiKey;
static::triggerDeprecation(
'firstred/postnl-api-php',
'1.4.1',
'Use a string for the API key instead of a `UserNameToken`'
);

$this->apiKey = $apiKey->getPassword();

return $this;
} elseif (is_string($apiKey)) {
$this->apiKey = new UsernameToken(null, $apiKey);
$this->apiKey = $apiKey;

return $this;
}
Expand All @@ -367,14 +373,34 @@ public function setToken($apiKey)
* @return bool|string
*
* @since 1.0.0
* @deprecated 1.4.1 Use `getApiKey` instead
*/
#[Deprecated]
public function getRestApiKey()
{
if ($this->apiKey instanceof UsernameToken) {
return $this->apiKey->getPassword();
static::triggerDeprecation(
'firstred/postnl-api-php',
'1.4.1',
'`getRestApiKey` is deprecated, use `getApiKey` instead'
);

if (null == $this->apiKey) {
return false;
}

return false;
return $this->apiKey;
}

/**
* Get API Key.
*
* @return null|string
*
* @since 1.4.1
*/
public function getApiKey()
{
return $this->apiKey;
}

/**
Expand All @@ -383,14 +409,18 @@ public function getRestApiKey()
* @return bool|UsernameToken
*
* @since 1.0.0
* @deprecated 1.4.1 Use `getApiKey` instead
*/
#[Deprecated]
public function getToken()
{
if ($this->apiKey instanceof UsernameToken) {
return $this->apiKey;
}
static::triggerDeprecation(
'firstred/postnl-api-php',
'1.4.1',
'`getToken` is deprecated, use `getApiKey` instead'
);

return false;
return new UsernameToken(null, $this->apiKey);
}

/**
Expand Down Expand Up @@ -494,7 +524,7 @@ public function setMode($mode)
if ($mode === static::MODE_SOAP) {
static::triggerDeprecation(
'firstred/postnl-api-php',
'2.0.0',
'1.4.0',
'Using the SOAP API is deprecated. Please use the REST API instead.'
);
}
Expand Down Expand Up @@ -1023,7 +1053,7 @@ public function generateBarcode(
if ($eps) {
static::triggerDeprecation(
'firstred/postnl-api-php',
'2.0.0',
'1.4.0',
'EPS is no longer supported. Please avoid.'
);
}
Expand Down Expand Up @@ -2267,7 +2297,7 @@ public function findBarcodeSerie(
} else {
static::triggerDeprecation(
'firstred/postnl-api-php',
'2.0.0',
'1.4.0',
'EPS is no longer supported. Please avoid.'
);
}
Expand Down

0 comments on commit d907aed

Please sign in to comment.