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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
extractCouponPrefix(java.lang.String couponCode)
tries to find the prefix substring of the given coupon code.java.lang.String
generateCouponAlphabet()
generates the alphabet used for a coupon.java.lang.String
generateCouponCode(MultiCodeCouponModel coupon)
Generates a code for the given multi code coupon.java.util.Optional<MediaModel>
generateCouponCodes(MultiCodeCouponModel multiCodeCoupon, int quantity)
Generates codes for the given multi-code coupon.java.lang.String
generateCouponSignature()
generates a base64 encoded String representing the signature of the multi code coupon.boolean
isValidCodeSeparator(java.lang.String codeSeparator)
verifies if the given string is a valid code separatorboolean
verifyCouponCode(MultiCodeCouponModel coupon, java.lang.String couponCode)
verifies if the givencouponCode
is valid for the givencoupon
.
-
-
-
Method Detail
-
generateCouponSignature
java.lang.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
java.lang.String generateCouponAlphabet()
generates the alphabet used for a coupon.- Returns:
- alphabet string used for a coupon
-
generateCouponCode
java.lang.String generateCouponCode(MultiCodeCouponModel coupon)
Generates a code for the given multi code coupon. Note: This method doesn't save the given coupon, but modifies it (by incrementing thecouponCodeNumber
attribute)- 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
java.lang.String extractCouponPrefix(java.lang.String couponCode)
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
boolean verifyCouponCode(MultiCodeCouponModel coupon, java.lang.String couponCode)
verifies if the givencouponCode
is 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
boolean isValidCodeSeparator(java.lang.String codeSeparator)
verifies if the given string is a valid code separator- Parameters:
codeSeparator
- Code separator- Returns:
- true if the codeSeperator is valid, otherwise false
-
generateCouponCodes
java.util.Optional<MediaModel> generateCouponCodes(MultiCodeCouponModel multiCodeCoupon, int quantity)
Generates codes for the given multi-code coupon. Returns a MediaModel containing a csv file with the generated codes. Note that the returned file containsquantity
coupon 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.
-
-