gabrielbull / php-ups-api

PHP Wrapper for all UPS API
MIT License
456 stars 255 forks source link

Wrong XML request for label recovery #256

Closed ygrenne closed 4 years ago

ygrenne commented 4 years ago

In the library, we have an incorrect "Shipping->recoverLabel" request. It always returns a response with LabelImageFormat Code = "gif" even if we pass another format, like "zpl"

...
 <LabelImage>
   <LabelImageFormat>
       <Code>gif</Code>
   </LabelImageFormat>
   <GraphicImage>.....</GraphicImage>
    <HTMLImage>.....</HTMLImage>
 </LabelImage>
...

It happens because request XML structure is wrong:

<LabelRecoveryRequest>
  <Request>
    <TransactionReference/>
    <RequestAction>LabelRecovery</RequestAction>
    <LabelSpecification>
      <LabelImageFormat>
        <Code>ZPL</Code>
      </LabelImageFormat>
    </LabelSpecification>
  </Request>
  <TrackingNumber>XXX</TrackingNumber>
</LabelRecoveryRequest>

The LabelSpecification is wrapped in the Request, but they should be siblings:

<LabelRecoveryRequest>
  <Request>
    <TransactionReference/>
    <RequestAction>LabelRecovery</RequestAction>
  </Request>
   <LabelSpecification>
      <LabelImageFormat>
        <Code>ZPL</Code>
      </LabelImageFormat>
  </LabelSpecification>
  <TrackingNumber>XXX</TrackingNumber>
</LabelRecoveryRequest>

Then response will be correct

gabrielbull commented 4 years ago

@ygrenne This library has no maintainer and is looking for one.