Skip to content

Conversation

bc-anshumishra
Copy link

@bc-anshumishra bc-anshumishra commented Sep 25, 2025

PROMO-1256
PROMO-1257
PROMO-1296

What changed?

  • Added prefix, suffix, delimiter, exclude_characters and code_length fields for bulk coupon api /v3/promotions/{promotion id}/codegen

Testing

SCR-20251010-llfm SCR-20251010-lkve SCR-20251010-lljf SCR-20251010-llxz

Release notes draft

We're happy to announce new enhanced controls for bulk coupon code generation! This feature helps you organize and track your promotions better by giving you precise control over the final structure of every code you create.
You can now generate clean, structured codes that are easy for both you and your customers to read:

  • Prefix & Suffix: Define static text to appear at the beginning (prefix) and end (suffix) of every code (e.g., SUMMER-SALE-VIP). These can be up to 20 characters long and allow capital letters, numbers, hyphens, and underscores.
  • Delimiter: Add a structured separator by choosing either a hyphen (-) or an underscore (_). This character is automatically inserted between the prefix, the random code, and the suffix to improve readability (e.g., PRE-P6NBGW-POST).
  • Exclude Characters: Prevent specific characters (like confusing ones such as 'O', 'I', '0', '1') from appearing in the random part of your codes. You can exclude up to 26 characters (characters can be capital letters and numbers only).
  • Code Length: You control the length of the random section of the code, which must be between 6 and 16 characters.

The maximum total length of any generated coupon code is 50 characters, calculated by summing the lengths of the prefix, code, suffix, and any delimiters.

Anything else?

We will merge it after turning on experiment PROJECT-5165.bulk_coupon_codegen_api_enhancements

ping @bc-anshumishra

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds new bulk coupon code generation fields to the promotions API specification, providing enhanced control over generated coupon codes through customizable prefixes, suffixes, and code length parameters.

Key Changes

  • Added three new optional fields to the bulk coupon generation API: prefix, suffix, and code_length
  • Established validation patterns and constraints for consistent code formatting
  • Enhanced API flexibility for organized coupon code management

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 324 to 330
pattern: '[A-Z0-9_-]'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]'
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The regex pattern '[A-Z0-9_-]' only matches a single character, but the field descriptions indicate these are for text/strings that can contain multiple characters. The pattern should be '[A-Z0-9_-]*' or '[A-Z0-9_-]+' to match zero or more, or one or more characters respectively.

Suggested change
pattern: '[A-Z0-9_-]'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]'
pattern: '[A-Z0-9_-]*'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]*'

Copilot uses AI. Check for mistakes.

Comment on lines 324 to 330
pattern: '[A-Z0-9_-]'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]'
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The regex pattern '[A-Z0-9_-]' only matches a single character, but the field descriptions indicate these are for text/strings that can contain multiple characters. The pattern should be '[A-Z0-9_-]*' or '[A-Z0-9_-]+' to match zero or more, or one or more characters respectively.

Suggested change
pattern: '[A-Z0-9_-]'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]'
pattern: '[A-Z0-9_-]*'
type: string
description: 'The fixed text or characters that will appear at the beginning of every generated coupon code. Only capital letters, numbers, underscores and hyphens are allowed.'
example: PRE-
maxLength: 20
suffix:
pattern: '[A-Z0-9_-]*'

Copilot uses AI. Check for mistakes.

@donald-nguyen-bc donald-nguyen-bc requested a review from a team September 25, 2025 06:54
@bc-anshumishra bc-anshumishra marked this pull request as draft September 25, 2025 06:59
@donald-nguyen-bc donald-nguyen-bc added do not merge Don't merge this work. wip Work is currently in progress. labels Sep 25, 2025
maxLength: 20
code_length:
type: integer
description: 'The length of the random string to be generated for each coupon code. The value must be between 6 and 16. The total length of each generated coupon code is calculated as: `code_length` + length of `prefix` + length of `suffix`. The maximum total length of a coupon code is 50.'
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to indicate the default values for prefix, suffix and code_length if they are not set in the request?

Copy link
Author

Choose a reason for hiding this comment

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

There is no default value for prefix and suffix.
The default value for code_length is 16. I have added it in description.

example: _
maxLength: 1
exclude_characters:
pattern: '[A-Z0-9]'
Copy link
Contributor

Choose a reason for hiding this comment

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

should this pattern belong to the "items", not directly in exclude_characters ?

minimum: 0
maximum: 100000
prefix:
pattern: '[A-Z0-9_-]'
Copy link
Contributor

Choose a reason for hiding this comment

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

probably we don't need to wrap text inside those single quotes ?

Suggested change
pattern: '[A-Z0-9_-]'
pattern: [A-Z0-9_-]

Copy link
Contributor

Choose a reason for hiding this comment

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

also applied to other lines in PR as well

@donald-nguyen-bc
Copy link
Contributor

may you pls add test proof that those fields rendered correctly in https://editor.swagger.io/

@bc-anshumishra
Copy link
Author

may you pls add test proof that those fields rendered correctly in https://editor.swagger.io/

Done.

…clude_characters and code_length fields for bulk coupon api /v3/promotions/{promotion id}/codegen
@bc-anshumishra bc-anshumishra changed the title PROMO-1256: Added prefix, suffix and code_length fields for bulk coup… PROMO-1256 PROMO-1257 PROMO-1296: Added prefix, suffix, delimiter, exclude_characters and code_length fields for bulk coupon api /v3/promotions/{promotion id}/codegen Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Don't merge this work. wip Work is currently in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants