-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IBX-8947: Add 2 cart REST routes; update Cart examples #2501
base: master
Are you sure you want to change the base?
Conversation
/api/ibexa/v2/cart/{identifier}/validate /api/ibexa/v2/cart/authorize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not able to find a way to add a context like JSON does.
<CartCreate>
<name>Default</name>
<currencyCode>EUR</currencyCode>
<context>
<foo>bar</foo>
</context>
</CartCreate>
?xml version="1.0" encoding="UTF-8"?>
<ErrorMessage media-type="application/vnd.ibexa.api.ErrorMessage+xml">
<errorCode>500</errorCode>
<errorMessage>Internal Server Error</errorMessage>
<errorDescription>Array to string conversion</errorDescription>
<trace>…</trace>
<file>/var/www/html/vendor/ibexa/rest/src/lib/Output/Generator/Xml.php</file>
<line>169</line>
</ErrorMessage>
{ | ||
"CartConstraintViolationList": { | ||
"_media-type": "application\/vnd.ibexa.api.CartConstraintViolationList+json", | ||
"violations": [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't manage to insert invalid data on purpose.
I tried to add a product with no stock, it's added without any error. I thought https://github.com/ibexa/cart/blob/main/src/lib/Validation/Constraint/ProductAvailableValidator.php would complain, but no. On the storefront, the product is indicated as Out of stock but if I edit the HTML and remove the disabled
attribute from the "Add to cart" button, I can add it to the cart without error. It seems there is no product availability around there.
I tried to add a product/entry called 'test' to match the example without having configuring proper TVA for the region.
curl "$baseUri/cart/$identifier/entry" \
-b anonymous_cookies.txt -H "X-CSRF-Token: $anonymous_token" \
-H "Content-Type: $mimeTypePrefix.CartEntryAdd+$format" \
--data "@$restRefDir/input/examples/cart/entry/POST/CartEntryAdd.json.example" \
;
The cart is validated on the fly and I get the following error:
<?xml version="1.0" encoding="UTF-8"?>
<ErrorMessage media-type="application/vnd.ibexa.api.ErrorMessage+xml">
<errorCode>406</errorCode>
<errorMessage>Not Acceptable</errorMessage>
<errorDescription>Argument '$entryAddStruct' is invalid: Product "test" has no VAT Category set.</errorDescription>
<trace>…</trace>
<file>/var/www/html/vendor/ibexa/cart/src/lib/Service/CartService.php</file>
<line>239</line>
</ErrorMessage>
I tried to fix the error and reintroduce it later but fail. I had error 500 on every page of the DXP for a region VAT not found.
I stopped my test there.
properties: | ||
violations: | ||
type: array | ||
items: CartConstraintViolation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a CartConstraintViolationWrapper is needed but I didn't manage to product constraint violation to study it.
Add two routes:
/api/ibexa/v2/cart/{identifier}/validate
added in ibexa/cart#38 (and asked in IBX-8947)/api/ibexa/v2/cart/authorize
added in ibexa/cart#80Add XML examples and update JSON examples.
Examples generation
Done with
Checklist