Skip to content

AbstractStringEnum::__construct() fatal error when trying to access order detail #43

@krtcom

Description

@krtcom

When trying to call get function to access order detail e.g.:

$client = MpApiClient::createFromOptions('...', $options);
$orderClient = $client->orders();
$orderClient->get($mallID);

I get an error like this:

PHP Fatal error:  Uncaught TypeError: Argument 1 passed to MpApiClient\Common\Util\AbstractStringEnum::__construct() must be of the type string, null given, called in .../vendor/mallgroup/mpapi-client/src/Order/Entity/ConsignmentStatusHistoryItem.php on line 47 and defined in .../vendor/mallgroup/mpapi-client/src/Common/Util/AbstractStringEnum.php:22
Stack trace:
#0 .../vendor/mallgroup/mpapi-client/src/Order/Entity/ConsignmentStatusHistoryItem.php(47): MpApiClient\Common\Util\AbstractStringEnum->__construct()
#1 .../vendor/mallgroup/mpapi-client/src/Order/Entity/ConsignmentStatusHistoryIterator.php(29): MpApiClient\Order\Entity\ConsignmentStatusHistoryItem::createFromApi()
#2 [internal function]: MpApiClient\Order\Entity\ConsignmentStatusHistoryIterator::MpApiClient\Order\Entity\{closure}()
#3 .../vendor/mallgroup/mpapi-client/src/Order/Entity/Consignmen in .../vendor/mallgroup/mpapi-client/src/Common/Util/AbstractStringEnum.php on line 22

after closer inspection I noticed that data recieved from API contain consignment_status_history item:

...
["consignment_status_history"]=>
  array(7) {
    [0]=>
    array(4) {
      ["code"]=>
      string(7) "CREATED"
      ["date"]=>
      string(19) "2023-08-03 10:14:02"
      ["flags"]=>
      array(0) {
      }
      ["tracking_number"]=>
      string(14) "06505900906526"
    }
    ...

but ConsignmentStatusEnum is initialized with key 'status' (see ConsignmentStatusHistoryItem.php:47 and ConsignmentStatusEnum.php:46)

my understanding is that ConsignmentStatusEnum::KEY_NAME should be 'code' instead of 'status'.

If I am wrong and there is something I am missing, please point me to correct direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions