Class PromotionUtils

java.lang.Object
com.skava.promotion.orchestration.utils.PromotionUtils

public final class PromotionUtils extends Object

The Class PromotionUtils

This class defines the promotion related methods.
Author:
Infosys Equinox
  • Method Details

    • isEmpty

      public static boolean isEmpty(Collection<?> collection)
      This method returns true if the collection is null or is empty.
      Parameters:
      collection - Indicates the Collection
      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 of PromotionDetails which contains the list of promotion details.
      itemPromoDetails - Indicates PromotionDetails object which contains the promotion details.
      locale - Indicates the locale which holds string value.
    • isValidPromoCode

      public static boolean isValidPromoCode(String code)
      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 - Indicates PromotionDetails which contains the promotion details.
      itemPromoDetails - Indicates PromotionDetails 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

      public static void constructInvalidPromoCode(List<PromotionCode> promoCodes, String locale)
      This method is used to construct invalid promo code.
      Parameters:
      promoCodes - Indicates the list of PromotionCode which contains all promotion details of the promotion codes.
      locale - Indicates the locale which holds string value.
    • setPromoCodeValue

      public static void setPromoCodeValue(PromotionDetails promoDetails, PromotionCode promoCode)
      This method is used to set promo code value.
      Parameters:
      promoDetails - Indicates PromotionDetails which contains all promotion details of the item or the cart.
      promoCode - Indicates PromotionCode which contains all promotion details of the promotion codes.
    • createPromotionCoupon

      public static List<Map<String,Object>> createPromotionCoupon(SFCart cart)
      This method is used to create promotion discount coupon information for the promotion request from the orchestration cart response.
      Parameters:
      cart - Indicates a SFCart, represents the entire cart of the customer.
      Returns:
      Returns the list of Map object which represents, discount coupon information.
    • createPromotionUser

      public static List<Map<String,Object>> createPromotionUser(org.apache.camel.Exchange exchange)
      This process method is used to create the promotion request for account.
      Parameters:
      exchange - Indicates a Exchange instance, which holds the information during the entire routing of a Message received by a Consumer.
      Returns:
      usersList.
    • createPromotionAccount

      public static List<Map<String,Object>> createPromotionAccount(org.apache.camel.Exchange exchange)
      This process method is used to create the promotion request for account.
      Parameters:
      exchange - Indicates a Exchange instance, which holds the information during the entire routing of a Message received by a Consumer.
      Returns:
      accountsList.
    • getGiftPromotion

      public static List<PromotionGiftResponse> getGiftPromotion(PromotionOfferResponse promotionOffer)
      This method is used to get promotion mapping with sku details from the promotion offer response.
      Parameters:
      promotionOffer - Indicates a PromotionOfferResponse, 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 a PromotionOfferResponse, 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

      public static Map<String,Object> getPriceFacetsDiscount(PromotionOffer offer)
      This method is used to get PriceFacetsDiscount from the promotion offer.
      Parameters:
      offer - Indicates a PromotionOffer, contains attributes to hold the promotion quantity based discount information.
      Returns:
      Returns the priceFacetsDiscount.
    • getDiscount

      public static double getDiscount(PromotionOffer offer)
      This method is used to get discount from the promotion offer.
      Parameters:
      offer - Indicates a PromotionOffer, 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.
      Parameters:
      priceFacet - Indicates a Map
      priceFacets - Indicates a Map
      key - .
      value - .
    • setItemPriceFacets

      public static Map<String,Object> setItemPriceFacets(SFItem item)
      This method is used to calculate total item priceFacets
      Parameters:
      item - Indicates a SFItem, 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.
      Parameters:
      product - Indicates a Map.
      bundlePrice - Indicates a double.
      priceFacets - Indicates a Map.
      allowedPromotionPriceFacet - .
      type - Indicates a string value for type
      Returns:
      Returns the facetValue of double.
    • setBundlePrice

      public static BigDecimal setBundlePrice(SpecialProdPromotionRequest catalogPromoRequest, List<SkuOrchestration> searchSkuResponse, String type)
      This method is used to calculate total item price
      Parameters:
      catalogPromoRequest - Indicates a SpecialProdPromotionRequest.
      searchSkuResponse - Indicates a List.
      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 a SpecialProdPromotionRequest.
      searchSkuResponse - Indicates a List.
      allowedPromotionPriceFacets - Indicates a List.
      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 a Map.
      quantity - indicates a BigDecimal.
      allowedPromotionPriceFacets - indicates a List.
      priceFacet - indicates a Map
    • 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 a Exchange instance, which holds the information during the entire routing of a Message received by a Consumer.
      properties - Contains loyalty properties
    • getUserProperties

      public static void getUserProperties(Users usersResponse, Map<String,String> properties)
      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 productPropertiesForPromotion
      item - Indicates a cart item data.
      isSubscriptionIncludedInPromotion - holds Boolean value isSubscriptionIncludedInPromotion
      Returns:
      the corresponding map
    • setProductProperties

      public static void setProductProperties(Map<String,String> properties, String productPropertiesForPromotion, Map<String,String> productProperties, SFItem item, Boolean isSubscriptionIncludedInPromotion, Map<String,String> productproperties)
    • 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 allowedPromotionPriceFacets
      priceFacets - Indicates the map of price facet details
    • setSubscriptionProperty

      public static void setSubscriptionProperty(SFItem item, Map<String,String> properties)
      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.