@RestResource(id="atg.commerce.pricing.restresources.PriceRestSubresource") public class PriceRestSubresource extends GenericService
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
static java.lang.String |
ENGINE |
static java.lang.String |
MSG_INVALID_PRODUCT_ID |
static java.lang.String |
MSG_INVALID_PRODUCT_SKU_COMBINATION |
static java.lang.String |
MSG_INVALID_QUANTITY |
static java.lang.String |
MSG_PRODUCT_NOT_FOUND_IN_REQUEST_CACHE |
static java.lang.String |
RESOURCE_NAME |
static java.util.ResourceBundle |
sResourceBundle
Resource bundle
|
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
PriceRestSubresource() |
Modifier and Type | Method and Description |
---|---|
protected java.util.List<CommerceItem> |
createPricingCommerceItems(RepositoryItem pProduct,
java.lang.String pSkuId,
double pQuantity)
Create a list of pricing commerce items (for use in pricing).
|
java.lang.String |
getEngineOverrideFilterId()
Returns the EngineOverrideFilterId property, used when view=engine is selected.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
getPrices(java.lang.String pProductId,
java.lang.String pSkuId,
RepositoryItem pProfile)
Returns a map containing the prices for the given product and its skus.
|
RepresentationModel |
getPrices(java.lang.String pProductId,
java.lang.String pSkuId,
java.lang.String pView,
java.lang.String pQuantity)
Return price information for a product and its variants, i.e.
|
java.lang.String |
getPricingCommerceItemsStateMapKey()
Gets the map key used to represent the pricing commerce items state.
|
PricingTools |
getPricingTools()
Returns the PricingTools property.
|
protected RepresentationModel.Builder |
getRepresentationModelBuilder(java.lang.Object pState)
Gets the RepresentationModel.Builder with the given object acting as the state.
|
protected java.util.List<CommerceItem> |
priceProduct(RepositoryItem pProduct,
java.lang.String pSkuId,
java.lang.String pQuantity,
RepositoryItem pProfile)
Prices the given product via the pricing engine, mimicking what would happen if the product is added to the
shopping cart.
|
void |
setEngineOverrideFilterId(java.lang.String pEngineOverrideFilterId)
Sets the EngineOverrideFilterId property, used for when view=engine is selected.
|
void |
setPricingCommerceItemsStateMapKey(java.lang.String pPricingCommerceItemsStateMapKey)
Sets the map key used to represent the pricing commerce items state.
|
void |
setPricingTools(PricingTools pPricingTools)
Sets the PricingTools property.
|
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService, toString
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static final java.lang.String CLASS_VERSION
public static final java.lang.String MSG_INVALID_PRODUCT_ID
public static final java.lang.String MSG_INVALID_PRODUCT_SKU_COMBINATION
public static final java.lang.String MSG_INVALID_QUANTITY
public static final java.lang.String MSG_PRODUCT_NOT_FOUND_IN_REQUEST_CACHE
public static final java.lang.String ENGINE
public static final java.lang.String RESOURCE_NAME
public static java.util.ResourceBundle sResourceBundle
public void setPricingTools(PricingTools pPricingTools)
pPricingTools
- The property value to setpublic PricingTools getPricingTools()
public void setEngineOverrideFilterId(java.lang.String pEngineOverrideFilterId)
pEngineOverrideFilterId
- set the EngineOverrideFilterId property to this valuepublic java.lang.String getEngineOverrideFilterId()
Default filter id is prices.engine-Default.
public void setPricingCommerceItemsStateMapKey(java.lang.String pPricingCommerceItemsStateMapKey)
pPricingCommerceItemsStateMapKey
- the map key used to represent the pricing commerce items statepublic java.lang.String getPricingCommerceItemsStateMapKey()
@Endpoint(id="/prices#GET", isSingular=true, filterId="prices.id-Detailed") public RepresentationModel getPrices(java.lang.String pProductId, java.lang.String pSkuId, java.lang.String pView, java.lang.String pQuantity) throws RestException, CommerceException, RepositoryException
Alternatively if the value of the 'view' query parameter is 'engine' then perform a pricing operation on the sku/product combination using the quantity specified. Prices returned (via a list of CommerceItems) will be influenced by the given quantity and by promotions (as pricing is conducted using the pricing engine). When in 'engine' mode the default filter will change to 'prices.engine-Default' and can be overriden using the 'EngineOverrideFilterId' property.
An example depicting price list prices, including a complex price is as follows:
{ "priceRange": true, "priceMin": 10, "priceMax": 52, "listPrice": 100, "salePrice": 50, "skuPrices": [{ "skuId": "sku001", "listPrice": 52, "salePrice": 50, "saleVolumePrice": { "tieredPrice": { "numLevels": 3, "levels": [{ "levelMinimum": 1, "price": 50, "levelMaximum": 5 }, { "levelMinimum": 6, "price": 40, "levelMaximum": 10 }, { "levelMinimum": 11, "price": 30 }] } }, }, { "skuId": "sku002", "listPrice": 50, "salePrice": 25 }] }
pSkuId
- optional sku id; if not provided, prices for all of the product's child skus will be returnedpView
- optional flag ("engine") indicating that a product/sku should be priced via the pricing enginepQuantity
- optional quantity of the sku to price (engine mode only) and only used when a sku id is given.
If not provided, then the quantity will default to 1.RestException
- if a problem occurs obtaining the pricing informationCommerceException
- if a problem occurs obtaining the pricing informationRepositoryException
- if a problem occurs obtaining the pricing informationprotected java.util.Map<java.lang.String,java.lang.Object> getPrices(java.lang.String pProductId, java.lang.String pSkuId, RepositoryItem pProfile) throws RestException, CommerceException
If the productId and skuId are supplied, the response will be constrained to just that combination. Otherwise, if the productId is supplied but no skuId, prices will be returned for both the product and its skus.
pProductId
- the product id for which we wish to obtain pricespSkuId
- the sku id for which we wish to obtain pricespProfile
- the profile of the shopper; required if prices are contained in price listsRestException
CommerceException
protected java.util.List<CommerceItem> priceProduct(RepositoryItem pProduct, java.lang.String pSkuId, java.lang.String pQuantity, RepositoryItem pProfile) throws RestException, CommerceException, RepositoryException
If a skuId is provided, that particular product-sku combination will be priced, otherwise all the skus for the product will be retrieved and priced.
A quantity can also be provided, denoting the quantity of each product to price. If no quantity is provided, then a value of 1 will be used as the default.
pProduct
- the product to pricepSkuId
- a skuId that can be used to narrow the scope of pricing to the particular product-sku combinationpQuantity
- the quantity of product to price; if null is supplied, a default value of 1 is usedpProfile
- the profile of the shopperRestException
CommerceException
RepositoryException
protected java.util.List<CommerceItem> createPricingCommerceItems(RepositoryItem pProduct, java.lang.String pSkuId, double pQuantity) throws CommerceException, RepositoryException
pProduct
- the product for which we want to create a pricing commerce itempSkuId
- the skuId for which we want to create a pricing commerce itempQuantity
- the quantity of commerce item to create (only used when pSkuId is not null)CommerceException
- if pricing commerce items could not be createdRepositoryException
- if pricing commerce items could not be createdprotected RepresentationModel.Builder getRepresentationModelBuilder(java.lang.Object pState)
pState
- the state that will be added to the representation model