Class VoucherifyPromotionProductService
- All Implemented Interfaces:
PromotionProductService
PromotionProductService interface that integrates with Voucherify
to manage products and SKUs (Stock Keeping Units).
This service is responsible for creating, updating, and retrieving products and their associated SKUs by interacting with the Voucherify API.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbulkProductDelete(List<PMSProductModel> pmsProductModelList) Deletes multiple products in bulk.createBulkProducts(List<PMSProductModel> pmsProductModelList) Creates multiple products in bulk by sending requests to Voucherify.createOrUpdateBulkProducts(List<PMSProductModel> pmsProductModelList) Creates and updates multiple products in bulk by sending requests to VoucherifycreateOrUpdateProducts(PMSProductModel pmsProductModel) Creates Or updates a product in Voucherify.createProduct(PMSProductModel productModel) Creates a new product in Voucherify.createProductSKU(PMSProductSkuModel skuModel) Creates a new SKU for a product in Voucherify.createProductWithSKU(PMSProductModel pmsProductModel) Creates a new product along with its associated SKUs in Voucherify.getProduct(String productId) Retrieves a product from Voucherify by its unique identifier.getProductsFromProductCollection(String productCollectionId) Retrieves a list of products within a specified product collection.updateMetaData(io.voucherify.client.model.ProductsGetResponseBody response, PMSProductModel productModel) Updates the metadata of a given product model based on the metadata from a response.updateProduct(PMSProductModel productModel) Updates an existing product in Voucherify.
-
Constructor Details
-
VoucherifyPromotionProductService
public VoucherifyPromotionProductService()
-
-
Method Details
-
createProduct
Creates a new product in Voucherify.This method maps the
PMSProductModelto a VoucherifyProductsCreateRequestBodyand sends a request to create the product in Voucherify. The response is then mapped back toPMSProductModel.- Specified by:
createProductin interfacePromotionProductService- Parameters:
productModel- thePMSProductModelrepresenting the product to be created.- Returns:
- the created
PMSProductModelwith updated details from Voucherify.
-
createBulkProducts
Creates multiple products in bulk by sending requests to Voucherify.This method iterates over a list of
PMSProductModelobjects and callscreateProduct(PMSProductModel)for each one, returning a list of created products.- Specified by:
createBulkProductsin interfacePromotionProductService- Parameters:
pmsProductModelList- a list ofPMSProductModelrepresenting the products to be created.- Returns:
- a list of created
PMSProductModelobjects.
-
updateProduct
Updates an existing product in Voucherify.This method maps the
PMSProductModelto a VoucherifyProductsUpdateRequestBodyand sends a request to update the product in Voucherify. The response is then mapped back toPMSProductModel.- Specified by:
updateProductin interfacePromotionProductService- Parameters:
productModel- thePMSProductModelrepresenting the product to be updated.- Returns:
- the updated
PMSProductModelwith details from Voucherify.
-
createProductSKU
Creates a new SKU for a product in Voucherify.This method maps the
PMSProductSkuModelto a VoucherifyProductsSkusCreateRequestBodyand sends a request to create the SKU for the specified product in Voucherify. The response is then mapped back toPMSProductSkuModel.- Specified by:
createProductSKUin interfacePromotionProductService- Parameters:
skuModel- thePMSProductSkuModelrepresenting the SKU to be created.- Returns:
- the created
PMSProductSkuModelwith updated details from Voucherify.
-
createProductWithSKU
Creates a new product along with its associated SKUs in Voucherify.This method first creates the product in Voucherify and then creates each associated SKU. Finally, it retrieves and returns the full product details, including the SKUs.
- Specified by:
createProductWithSKUin interfacePromotionProductService- Parameters:
pmsProductModel- thePMSProductModelrepresenting the product and its SKUs to be created.- Returns:
- the
PMSProductModelwith updated details and SKUs from Voucherify.
-
getProduct
Retrieves a product from Voucherify by its unique identifier.This method fetches the product details from Voucherify using the product ID and maps the response to a
PMSProductModel.- Specified by:
getProductin interfacePromotionProductService- Parameters:
productId- the unique identifier of the product to be retrieved.- Returns:
- the
PMSProductModelrepresenting the retrieved product.
-
getProductsFromProductCollection
Retrieves a list of products within a specified product collection. If an error occurs while fetching the collection, returns a list containing a singlePMSProductModelwith error details.- Specified by:
getProductsFromProductCollectionin interfacePromotionProductService- Parameters:
productCollectionId- the unique identifier of the product collection to retrieve- Returns:
- a list of
PMSProductModelinstances representing the products in the specified collection; if an error occurs, returns a list containing a single error model
-
createOrUpdateBulkProducts
Creates and updates multiple products in bulk by sending requests to VoucherifyThis method iterates over a list of
PMSProductModelobjects and callscreateOrUpdateProducts(PMSProductModel)for each one, returning a list of created Or updated products.- Specified by:
createOrUpdateBulkProductsin interfacePromotionProductService- Parameters:
pmsProductModelList- a list ofPMSProductModelrepresenting the products to be created.- Returns:
- a list of created
PMSProductModelobjects
-
bulkProductDelete
public Map<String,List<PMSProductModel>> bulkProductDelete(List<PMSProductModel> pmsProductModelList) Description copied from interface:PromotionProductServiceDeletes multiple products in bulk.- Specified by:
bulkProductDeletein interfacePromotionProductService- Parameters:
pmsProductModelList- a list ofPMSProductModelobjects representing the products to be deleted. This list must not benullor empty.- Returns:
- a map containing lists of products categorized by their deletion status: "DELETED", "NOT_FOUND", and "ERRORED".
-
createOrUpdateProducts
Creates Or updates a product in Voucherify.This method maps the
PMSProductModelto a VoucherifyProductsGetResponseBodyand sends a request to create OR update the product in Voucherify. The response is then mapped back toPMSProductModel.- Specified by:
createOrUpdateProductsin interfacePromotionProductService- Parameters:
pmsProductModel- thePMSProductModelrepresenting the product to be created OR Updated.- Returns:
- the created
PMSProductModelwith updated details from Voucherify.
-
updateMetaData
public PMSProductModel updateMetaData(io.voucherify.client.model.ProductsGetResponseBody response, PMSProductModel productModel) Updates the metadata of a given product model based on the metadata from a response. This method checks if the response contains tenant data and adds it to the product model if it does not already exist.- Parameters:
response- The response contains the existing metadata.productModel- The product contains the new metadata.
-