Class ShippingFeePromotionService
java.lang.Object
org.bhn.promotion.voucherify.service.ShippingFeePromotionService
Service class handles the logic for applying, updating, and managing shipping fee-related
promotions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisValidShippingFee(PromotionQuoteRequest promotionQuoteRequest) Validates whether the first shipping fee in the provided PromotionQuoteRequest is greater than zero.booleanisValidShippingMetaData(Map<String, Object> metaData) Validates the shipping metadata present in the provided metaData map.voidsetDefaultShippingFeePromoSummaryIfNotExist(PromoSummary promoSummary) Sets a default shipping fee promotion summary to the provided promoSummary object only if the shippingFeePromoSummary does not already exist.setShippingFeeMetaData(PromotionQuoteRequest promotionQuoteRequest, EvaluationRequest evaluationRequest) Sets the shipping fee metadata for the validation request.setShippingFeeMetaDataForRedemption(PromotionQuoteRequest promotionQuoteRequest, RedemptionRequestDto redemptionRequest) Sets the shipping fee metadata for the redemption request.updatePromoSummary(PromoSummary promoSummary, PromoSummary shippingFeePromoSummary) Updates the existing promo summary with details from the shipping fee promo summary.
-
Constructor Details
-
ShippingFeePromotionService
public ShippingFeePromotionService()
-
-
Method Details
-
setShippingFeeMetaData
public ValidationRequestDto setShippingFeeMetaData(PromotionQuoteRequest promotionQuoteRequest, EvaluationRequest evaluationRequest) throws com.fasterxml.jackson.core.JsonProcessingException Sets the shipping fee metadata for the validation request.- Parameters:
promotionQuoteRequest- The PromotionQuoteRequest containing metadata related to the quote.evaluationRequest- The EvaluationRequest containing the original request body for validation.- Returns:
- A ValidationsValidateRequestBody containing the updated shipping metadata and other necessary details for validation.
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- If there is an error processing the JSON metadata.
-
setShippingFeeMetaDataForRedemption
public RedeemPromotionRequestDto setShippingFeeMetaDataForRedemption(PromotionQuoteRequest promotionQuoteRequest, RedemptionRequestDto redemptionRequest) throws com.fasterxml.jackson.core.JsonProcessingException Sets the shipping fee metadata for the redemption request.- Parameters:
promotionQuoteRequest- The PromotionQuoteRequest containing metadata related to the quote.redemptionRequest- The RedemptionRequest containing the original request body for the redemption.- Returns:
- A RedemptionsRedeemRequestBody containing the updated shipping metadata and other necessary details for redemption.
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- If there is an error processing the JSON metadata.
-
updatePromoSummary
public PromoSummary updatePromoSummary(PromoSummary promoSummary, PromoSummary shippingFeePromoSummary) Updates the existing promo summary with details from the shipping fee promo summary.- Parameters:
promoSummary- The main PromoSummary object that needs to be updated.shippingFeePromoSummary- The PromoSummary object containing the shipping fee promo details to be added to the main promo summary.
-
isValidShippingMetaData
Validates the shipping metadata present in the provided metaData map.- Parameters:
metaData- The map containing metadata information, including the shipping details.- Returns:
- true if the shipping metadata is valid (contains the "METHOD_CODE" key), false otherwise.
-
isValidShippingFee
Validates whether the first shipping fee in the provided PromotionQuoteRequest is greater than zero. This method checks if the list of shipping fees in the PromotionQuoteRequest is not empty, and if the first `ShippingFee`'s value is greater than zero. If the list is empty or the value is zero or negative, the method will return false.- Parameters:
promotionQuoteRequest- the PromotionQuoteRequest object containing a list of ShippingFees to be validated.- Returns:
- true if the first shipping fee is greater than zero, false otherwise.
-
setDefaultShippingFeePromoSummaryIfNotExist
Sets a default shipping fee promotion summary to the provided promoSummary object only if the shippingFeePromoSummary does not already exist. If the shippingFeePromoSummary is null, a new PromoSummary is created with a value of BigDecimal.ZERO, and the currency is copied from the provided promoSummary.- Parameters:
promoSummary- The PromoSummary object to which the default shipping fee promotion summary will be set, if it doesn't already have one.
-