Interface CouponCodeGenerationService
- All Known Implementing Classes:
DefaultCouponCodeGenerationService
public interface CouponCodeGenerationService
The CouponCodeGenerationService provides methods to configure coupon code generation and create coupon codes. Each
coupon code has a clear-text part and a cipher-text part. The cipher-text part is calculated by encrypting the
clear-text part.
-
Method Summary
Modifier and TypeMethodDescriptionextractCouponPrefix(String couponCode) tries to find the prefix substring of the given coupon code.generates the alphabet used for a coupon.Generates a code for the given multi code coupon.generateCouponCodes(MultiCodeCouponModel multiCodeCoupon, int quantity) Generates codes for the given multi-code coupon.generates a base64 encoded String representing the signature of the multi code coupon.booleanisValidCodeSeparator(String codeSeparator) verifies if the given string is a valid code separatorbooleanverifyCouponCode(MultiCodeCouponModel coupon, String couponCode) verifies if the givencouponCodeis valid for the givencoupon.
-
Method Details
-
generateCouponSignature
String generateCouponSignature()generates a base64 encoded String representing the signature of the multi code coupon. The signature is used to generate the cipher-text part of the coupon code which incorporates the signed first half of the coupon code.- Returns:
- base64 encoded String representing the signature of the multi code coupon
-
generateCouponAlphabet
String generateCouponAlphabet()generates the alphabet used for a coupon.- Returns:
- alphabet string used for a coupon
-
generateCouponCode
Generates a code for the given multi code coupon. Note: This method doesn't save the given coupon, but modifies it (by incrementing thecouponCodeNumberattribute)- Parameters:
coupon- multi code coupon- Returns:
- code for the given multi code coupon
- Throws:
CouponCodeGenerationException- if the code cannot be generated (e.g. if the maximum number of coupon codes has been exceeded)
-
extractCouponPrefix
tries to find the prefix substring of the given coupon code.- Parameters:
couponCode- coupon code to extract prefix substring- Returns:
- the (assumed) prefix of the given coupon code or null if none could be determined
-
verifyCouponCode
verifies if the givencouponCodeis valid for the givencoupon.- Parameters:
coupon- Coupon against which check will be firedcouponCode- Coupon code to verify- Returns:
- true if the couponCode is valid, otherwise false
-
isValidCodeSeparator
verifies if the given string is a valid code separator- Parameters:
codeSeparator- Code separator- Returns:
- true if the codeSeperator is valid, otherwise false
-
generateCouponCodes
Generates codes for the given multi-code coupon. Returns a MediaModel containing a csv file with the generated codes. Note that the returned file containsquantitycoupon codes or less. It contains less codes if the requested quantity cannot be generated (e.g. if the limit of codes has been reached). If no coupon codes could be generated anOptional.empty()is returned.- Parameters:
multiCodeCoupon- Multi code coupon instancequantity- number of coupon codes to be generated- Returns:
- MediaModel containing a csv file with the generated codes. If no coupon codes could be generated an
Optional.empty()is returned.
-