Bynder / bynder-php-sdk

SDK in PHP for integration with Bynder
MIT License
14 stars 22 forks source link

getMediaList uses undocumented "query" parameter #50

Closed svanrintel closed 2 years ago

svanrintel commented 2 years ago

The Bynder drupal module has an update metadata button to update the metadata of every Bynder asset used in Drupal. In this process the method 'getMediaList' is used where a list of Bynder asset IDs is passed into the 'query' parameter. Better would be to use the ids parameter for accurate results.

Also it happens that passing a Bynder asset id doesn't return the actual Bynder asset in the result list while it works when using the ids parameter.

hixfield commented 2 years ago

As a result, the update meta data button does not work correctly in Drupal (anymore)

TimBloembergen commented 2 years ago

Hi @svanrintel & @hixfield

This isn't an issue on the SDK itself but with the parameters that are being passed in the query within the Drupal plugin. Could you create this issue on Drupal.org? I've also notified our partners to have a look at this and see if they can resolve it.

Thanks!

svanrintel commented 2 years ago

Hi @TimBloembergen, thank you for your quick response.

I'm not sure if it is an issue in the Drupal module because the query parameter is used in the AssetBankManager L58 of this SDK. It is this query parameter that I can't find in the API documentation on https://bynder.docs.apiary.io/#reference/assets/asset-operations/retrieve-assets.

Also requesting /api/v4/media/?query=6923D63F-A12B-4760-BC2490707161E71E with Postman doesn't return the actual Bynder asset in the results. Instead it returns a list of the last 50 added Bynder assets I assume. /api/v4/media/?ids=6923D63F-A12B-4760-BC2490707161E71E does return the correct asset.

TimBloembergen commented 2 years ago

@svanrintel no worries!

The query that you see is the variable, it can be filled with the actual parameters that we have available (listed in the docs). The use of the parameters is done like we've put in as an sample app:

https://github.com/Bynder/bynder-php-sdk/blob/8838ecaa7da43c2820bfd36c344d505948d190ae/sample/sample.php#L88-L95

Like so:

$query = [
    'ids' => list_of_asset_ids_gohere
];

If you'd then run the request; $mediaListPromise = $assetBankManager->getMediaList($query);

You will be able to retrieve the assets that you requested by passing the ids in the query by using the ids parameter. So this should be fixed if it's broken within the Drupal implementation.