highsidelabs / walmart-api-php

PHP SDK for Walmart's Marketplace Partner, Content Provider, and 1P Supplier APIs.
https://highsidelabs.co
BSD 3-Clause "New" or "Revised" License
25 stars 21 forks source link

Internally requiring `autoload.php` breaks package usage #2

Closed brysonreece closed 1 year ago

brysonreece commented 1 year ago

Hey there, back again -- I wanted to point out an issue that my team is running into and wanted to make sure you were aware!


When installing the package through Composer and attempting to import various classes we're encountering the following:

WARNING  require_once(vendor/highsidelabs/walmart-api/src/../vendor/autoload.php): Failed to open stream: No such file or directory in vendor/highsidelabs/walmart-api/src/Walmart.php on line 5.

ERROR  Failed opening required 'vendor/highsidelabs/walmart-api/src/../vendor/autoload.php' (include_path='.:/opt/homebrew/Cellar/php/8.2.5_1/share/php/pear').

This is caused by the expectation that the vendor directory and dependencies are located in the root of the package, rather than the root of the project including the package. A temporary workaround is to cd into vendor/highside-labs/walmart-api and again running composer install.

Removing the various require_once calls that load autoload.php shouldn't impact functionality other than allowing it to be utilized by external projects again (which would handle loading autoload.php on their own).

If you need me to submit a PR, I can!

Thanks!

brysonreece commented 1 year ago

Additionally it seems that de-serializing into a TaxonomyResponseDTO object fails to populate category/sub-category attributes when fetching the Marketplace department list from the Utility API. We've been able to determine that it's caused by the Category/Subcategory attribute maps not pointing to the correct key in the API response data (as well as missing a couple). Not sure if a new DTO object needs to be created for that specific endpoint.

friendscottn commented 1 year ago

Hey @jlevers, I was about to put up a PR for this, but you beat me to it =) It looks like your latest commit got all but one of the require_once references. Walmart.php has the same require_once issue as all the other generated API classes that you fixed.

jlevers commented 1 year ago

Thanks @friendscottn! This should be all fixed in v0.4.0. Let me know if yall run into any other issues with it.

jlevers commented 1 year ago

Please note that the latest release contains breaking changes – client ID and client secret are now keys passed to the $options array parameter in the Configuration constructor, which is now the only parameter accepted by the Configuration constructor. The breaking change was necessary to fix #3 cleanly...I figured since this library is still in pre-release and there's only 22 total downloads, this wouldn't be too big an issue ;)