| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class BaseResponse. |
| 4 |
* |
| 5 |
* @package Packetery\Core\Api\Soap\Response |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace Packetery\Core\Api\Soap\Response; |
| 11 |
|
| 12 |
/** |
| 13 |
* Class BaseResponse. |
| 14 |
* |
| 15 |
* @package Packetery\Core\Api\Soap\Response |
| 16 |
*/ |
| 17 |
class BaseResponse { |
| 18 |
|
| 19 |
/** |
| 20 |
* Fault identifier. |
| 21 |
* |
| 22 |
* @var ?string |
| 23 |
*/ |
| 24 |
protected $fault; |
| 25 |
|
| 26 |
/** |
| 27 |
* Fault string. |
| 28 |
* |
| 29 |
* @var ?string |
| 30 |
*/ |
| 31 |
private $faultString; |
| 32 |
|
| 33 |
/** |
| 34 |
* Checks if is faulty. |
| 35 |
* |
| 36 |
* @return bool |
| 37 |
*/ |
| 38 |
public function hasFault(): bool { |
| 39 |
return (bool) $this->fault; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Checks if password is faulty. |
| 44 |
* |
| 45 |
* @return bool |
| 46 |
*/ |
| 47 |
public function hasWrongPassword(): bool { |
| 48 |
return ( 'IncorrectApiPasswordFault' === $this->fault ); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Tells if API returns PacketIdsFault fault. |
| 53 |
* |
| 54 |
* @return bool |
| 55 |
*/ |
| 56 |
public function hasPacketIdsFault(): bool { |
| 57 |
return 'PacketIdsFault' === $this->fault; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Tells if API returns PacketIdFault fault. |
| 62 |
* |
| 63 |
* @return bool |
| 64 |
*/ |
| 65 |
public function hasPacketIdFault(): bool { |
| 66 |
return 'PacketIdFault' === $this->fault; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Tells if API returns InvalidCourierNumber fault. |
| 71 |
* |
| 72 |
* @return bool |
| 73 |
*/ |
| 74 |
public function hasInvalidCourierNumberFault(): bool { |
| 75 |
return 'InvalidCourierNumber' === $this->fault; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Sets fault identifier. |
| 80 |
* |
| 81 |
* @param string $fault Fault identifier. |
| 82 |
*/ |
| 83 |
public function setFault( string $fault ): void { |
| 84 |
$this->fault = $fault; |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Sets fault string. |
| 89 |
* |
| 90 |
* @param string $faultString Fault string. |
| 91 |
*/ |
| 92 |
public function setFaultString( string $faultString ): void { |
| 93 |
$this->faultString = $faultString; |
| 94 |
} |
| 95 |
|
| 96 |
/** |
| 97 |
* Gets fault string. |
| 98 |
* |
| 99 |
* @return string|null |
| 100 |
*/ |
| 101 |
public function getFaultString(): ?string { |
| 102 |
return $this->faultString; |
| 103 |
} |
| 104 |
|
| 105 |
} |
| 106 |
|