Class VoucherifyValidationService
java.lang.Object
org.bhn.promotion.voucherify.service.VoucherifyValidationService
This class contains all methods related to Voucherify Validation Service
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis method parses a logical expression represented as a string and identifies groups of rule keys enclosed in brackets.voidprocessCampaignValidationRulesAndSavePromotionBudget(String campaignId, PimcorePromotionModel pimcorePromotionModel, io.voucherify.client.model.CampaignsGetResponseBody voucherifyCampaignModel) Processes the validation rules for a given campaign and saves the corresponding promotion budget.io.voucherify.client.model.ValidationRulesUpdateResponseBodyupdatePromotionBudgetInVoucherify(String validationRuleId, BigDecimal partialRefundAmount, boolean overwriteBudget) Updates the promotion budget in Voucherify based on the given validation rule ID and partial refund amount.
-
Constructor Details
-
VoucherifyValidationService
public VoucherifyValidationService()
-
-
Method Details
-
extractGroupedRuleKeysFromLogic
This method parses a logical expression represented as a string and identifies groups of rule keys enclosed in brackets. Each group is further split into individual keys using the logical "AND" operator. The extracted keys are grouped into lists, where each list represents a group from the original expression.- Parameters:
logic- the logical expression to parse, which may include groups enclosed in brackets and separated by logical operators- Returns:
- a list of lists, where each inner list contains rule keys extracted from one group in the logical expression
-
processCampaignValidationRulesAndSavePromotionBudget
public void processCampaignValidationRulesAndSavePromotionBudget(String campaignId, PimcorePromotionModel pimcorePromotionModel, io.voucherify.client.model.CampaignsGetResponseBody voucherifyCampaignModel) Processes the validation rules for a given campaign and saves the corresponding promotion budget.- Parameters:
campaignId- The unique identifier for the campaign.pimcorePromotionModel- The Pimcore promotion model that contains campaign-related data.voucherifyCampaignModel- A list of validation rule assignments that need to be processed for the campaign.
-
updatePromotionBudgetInVoucherify
public io.voucherify.client.model.ValidationRulesUpdateResponseBody updatePromotionBudgetInVoucherify(String validationRuleId, BigDecimal partialRefundAmount, boolean overwriteBudget) throws io.voucherify.client.ApiException Updates the promotion budget in Voucherify based on the given validation rule ID and partial refund amount. It retrieves the validation rule, checks if the promotion budget is positive, and updates the conditions associated with the rule to reflect the partial refund.- Parameters:
validationRuleId- The ID of the validation rule to update.partialRefundAmount- The amount to be added to the current promotion budget.- Returns:
- A ValidationRulesUpdateResponseBody containing the updated validation rule, or null if the update didn't occur.
- Throws:
io.voucherify.client.ApiException- If an error occurs while making the API call.
-