Class PromotionUtils
java.lang.Object
com.skava.promotion.orchestration.utils.PromotionUtils
The Class PromotionUtils
This class defines the promotion related methods.- Author:
- Infosys Equinox
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
calculatePriceFacets
(Map<String, Object> priceFacets, Map<String, Object> priceFacet, String key, Map.Entry<String, Object> value) This method is used to calculate PriceFacets.static void
constructInvalidPromoCode
(List<PromotionCode> promoCodes, String locale) This method is used to construct invalid promo code.createPromotionAccount
(org.apache.camel.Exchange exchange) This process method is used to create the promotion request for account.createPromotionCoupon
(SFCart cart) This method is used to create promotion discount coupon information for the promotion request from the orchestration cart response.createPromotionUser
(org.apache.camel.Exchange exchange) This process method is used to create the promotion request for account.static double
getDiscount
(PromotionOffer offer) This method is used to get discount from the promotion offer.static List<PromotionGiftResponse>
getGiftPromotion
(PromotionOfferResponse promotionOffer) This method is used to get promotion mapping with sku details from the promotion offer response.This method is used to get PriceFacetsDiscount from the promotion offer.static Map<String,
PromotionSku> getPromotion
(PromotionOfferResponse promotionOffer, String type) This method is used to get promotion mapping with sku details from the promotion offer response.static PromotionCode
getPromotionCodesFromCoupons
(PromotionCoupon promoCoupon, PromotionDetails promoDetails, PromotionDetails itemPromoDetails, String locale) This method is used to get promo codes from the given coupons.static void
getUserProperties
(Users usersResponse, Map<String, String> properties) This process method is used to get and set the userResponse properties.static boolean
isEmpty
(Collection<?> collection) This method returns true if the collection is null or is empty.static boolean
isValidPromoCode
(String code) This method is used validate the promo code.static BigDecimal
setBundlePrice
(SpecialProdPromotionRequest catalogPromoRequest, List<SkuOrchestration> searchSkuResponse, String type) This method is used to calculate total item pricesetBundlePriceFacets
(SpecialProdPromotionRequest catalogPromoRequest, List<SkuOrchestration> searchSkuResponse, List<String> allowedPromotionPriceFacets) This method is used to calculate setBundlePriceFacetssetItemPriceFacets
(SFItem item) This method is used to calculate total item priceFacetssetItemProperties
(Map<String, String> properties, String productPropertiesForPromotion, SFItem item, Boolean isSubscriptionIncludedInPromotion, Map<String, String> productproperties) This process method is used to set the setItemProperties.static void
setLoyaltyDetails
(org.apache.camel.Exchange exchange, Map<String, String> properties) This process method is used to create the promotion request for account.static void
setPriceFacets
(Map<String, Object> priceFacets, BigDecimal quantity, List<String> allowedPromotionPriceFacets, Map<String, Object> priceFacet) This process method is used to check for skuID.static void
setProductProperties
(Map<String, String> properties, String productPropertiesForPromotion, Map<String, String> productProperties, SFItem item, Boolean isSubscriptionIncludedInPromotion, Map<String, String> productproperties) static void
setPromoCodesFromCoupons
(List<PromotionCoupon> promoCouponList, PromotionDetails promoDetails, PromotionDetails itemPromoDetails, String locale) This method is used to set promo codes from the given coupons.static void
setPromoCodeValue
(PromotionDetails promoDetails, PromotionCode promoCode) This method is used to set promo code value.static void
setSkuPriceFacets
(SkuOrchestration sku, String allowedPromotionPriceFacets, Map<String, Object> priceFacets) This method is used set SKU PriceFacets for promotion request.static double
setSpecialProductPrices
(SFProduct product, double bundlePrice, Map<String, Object> priceFacets, List<String> allowedPromotionPriceFacet, String type) This method is used to set fixedPriceBundlePrices.static void
setSubscriptionProperty
(SFItem item, Map<String, String> properties) This method is used to set the subscription property in promotion request properties.
-
Method Details
-
isEmpty
This method returns true if the collection is null or is empty.- Parameters:
collection
- Indicates theCollection
- Returns:
- true | false
-
setPromoCodesFromCoupons
public static void setPromoCodesFromCoupons(List<PromotionCoupon> promoCouponList, PromotionDetails promoDetails, PromotionDetails itemPromoDetails, String locale) This method is used to set promo codes from the given coupons.- Parameters:
promoCouponList
- Indicates the list of (@link PromotionCoupon} object which contains the list of the promotion coupons details.promoDetails
- Indicates the list ofPromotionDetails
which contains the list of promotion details.itemPromoDetails
- IndicatesPromotionDetails
object which contains the promotion details.locale
- Indicates the locale which holds string value.
-
isValidPromoCode
This method is used validate the promo code.- Parameters:
code
- Indicates the promo code which holds string value.- Returns:
- Returns boolean value whether the promo code is valid or not.
-
getPromotionCodesFromCoupons
public static PromotionCode getPromotionCodesFromCoupons(PromotionCoupon promoCoupon, PromotionDetails promoDetails, PromotionDetails itemPromoDetails, String locale) This method is used to get promo codes from the given coupons.- Parameters:
promoCoupon
- Indicates (@link PromotionCoupon} object which contains the promotion coupons details.promoDetails
- IndicatesPromotionDetails
which contains the promotion details.itemPromoDetails
- IndicatesPromotionDetails
object which contains the item promotion details.locale
- Indicates the locale which holds string value.- Returns:
- Returns the
PromotionCode
, contains all promotion details of the promotion codes.
-
constructInvalidPromoCode
This method is used to construct invalid promo code.- Parameters:
promoCodes
- Indicates the list ofPromotionCode
which contains all promotion details of the promotion codes.locale
- Indicates the locale which holds string value.
-
setPromoCodeValue
This method is used to set promo code value.- Parameters:
promoDetails
- IndicatesPromotionDetails
which contains all promotion details of the item or the cart.promoCode
- IndicatesPromotionCode
which contains all promotion details of the promotion codes.
-
createPromotionCoupon
This method is used to create promotion discount coupon information for the promotion request from the orchestration cart response. -
createPromotionUser
This process method is used to create the promotion request for account.- Parameters:
exchange
- Indicates aExchange
instance, which holds the information during the entire routing of a Message received by a Consumer.- Returns:
- usersList.
-
createPromotionAccount
This process method is used to create the promotion request for account.- Parameters:
exchange
- Indicates aExchange
instance, which holds the information during the entire routing of a Message received by a Consumer.- Returns:
- accountsList.
-
getGiftPromotion
This method is used to get promotion mapping with sku details from the promotion offer response.- Parameters:
promotionOffer
- Indicates aPromotionOfferResponse
, contains the offers for the items that matches the specified criteria, response is rendered with the same data as in the request.- Returns:
- Returns the
List
, mapping where promotion sku contains the sku information.
-
getPromotion
public static Map<String,PromotionSku> getPromotion(PromotionOfferResponse promotionOffer, String type) This method is used to get promotion mapping with sku details from the promotion offer response.- Parameters:
promotionOffer
- Indicates aPromotionOfferResponse
, contains the offers for the items that matches the specified criteria, response is rendered with the same data as in the request.type
- is String.- Returns:
- Returns the
Map
, mapping where promotion sku contains the sku information.
-
getPriceFacetsDiscount
This method is used to get PriceFacetsDiscount from the promotion offer.- Parameters:
offer
- Indicates aPromotionOffer
, contains attributes to hold the promotion quantity based discount information.- Returns:
- Returns the priceFacetsDiscount.
-
getDiscount
This method is used to get discount from the promotion offer.- Parameters:
offer
- Indicates aPromotionOffer
, contains attributes to hold the promotion quantity based discount information.- Returns:
- Returns the discount amount.
-
calculatePriceFacets
public static void calculatePriceFacets(Map<String, Object> priceFacets, Map<String, Object> priceFacet, String key, Map.Entry<String, Object> value) This method is used to calculate PriceFacets. -
setItemPriceFacets
This method is used to calculate total item priceFacets- Parameters:
item
- Indicates aSFItem
, contains the item- Returns:
- priceFacets.
-
setSpecialProductPrices
public static double setSpecialProductPrices(SFProduct product, double bundlePrice, Map<String, Object> priceFacets, List<String> allowedPromotionPriceFacet, String type) This method is used to set fixedPriceBundlePrices. -
setBundlePrice
public static BigDecimal setBundlePrice(SpecialProdPromotionRequest catalogPromoRequest, List<SkuOrchestration> searchSkuResponse, String type) This method is used to calculate total item price- Parameters:
catalogPromoRequest
- Indicates aSpecialProdPromotionRequest
.searchSkuResponse
- Indicates aList
.type
- Indicates a string value for type- Returns:
- bundlePrice.
-
setBundlePriceFacets
public static Map<String,Object> setBundlePriceFacets(SpecialProdPromotionRequest catalogPromoRequest, List<SkuOrchestration> searchSkuResponse, List<String> allowedPromotionPriceFacets) This method is used to calculate setBundlePriceFacets- Parameters:
catalogPromoRequest
- Indicates aSpecialProdPromotionRequest
.searchSkuResponse
- Indicates aList
.allowedPromotionPriceFacets
- Indicates aList
.- Returns:
- priceFacets.
-
setPriceFacets
public static void setPriceFacets(Map<String, Object> priceFacets, BigDecimal quantity, List<String> allowedPromotionPriceFacets, Map<String, Object> priceFacet) This process method is used to check for skuID.- Parameters:
priceFacets
- indicates aMap
.quantity
- indicates aBigDecimal
.allowedPromotionPriceFacets
- indicates aList
.priceFacet
- indicates aMap
-
setLoyaltyDetails
public static void setLoyaltyDetails(org.apache.camel.Exchange exchange, Map<String, String> properties) This process method is used to create the promotion request for account.- Parameters:
exchange
- Indicates aExchange
instance, which holds the information during the entire routing of a Message received by a Consumer.properties
- Contains loyalty properties
-
getUserProperties
This process method is used to get and set the userResponse properties.- Parameters:
usersResponse
- contains userDetails.properties
- Contains user properties
-
setItemProperties
public static Map<String,String> setItemProperties(Map<String, String> properties, String productPropertiesForPromotion, SFItem item, Boolean isSubscriptionIncludedInPromotion, Map<String, String> productproperties) This process method is used to set the setItemProperties.- Parameters:
properties
- Contains the item/product/sku Properties.productPropertiesForPromotion
- Indicates a string value for productPropertiesForPromotionitem
- Indicates a cart item data.isSubscriptionIncludedInPromotion
- holds Boolean value isSubscriptionIncludedInPromotion- Returns:
- the corresponding map
-
setProductProperties
-
setSkuPriceFacets
public static void setSkuPriceFacets(SkuOrchestration sku, String allowedPromotionPriceFacets, Map<String, Object> priceFacets) This method is used set SKU PriceFacets for promotion request.- Parameters:
sku
-SkuOrchestration
, which contains information about an SKU response.allowedPromotionPriceFacets
- Indicates a string value for allowedPromotionPriceFacetspriceFacets
- Indicates the map of price facet details
-
setSubscriptionProperty
This method is used to set the subscription property in promotion request properties.- Parameters:
item
-SFItem
indicates the item in the cart.properties
- contains the promotion request properties.
-