Skip to content

[Discounts] REST API #2780

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

Open
wants to merge 24 commits into
base: 4.6
Choose a base branch
from
Open

[Discounts] REST API #2780

wants to merge 24 commits into from

Conversation

mnocon
Copy link
Contributor

@mnocon mnocon commented Jun 10, 2025

Copy link

github-actions bot commented Jun 10, 2025

Preview of modified files: no change to preview.

@mnocon mnocon force-pushed the discounts-rest branch 2 times, most recently from 35978c8 to 636c53c Compare June 10, 2025 22:12
@mnocon mnocon marked this pull request as ready for review June 11, 2025 06:37
@mnocon mnocon requested a review from a team June 11, 2025 07:25
@ezrobot ezrobot requested review from adriendupuis, dabrt and julitafalcondusza and removed request for a team June 11, 2025 07:26
mnocon and others added 9 commits June 11, 2025 13:03
* [Discounts] Added migration doc

* Added files

* Update docs/content_management/data_migration/importing_data.md
Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
* [Discounts] Search overview

* Fixes before review

* Reworded Type sort clause

* Update docs/search/discounts_search_reference/discounts_sort_clauses.md

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
* [Discounts] Added event reference

* Fixed links

* Fixes before review

* Removed column
* Mentioned discounts in pricing and customer groups

* Before review fixes

* Added mention to the PIM guide
* Permissions

* Build fixes

* Fixed links

* Fixed last links

* Removed link

* Apply suggestions from code review

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>

---------

Co-authored-by: julitafalcondusza <117284672+julitafalcondusza@users.noreply.github.com>
* Added update instructions

* Fixed link
Base automatically changed from discounts to 4.6 June 11, 2025 13:51
Copy link
Contributor

@adriendupuis adriendupuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some error responses are missing but this isn't really important.

JSON object type description is incomplete as the wrapped XML part isn't accessible.

"DiscountCode": {
"_media-type": "application\/vnd.ibexa.api.DiscountCode+json",
"id": 1,
"code": "my_secret_code",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like the response to the payload example. Shouldn't it be summer10?

Suggested change
"code": "my_secret_code",
"code": "summer10",


/{id}:
get:
displayName: Get discount
Copy link
Contributor

@adriendupuis adriendupuis Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optionally this change, see next comment.

Suggested change
displayName: Get discount
displayName: Get discount by ID


/{identifier}:
get:
displayName: Get discount
Copy link
Contributor

@adriendupuis adriendupuis Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one can't be reach through the ToC as it has the same name (and therefore anchor) than the previous entry.

image

Suggested change
displayName: Get discount
displayName: Get discount by identifier

Comment on lines +36 to +41
responses:
200:
body:
application/vnd.ibexa.api.Discount+json:
type: DiscountWrapper
example: !include examples/discounts/POST/DiscountCreateResponse.json.example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is likely some error responses as well. Probably 403 if user haven't the rights to create a discount and 500 if the payload is malformed.
It might not worth spending too much time into completing this in 4.6 RAML. It will be more important in 5.0 OpenAPI.
Remember https://redocly.com/docs/cli/rules/oas/operation-4xx-response 😉

Comment on lines +6317 to +6385
DiscountListWrapper:
type: object
description: 'Wrapper object for DiscountList.'
properties:
DiscountList:
type: DiscountList
description: 'Object containing a list of discounts.'

DiscountList:
type: object
description: 'Object containing a list of discounts.'
properties:
Discount:
type: array
items:
type: object
properties:
identifier:
type: string
description: "Discount identifier."
type:
type: string
description: "Discount type: cart or catalog."
priority:
type: integer
description: "Discount priority."
isEnabled:
type: boolean
description: "Indicates whether the discount is enabled."
userId:
type: integer
description: "User ID of discount creator."
rule:
type: object
description: "Describes how the discount is calculated: percentage or fixed."
properties:
type:
type: string
description: "Discount type."
amount:
type: integer
description: "Discount amount."
startDate:
type: datetime
description: "Defines when the discount starts."
endDate:
type: datetime
description: "Defines when the discount starts."
translations:
type: array
description: "Translations of discount data."
items:
type: object
properties:
languageCode:
type: string
name:
type: string
description:
type: string
label:
type: string
labelDescription:
type: string
conditions:
type: array
description: "List of discount conditions."
items:
type: DiscountCondition
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As only JSON is used, DiscountList can't be displayed.

When there is both, this no big deal that the Wrapper description is short, just close the JSON Wrapper type description and open the XML type description.
image

But here, there is no such possibility.
image

I would move DiscountList under its wrapper.

Suggested change
DiscountListWrapper:
type: object
description: 'Wrapper object for DiscountList.'
properties:
DiscountList:
type: DiscountList
description: 'Object containing a list of discounts.'
DiscountList:
type: object
description: 'Object containing a list of discounts.'
properties:
Discount:
type: array
items:
type: object
properties:
identifier:
type: string
description: "Discount identifier."
type:
type: string
description: "Discount type: cart or catalog."
priority:
type: integer
description: "Discount priority."
isEnabled:
type: boolean
description: "Indicates whether the discount is enabled."
userId:
type: integer
description: "User ID of discount creator."
rule:
type: object
description: "Describes how the discount is calculated: percentage or fixed."
properties:
type:
type: string
description: "Discount type."
amount:
type: integer
description: "Discount amount."
startDate:
type: datetime
description: "Defines when the discount starts."
endDate:
type: datetime
description: "Defines when the discount starts."
translations:
type: array
description: "Translations of discount data."
items:
type: object
properties:
languageCode:
type: string
name:
type: string
description:
type: string
label:
type: string
labelDescription:
type: string
conditions:
type: array
description: "List of discount conditions."
items:
type: DiscountCondition
DiscountListWrapper:
type: object
description: 'Wrapper object for DiscountList.'
properties:
DiscountList:
type: object
description: 'Object containing a list of discounts.'
properties:
Discount:
type: array
items:
type: object
properties:
identifier:
type: string
description: "Discount identifier."
type:
type: string
description: "Discount type: cart or catalog."
priority:
type: integer
description: "Discount priority."
isEnabled:
type: boolean
description: "Indicates whether the discount is enabled."
userId:
type: integer
description: "User ID of discount creator."
rule:
type: object
description: "Describes how the discount is calculated: percentage or fixed."
properties:
type:
type: string
description: "Discount type."
amount:
type: integer
description: "Discount amount."
startDate:
type: datetime
description: "Defines when the discount starts."
endDate:
type: datetime
description: "Defines when the discount starts."
translations:
type: array
description: "Translations of discount data."
items:
type: object
properties:
languageCode:
type: string
name:
type: string
description:
type: string
label:
type: string
labelDescription:
type: string
conditions:
type: array
description: "List of discount conditions."
items:
type: DiscountCondition

Same for every JSON-only object types below…

Copy link
Contributor

@adriendupuis adriendupuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants