firstred / postnl-api-php

PostNL API PHP bindings
https://postnl-php.readthedocs.io
MIT License
26 stars 37 forks source link

Deserializable entity `CurrentStatusResponseShipment` contains unknown properties: `['Amount']` #84

Open bastiaansenglenn opened 1 year ago

bastiaansenglenn commented 1 year ago

When retrieving the state of the shipment with barcode we get the following deserialize error: Deserializable entityCurrentStatusResponseShipmentcontains unknown properties: ['Amount']

It is triggered by this function: $shipmentDetails = $this->client->getShippingStatusByBarcode($shipment->track_trace_code);

On the CurrentStatusResponseShipment class is amounts defined but the request response only contains amount. Response returned by PostNL API before deserialize;

  +"CurrentStatusResponseShipment": {#3937
    +"MainBarcode": "xxxxxxxxxxx"
    +"Barcode": "xxxxxxxxxxx"
    +"ShipmentAmount": "1"
    +"ShipmentCounter": "1"
    +"Customer": Customer object
    +"ProductCode": "003087"
    +"ProductDescription": "Verhoogde Aansprakelijkheid Zending"
    +"Reference": "xxxxxxx"
    +"Dimension": {#3918
      +"Height": "390"
      +"Length": "600"
      +"Volume": "93600"
      +"Weight": "8820"
      +"Width": "400"
    }
    +"Amount": {#3907
      +"VerzekerdBedrag": "EUR800.00"
    }
    +"ProductOptions": array:4 [
      0 => {#3941
        +"OptionCode": "27"
        +"CharacteristicCode": "122"
      }
      1 => {#3942
        +"OptionCode": "17"
        +"CharacteristicCode": "122"
      }
      2 => {#3943
        +"OptionCode": "21"
        +"CharacteristicCode": "122"
      }
      3 => {#3944
        +"OptionCode": "1"
        +"CharacteristicCode": "112"
      }
    ]
    +"Expectation": {#3945
      +"ETAFrom": "2023-10-11T14:35:00"
      +"ETATo": "2023-10-11T16:35:00"
    }
    +"Status": {#3946
      +"TimeStamp": "11-10-2023 15:32:16"
      +"StatusCode": "11"
      +"StatusDescription": "Zending afgeleverd"
      +"PhaseCode": "4"
      +"PhaseDescription": "Afgeleverd"
    }
    +"Addresses": array:2 [
      0 => Address object
      1 => Address object
    ]
  }
}

This error will only occur for me when retrieving status of an insured shipment. I can make a PR and change the amounts to amount on the CurrentStatusResponseShipment class, but i don't know if that has any impact on other users off this package.

If I need to provide more data, please let me know.