aimeos / ai-client-jsonapi

Aimeos frontend JSON API
GNU Lesser General Public License v3.0
28 stars 6 forks source link

Allowed basket/product methods in basket jsonapi tresponse #11

Closed bu-jgerhold closed 2 years ago

bu-jgerhold commented 3 years ago

Hi!

I think more methods should be added here:

https://github.com/aimeos/ai-client-jsonapi/blob/ea88db283f2dda2c994829101a5dc996278ec6be/client/jsonapi/templates/basket/standard.php#L315

"basket/product": {
    "href": "<?= $this->url( $target, $cntl, $action, ['resource' => 'basket', 'id' => $basketId, 'related' => 'product'], [], $config ); ?>",
    "allow": ["POST"]
},

client/jsonapi/src/Client/JsonApi/Basket/Product/Standard.php allows multiple items to be deleted by a body with an array of Objects with an id attribute.

https://github.com/aimeos/ai-client-jsonapi/blob/master/client/jsonapi/src/Client/JsonApi/Basket/Product/Standard.php#L79

This probably is true. for other methods and other basket types.

aimeos commented 3 years ago

No, for the base basket only adding new products via POST is possible. The DELETE and PATCH methods are available for each product item: https://github.com/aimeos/ai-client-jsonapi/blob/ea88db283f2dda2c994829101a5dc996278ec6be/client/jsonapi/templates/basket/standard.php#L123 This is also true for bulk operations because they need to be sent to the basket/product endpoint, not the basket endpoint itself.

bu-jgerhold commented 3 years ago

No, for the base basket only adding new products via POST is possible. The DELETE and PATCH methods are available for each product item:

https://github.com/aimeos/ai-client-jsonapi/blob/ea88db283f2dda2c994829101a5dc996278ec6be/client/jsonapi/templates/basket/standard.php#L123

This is also true for bulk operations because they need to be sent to the basket/product endpoint, not the basket endpoint itself.

This link of the product item includes the items relatedid as get parameter and the body will be ignored.

https://github.com/aimeos/ai-client-jsonapi/blob/master/client/jsonapi/src/Client/JsonApi/Basket/Product/Standard.php#L63

The link I referenced above is the same link without the relatedid get parameter.

aimeos commented 3 years ago

OK, maybe a DELETE is acceptable. Can you create a PR with a patch?

aimeos commented 2 years ago

Added in https://github.com/aimeos/ai-client-jsonapi/commit/9d4ecc0b23a53479a628b3ed5dfbf65af3c3cde0