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 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 the couponCodeNumber 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 given couponCode is valid for the given coupon.
        Parameters:
        coupon - Coupon against which check will be fired
        couponCode - 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 contains quantity 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 an Optional.empty() is returned.
        Parameters:
        multiCodeCoupon - Multi code coupon instance
        quantity - 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.