Interface PriceDraft

All Superinterfaces:
CustomizableDraft<PriceDraft>, Draft<PriceDraft>, WithKey

public interface PriceDraft extends CustomizableDraft<PriceDraft>, WithKey, Draft<PriceDraft>

The draft representation for prices to be embedded into ProductVariantDrafts when the ProductPriceMode is Embedded. For the Standalone ProductPriceMode use StandalonePriceDraft.


Example to create an instance using the builder pattern

     PriceDraft priceDraft = PriceDraft.builder()
             .value(valueBuilder -> valueBuilder)
             .build()
 
  • Method Details

    • getKey

      String getKey()

      User-defined identifier for the Price. It must be unique per ProductVariant.

      Specified by:
      getKey in interface WithKey
      Returns:
      key
    • getValue

      @NotNull @Valid @NotNull @Valid Money getValue()

      Money value of this Price.

      To set the money value in high precision, use HighPrecisionMoneyDraft.

      Returns:
      value
    • getCountry

      String getCountry()

      Set this field if this Price is only valid for the specified country.

      Returns:
      country
    • getCustomerGroup

      @Valid @Valid CustomerGroupResourceIdentifier getCustomerGroup()

      Set this field if this Price is only valid for the referenced CustomerGroup.

      Returns:
      customerGroup
    • getChannel

      @Valid @Valid ChannelResourceIdentifier getChannel()

      Set this field if this Price is only valid for the referenced ProductDistribution Channel.

      Returns:
      channel
    • getValidFrom

      ZonedDateTime getValidFrom()

      Set this field if this Price is only valid from the specified date and time. Must be at least 1 ms earlier than validUntil.

      Returns:
      validFrom
    • getValidUntil

      ZonedDateTime getValidUntil()

      Set this field if this Price is only valid until the specified date and time. Must be at least 1 ms later than validFrom. Prices that are no longer valid are not automatically removed, but they can be removed if necessary.

      Returns:
      validUntil
    • getDiscounted

      @Valid @Valid DiscountedPriceDraft getDiscounted()

      Set this field to add a DiscountedPrice from an external service.

      Otherwise, Composable Commerce sets this field automatically if at least one ProductDiscount applies. The DiscountedPrice must reference a ProductDiscount with:

      • The isActive flag set to true.
      • A ProductDiscountValue of type external.
      • A predicate that matches the ProductVariant the Price is referenced from.
      Returns:
      discounted
    • getTiers

      @Valid @Valid List<PriceTierDraft> getTiers()

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

      Returns:
      tiers
    • getCustom

      @Valid @Valid CustomFieldsDraft getCustom()

      Custom Fields for the Price.

      Specified by:
      getCustom in interface CustomizableDraft<PriceDraft>
      Returns:
      custom
    • setKey

      void setKey(String key)

      User-defined identifier for the Price. It must be unique per ProductVariant.

      Parameters:
      key - value to be set
    • setValue

      void setValue(Money value)

      Money value of this Price.

      To set the money value in high precision, use HighPrecisionMoneyDraft.

      Parameters:
      value - value to be set
    • setCountry

      void setCountry(String country)

      Set this field if this Price is only valid for the specified country.

      Parameters:
      country - value to be set
    • setCustomerGroup

      void setCustomerGroup(CustomerGroupResourceIdentifier customerGroup)

      Set this field if this Price is only valid for the referenced CustomerGroup.

      Parameters:
      customerGroup - value to be set
    • setChannel

      void setChannel(ChannelResourceIdentifier channel)

      Set this field if this Price is only valid for the referenced ProductDistribution Channel.

      Parameters:
      channel - value to be set
    • setValidFrom

      void setValidFrom(ZonedDateTime validFrom)

      Set this field if this Price is only valid from the specified date and time. Must be at least 1 ms earlier than validUntil.

      Parameters:
      validFrom - value to be set
    • setValidUntil

      void setValidUntil(ZonedDateTime validUntil)

      Set this field if this Price is only valid until the specified date and time. Must be at least 1 ms later than validFrom. Prices that are no longer valid are not automatically removed, but they can be removed if necessary.

      Parameters:
      validUntil - value to be set
    • setDiscounted

      void setDiscounted(DiscountedPriceDraft discounted)

      Set this field to add a DiscountedPrice from an external service.

      Otherwise, Composable Commerce sets this field automatically if at least one ProductDiscount applies. The DiscountedPrice must reference a ProductDiscount with:

      • The isActive flag set to true.
      • A ProductDiscountValue of type external.
      • A predicate that matches the ProductVariant the Price is referenced from.
      Parameters:
      discounted - value to be set
    • setTiers

      void setTiers(PriceTierDraft... tiers)

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

      Parameters:
      tiers - values to be set
    • setTiers

      void setTiers(List<PriceTierDraft> tiers)

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

      Parameters:
      tiers - values to be set
    • setCustom

      void setCustom(CustomFieldsDraft custom)

      Custom Fields for the Price.

      Specified by:
      setCustom in interface CustomizableDraft<PriceDraft>
      Parameters:
      custom - value to be set
    • of

      static PriceDraft of()
      factory method
      Returns:
      instance of PriceDraft
    • of

      static PriceDraft of(PriceDraft template)
      factory method to create a shallow copy PriceDraft
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • deepCopy

      @Nullable static PriceDraft deepCopy(@Nullable PriceDraft template)
      factory method to create a deep copy of PriceDraft
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      static PriceDraftBuilder builder()
      builder factory method for PriceDraft
      Returns:
      builder
    • builder

      static PriceDraftBuilder builder(PriceDraft template)
      create builder for PriceDraft instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withPriceDraft

      default <T> T withPriceDraft(Function<PriceDraft,T> helper)
      accessor map function
      Type Parameters:
      T - mapped type
      Parameters:
      helper - function to map the object
      Returns:
      mapped value
    • typeReference

      static com.fasterxml.jackson.core.type.TypeReference<PriceDraft> typeReference()
      gives a TypeReference for usage with Jackson DataBind
      Returns:
      TypeReference