Class ExternalOfferProvider

    • Constructor Summary

      Constructors 
      Constructor Description
      ExternalOfferProvider​(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalOfferProperties properties, UserTargetGenerationService userTargetGenerationService)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> buildOrderDto​(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)  
      protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext createCustomerContext()
      Create a CustomerContext and add customer and customer segments.
      protected Object getProductType​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)  
      protected ExternalOfferProperties getProperties()  
      protected Optional<javax.money.MonetaryAmount> getStandardPrice​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)  
      protected UserTargetGenerationService getUserTargetGenerationService()  
      protected void handleWebClientResponseException​(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult result, org.springframework.web.reactive.function.client.WebClientResponseException exception)
      Logs and set the OfferAndOfferCodeUsageValidationResult.getValidationFailureMessages() for all the voucher offers.
      protected boolean hasSalePrice​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)  
      protected boolean hasStandardPrice​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)  
      protected com.broadleafcommerce.promotion.offer.client.web.context.Codes populateCodes​(com.broadleafcommerce.order.client.domain.Order order)  
      protected void populateDependentLineItemDto​(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems, com.broadleafcommerce.order.client.domain.OrderItem orderItem)  
      protected com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto populateLineItemDto​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)
      Returns a populated OrderLineItemDto from given OrderItem.
      protected List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> populateLineItems​(com.broadleafcommerce.order.client.domain.Order order)  
      protected com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher populateVoucherDto​(com.broadleafcommerce.order.common.domain.Voucher voucher)
      Returns a populated Voucher from given Voucher.
      protected List<com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher> populateVouchers​(com.broadleafcommerce.order.client.domain.Order order)  
      com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult validateVoucherOfferUsages​(com.broadleafcommerce.order.client.domain.Order order, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Validates existing vouchers stored in Order.getVouchers() to ensure that they are still valid and applicable to the given Order.
    • Constructor Detail

      • ExternalOfferProvider

        public ExternalOfferProvider​(org.springframework.web.reactive.function.client.WebClient webClient,
                                     com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                                     com.broadleafcommerce.common.extension.TypeFactory typeFactory,
                                     ExternalOfferProperties properties,
                                     UserTargetGenerationService userTargetGenerationService)
    • Method Detail

      • validateVoucherOfferUsages

        public com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult validateVoucherOfferUsages​(com.broadleafcommerce.order.client.domain.Order order,
                                                                                                                                          @Nullable
                                                                                                                                          com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: OfferProvider
        Validates existing vouchers stored in Order.getVouchers() to ensure that they are still valid and applicable to the given Order.
        Specified by:
        validateVoucherOfferUsages in interface OfferProvider
        Parameters:
        order - the Order containing the Vouchers to validate against
        contextInfo - context information surrounding sandboxing and multitenant state
        Returns:
        an OfferAndOfferCodeUsageValidationResult containing details about any invalid Offers and failure messages
      • handleWebClientResponseException

        protected void handleWebClientResponseException​(com.broadleafcommerce.order.client.domain.Order order,
                                                        com.broadleafcommerce.promotion.offer.client.web.context.OfferAndOfferCodeUsageValidationResult result,
                                                        org.springframework.web.reactive.function.client.WebClientResponseException exception)
        Logs and set the OfferAndOfferCodeUsageValidationResult.getValidationFailureMessages() for all the voucher offers.
        Parameters:
        order - the Order containing all the voucher offers
        result - the OfferAndOfferCodeUsageValidationResult
        exception - the WebClientResponseException to log
      • createCustomerContext

        protected com.broadleafcommerce.promotion.offer.client.web.context.CustomerContext createCustomerContext()
        Create a CustomerContext and add customer and customer segments. Uses the current authentication token to determine principal and details.
        Returns:
        The created CustomerContext
      • buildOrderDto

        protected com.broadleafcommerce.promotion.offer.client.web.context.OrderDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentGroupDto<com.broadleafcommerce.promotion.offer.client.web.context.FulfillmentLineItemDto>> buildOrderDto​(com.broadleafcommerce.order.client.domain.Order order,
                                                                                                                                                                                                                                                                 @Nullable
                                                                                                                                                                                                                                                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      • populateVouchers

        protected List<com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher> populateVouchers​(com.broadleafcommerce.order.client.domain.Order order)
      • populateLineItems

        protected List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> populateLineItems​(com.broadleafcommerce.order.client.domain.Order order)
      • populateCodes

        protected com.broadleafcommerce.promotion.offer.client.web.context.Codes populateCodes​(com.broadleafcommerce.order.client.domain.Order order)
      • getProductType

        @Nullable
        protected Object getProductType​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)
      • populateDependentLineItemDto

        protected void populateDependentLineItemDto​(List<com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto> lineItems,
                                                    com.broadleafcommerce.order.client.domain.OrderItem orderItem)
      • populateVoucherDto

        protected com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher populateVoucherDto​(com.broadleafcommerce.order.common.domain.Voucher voucher)
        Returns a populated Voucher from given Voucher.
        Parameters:
        voucher - the Voucher to populate an Voucher from
        Returns:
        populated Voucher from given Voucher
      • populateLineItemDto

        protected com.broadleafcommerce.promotion.offer.client.web.context.OrderLineItemDto populateLineItemDto​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)
        Returns a populated OrderLineItemDto from given OrderItem.
        Parameters:
        orderItem - the OrderItem to populate an OrderLineItemDto from
        Returns:
        populated OrderLineItemDto from given OrderItem
      • hasStandardPrice

        protected boolean hasStandardPrice​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)
      • hasSalePrice

        protected boolean hasSalePrice​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)
      • getStandardPrice

        protected Optional<javax.money.MonetaryAmount> getStandardPrice​(com.broadleafcommerce.order.client.domain.OrderItem orderItem)