Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting error while hit ShipmentRequest from sample #45

Open
ablyshashi opened this issue Feb 27, 2020 · 2 comments
Open

getting error while hit ShipmentRequest from sample #45

ablyshashi opened this issue Feb 27, 2020 · 2 comments

Comments

@ablyshashi
Copy link

Notice: Trying to get property 'ConditionCode' of non-object in /home/shashi/projects/dhl-api/DHL/Entity/Base.php on line 235

Fatal error: Uncaught InvalidArgumentException: Field : Barcodes is not defined for DHL\Entity\GB\ShipmentResponse in /home/shashi/projects/dhl-api/DHL/Datatype/Base.php:272 Stack trace: #0 /home/shashi/projects/dhl-api/DHL/Entity/Base.php(256): DHL\Datatype\Base->__get('Barcodes') #1 /home/shashi/projects/dhl-api/ShipmentRequest.php(158): DHL\Entity\Base->initFromXML(Object(SimpleXMLElement)) #2 {main} thrown in /home/shashi/projects/dhl-api/DHL/Datatype/Base.php on line 272
ShipmentRequest.zip

@anargoz
Copy link

anargoz commented Mar 29, 2020

Hi, it seems to be case sensitive and some fields are defined with Upper case inside "/DHL/Entity/GB/ShipmentResponse.php"

@PierreLebedel
Copy link

Hi, you can alterate the xml string by replacing the Barcode tag with BarCode to satisfy the entity model.

$xml = $client->call($sample);
$xml = str_replace(array('<Barcodes>', '</Barcodes>'), array('<BarCodes>', '</BarCodes>'), $xml);
$response = new ShipmentResponse();
$response->initFromXML($xml);

or try to override the ShipmentResponse class with something like the following, but namespace issues arise later

use DHL\Entity\GB\ShipmentResponse;
class MyShipmentResponse extends ShipmentResponse {
    public function __construct()
    {
        $this->_bodyParams['Barcodes'] = $this->_bodyParams['BarCodes'];
        unset($this->_bodyParams['BarCodes']);
        parent::__construct();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants