Skip to content

Commit

Permalink
IBX-8947: Add 2 cart REST routes; update Cart examples (#2501)
Browse files Browse the repository at this point in the history
/api/ibexa/v2/cart/{identifier}/validate
/api/ibexa/v2/cart/authorize

---------

Co-authored-by: Marek Nocoń <[email protected]>
  • Loading branch information
adriendupuis and mnocon authored Dec 3, 2024
1 parent c636be4 commit 50b28fb
Show file tree
Hide file tree
Showing 14 changed files with 1,751 additions and 259 deletions.
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": []
}
}
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
Expand Up @@ -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>
42 changes: 42 additions & 0 deletions docs/api/rest_api/rest_api_reference/input/ibexa-cart.raml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ post:
body:
application/vnd.ibexa.api.CartCreate+xml:
type: CartCreate
example: !include examples/cart/POST/CartCreate.xml.example
application/vnd.ibexa.api.CartCreate+json:
type: CartCreateWrapper
example: !include examples/cart/POST/CartCreate.json.example
Expand All @@ -24,6 +25,7 @@ post:
body:
application/vnd.ibexa.api.Cart+xml:
type: Cart
example: !include examples/cart/POST/Cart.xml.example
application/vnd.ibexa.api.Cart+json:
type: CartWrapper
example: !include examples/cart/POST/Cart.json.example
Expand All @@ -47,6 +49,7 @@ post:
body:
application/vnd.ibexa.api.CartViewInput+xml:
type: CartViewInput
example: !include examples/cart/view/CartViewInput.xml.example
application/vnd.ibexa.api.CartViewInput+json:
type: CartViewInputWrapper
example: !include examples/cart/view/CartViewInput.json.example
Expand All @@ -58,6 +61,7 @@ post:
type: CartView
application/vnd.ibexa.api.CartView+json:
type: CartViewWrapper
example: !include examples/cart/view/CartView.json.example
/{identifier}:
get:
displayName: Get Cart
Expand All @@ -74,6 +78,7 @@ post:
body:
application/vnd.ibexa.api.Cart+xml:
type: Cart
example: !include examples/cart/POST/Cart.xml.example
application/vnd.ibexa.api.Cart+json:
type: CartWrapper
example: !include examples/cart/POST/Cart.json.example
Expand Down Expand Up @@ -165,3 +170,40 @@ post:
description: Error - The user is not authorized to read this Cart.
404:
description: Error - Cart not found.
/validate:
post:
displayName: Cart Validation
description: Validates a Cart against constraints
headers:
Accept:
description: If set, the Cart Constraint Violations are returned in XML or JSON format.
example: |
application/vnd.ibexa.api.CartConstraintViolationList+xml
application/vnd.ibexa.api.CartConstraintViolationList+json
responses:
200:
body:
application/vnd.ibexa.api.CartConstraintViolationList+xml:
type: CartConstraintViolationList
example: !include examples/cart/identifier/validate/CartConstraintViolationList.xml.example
application/vnd.ibexa.api.CartConstraintViolationList+json:
type: CartConstraintViolationListWrapper
example: !include examples/cart/identifier/validate/CartConstraintViolationList.json.example
/authorize:
post:
displayName: Cart Authorization
description: Returns the CSRF token required by anonymous user to interact with their own cart.
headers:
Accept:
example: |
application/vnd.ibexa.api.Token+xml
application/vnd.ibexa.api.Token+json
responses:
200:
body:
application/vnd.ibexa.api.Token+xml:
type: Token
example: !include examples/cart/authorize/Token.xml.example
application/vnd.ibexa.api.CartConstraintViolationList+json:
type: Token
example: !include examples/cart/authorize/Token.json.example
30 changes: 29 additions & 1 deletion docs/api/rest_api/rest_api_reference/input/ibexa-types.raml
Original file line number Diff line number Diff line change
Expand Up @@ -3593,7 +3593,7 @@ CartListViewResult:
type: object
properties:
count: integer
Result: CartList
CartList: CartList

CartList:
description: 'This class represents a cart list.'
Expand All @@ -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

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
Expand Down
Loading

0 comments on commit 50b28fb

Please sign in to comment.