-
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
Changes from all commits
90ad68d
6dbb666
8063a6a
46a9062
a54aeb8
23252bd
8e3c909
dd25f24
ab81f32
e33db33
bbf0966
84b1795
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
{ | ||
"Cart": { | ||
"_media-type": "application/vnd.ibexa.api.Cart+json", | ||
"id": 12, | ||
"identifier": "fafccc4b-cce1-40d7-8d23-29ad41638581", | ||
"_media-type": "application\/vnd.ibexa.api.Cart+json", | ||
"id": 1, | ||
"identifier": "e79b5dba-c701-4c64-8032-73719a513e50", | ||
"name": "Default", | ||
"createdAt": "2023-10-12T10:02:51+00:00", | ||
"updatedAt": "2023-10-12T10:02:51+00:00", | ||
"createdAt": "2024-09-26T09:16:56+00:00", | ||
"updatedAt": "2024-09-26T09:16:56+00:00", | ||
"owner": { | ||
"_media-type": "application/vnd.ibexa.api.User+json", | ||
"_href": "/api/ibexa/v2/user/users/14" | ||
"_media-type": "application\/vnd.ibexa.api.User+json", | ||
"_href": "\/api\/ibexa\/v2\/user\/users\/10" | ||
}, | ||
"Currency": { | ||
"_media-type": "application/vnd.ibexa.api.Currency+json", | ||
"_media-type": "application\/vnd.ibexa.api.Currency+json", | ||
"id": 2, | ||
"code": "EUR", | ||
"subunits": 2, | ||
"enabled": true | ||
}, | ||
"entries": [] | ||
"entries": [], | ||
"context": { | ||
"foo": "bar" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Cart media-type="application/vnd.ibexa.api.Cart+xml"> | ||
<id>1</id> | ||
<identifier>e67d8f4c-95b5-423f-89d8-b2b81c37609b</identifier> | ||
<name>Default</name> | ||
<createdAt>2024-09-26T09:16:56+00:00</createdAt> | ||
<updatedAt>2024-09-26T09:16:56+00:00</updatedAt> | ||
<owner media-type="application/vnd.ibexa.api.User+xml" href="/api/ibexa/v2/user/users/10"/> | ||
<Currency media-type="application/vnd.ibexa.api.Currency+xml"> | ||
<id>2</id> | ||
<code>EUR</code> | ||
<subunits>2</subunits> | ||
<enabled>1</enabled> | ||
</Currency> | ||
</Cart> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<CartCreate> | ||
<name>Default</name> | ||
<currencyCode>EUR</currencyCode> | ||
</CartCreate> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"Token": { | ||
"_media-type": "application\/vnd.ibexa.api.Token+json", | ||
"value": "7b19308.RiDPaorwmJRyQoGajJiLMp843r30WaW-PH1CeH4oQyU.dkOXWOuFrvBfDPXY1t27YMx0hvyFH8fPUwoDNRl_D0sWDb4O3bb-20Q32A" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Token media-type="application/vnd.ibexa.api.Token+xml"> | ||
<value>eff5.w9r2Ws_zpjcopNJ8FRNVaplGlx19y4Mp2QP-eQWZDKc.-pe4Pam133xKzKQZLCdiIMkj2EgQ5rMdtlGTEEPPaOyHv6Y1iKTsZ2_OtQ</value> | ||
</Token> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"CartConstraintViolationList": { | ||
"_media-type": "application\/vnd.ibexa.api.CartConstraintViolationList+json", | ||
"violations": [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 I tried to add a product/entry called 'test' to match the example without having configuring proper TVA for the region.
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. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CartConstraintViolationList media-type="application/vnd.ibexa.api.CartConstraintViolationList+xml"/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"CartView": { | ||
"_media-type": "application\/vnd.ibexa.api.CartView+json", | ||
"identifier": "loadUserCarts", | ||
"Result": { | ||
"_media-type": "application\/vnd.ibexa.api.ViewResult+json", | ||
"count": 1, | ||
"CartList": { | ||
"_media-type": "application\/vnd.ibexa.api.CartList+json", | ||
"Cart": [ | ||
{ | ||
"_media-type": "application\/vnd.ibexa.api.Cart+json", | ||
"id": 1, | ||
"identifier": "e79b5dba-c701-4c64-8032-73719a513e50", | ||
"name": "Default", | ||
"createdAt": "2024-09-26T09:16:56+00:00", | ||
"updatedAt": "2024-09-26T09:16:56+00:00", | ||
"owner": { | ||
"_media-type": "application\/vnd.ibexa.api.User+json", | ||
"_href": "\/api\/ibexa\/v2\/user\/users\/10" | ||
}, | ||
"Currency": { | ||
"_media-type": "application\/vnd.ibexa.api.Currency+json", | ||
"id": 2, | ||
"code": "EUR", | ||
"subunits": 2, | ||
"enabled": true | ||
}, | ||
"entries": [], | ||
"context": { | ||
"foo": "bar" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CartView media-type="application/vnd.ibexa.api.CartView+xml"> | ||
<identifier>loadUserCarts</identifier> | ||
<Result media-type="application/vnd.ibexa.api.ViewResult+xml"> | ||
<count>1</count> | ||
<CartList media-type="application/vnd.ibexa.api.CartList+xml"> | ||
<Cart media-type="application/vnd.ibexa.api.Cart+xml"> | ||
<id>1</id> | ||
<identifier>e67d8f4c-95b5-423f-89d8-b2b81c37609b</identifier> | ||
<name>Default</name> | ||
<createdAt>2024-09-26T09:16:56+00:00</createdAt> | ||
<updatedAt>2024-09-26T09:16:56+00:00</updatedAt> | ||
<owner media-type="application/vnd.ibexa.api.User+xml" href="/api/ibexa/v2/user/users/10"/> | ||
<Currency media-type="application/vnd.ibexa.api.Currency+xml"> | ||
<id>2</id> | ||
<code>EUR</code> | ||
<subunits>2</subunits> | ||
<enabled>1</enabled> | ||
</Currency> | ||
</Cart> | ||
</CartList> | ||
</Result> | ||
</CartView> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"CartQuery": { | ||
"offset": 0, | ||
"limit": 10, | ||
"ownerId": 123 | ||
"ownerId": 10 | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<CartViewInput> | ||
<identifier>loadUserCarts</identifier> | ||
<CartQuery> | ||
<offset>0</offset> | ||
<limit>10</limit> | ||
<ownerId>10</ownerId> | ||
</CartQuery> | ||
</CartViewInput> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3593,7 +3593,7 @@ CartListViewResult: | |
type: object | ||
properties: | ||
count: integer | ||
Result: CartList | ||
CartList: CartList | ||
|
||
CartList: | ||
description: 'This class represents a cart list.' | ||
|
@@ -3614,6 +3614,34 @@ CartMetadataUpdate: | |
names: Value[] | ||
descriptions: Value[] | ||
|
||
CartConstraintViolationListWrapper: | ||
description: 'JSON object with only a CartConstraintViolationList property.' | ||
type: object | ||
properties: | ||
CartConstraintViolationList: CartConstraintViolationList | ||
|
||
CartConstraintViolationList: | ||
description: 'This class represents a list of cart constraint violations.' | ||
type: object | ||
properties: | ||
violations: | ||
type: array | ||
items: CartConstraintViolation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
CartConstraintViolation: | ||
description: 'This class represents a cart constraint violation.' | ||
type: object | ||
properties: | ||
code: string | ||
propertyPath: string | ||
message: string | ||
|
||
Token: | ||
description: 'This class represents a CSRF token' | ||
type: object | ||
properties: | ||
value: string | ||
|
||
CatalogWrapper: | ||
description: 'JSON object with only a Catalog property.' | ||
type: object | ||
|
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.
Question: should the slashes be escaped?
I see we sometimes do it and sometimes don't, does it matter?
Examples:
https://github.com/ibexa/documentation-developer/blob/master/docs/api/rest_api/rest_api_reference/input/examples/shipping/methods/identifier/GET/ShippingMethod.json.example#L3
https://github.com/ibexa/documentation-developer/blob/master/docs/api/rest_api/rest_api_reference/input/examples/content/locations/path/GET/Location.json.example#L3
Or maybe it doesn't matter?
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.
@mnocon
I checked on https://www.json.org/json-en.html and further on https://ecma-international.org/publications-and-standards/standards/ecma-404/. The standard's PDF states:
So escaping the slash (a.k.a solidus) is optional; it doesn't matter.
jq
understands it but considers it's not worth keeping it.We could status for consistency and open a new PR about this. I would vote for removing them all.