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

ShipmentValidationRequest XML issue #9

Closed
jason-FLS opened this issue Jan 5, 2015 · 3 comments
Closed

ShipmentValidationRequest XML issue #9

jason-FLS opened this issue Jan 5, 2015 · 3 comments

Comments

@jason-FLS
Copy link

Hi Al-fallouji,
Thank you for providing this, its been extremely helpful!

I ran into an issue while using the ShipmentValidateRequest object. Whenever I try to convert this object into XML, I get an XML piece element placed in another XML piece element.The XML in question. I am using the ShipmentValidateRequest located in Entity/AM folder.

     <Pieces>
         <Piece>
            <Piece>
               <PieceID>1</PieceID>
               <PackageType>CP</PackageType>
               <Weight>2</Weight>
               <Width>1</Width>
               <Height>1</Height>
               <Depth>1</Depth>
               <PieceContents>box</PieceContents>
            </Piece>
         </Piece>
      </Pieces>

the code in question I'm using to add pieces to the object:

foreach ($this->packages as $package) {
 $piece = new Piece();
 $piece->PieceID = $package->id;
 $piece->PackageType = 'CP'; 
 $piece->Weight = ceil($package->weight);
 $piece->Width = ceil($package->width);
 $piece->Height = ceil($package->height);
 $piece->Depth = ceil($package->length);

 $shipmentConfirmationRequest->ShipmentDetails->addPiece($piece);
}

I don't know if its an issue with the toXML function that your client is using, or if its another issue. Any help would be appreciated.

Thank you for your time,

Jason

@suriyabaskaran
Copy link

@jason-FLS , How did you solve this issue?

@jason-FLS
Copy link
Author

@suriyabaskaran In the ShipmentDetails.php, just change the Pieces parameter type to accept a Piece object instead of a Pieces object. Its not a great fix but it seemed to do the trick for me.

'Pieces' => array(
            'type' => 'Piece',
            'required' => false,
            'subobject' => true,
            'multivalues' => true,
        ),

@alfallouji
Copy link
Owner

@jason-FLS : this is actually the right way to do it :)

I just updated the master branch.

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