Class VoucherifyCampaignService
java.lang.Object
org.bhn.promotion.voucherify.service.VoucherifyCampaignService
This class contains all methods related to Voucherify Campaign Service
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateCampaign(@Valid CampaignModel campaignModel) This method invokes voucherify api and Creates campaignvoidcreateOrUpdateCampaignBudget(@Valid WebhookRequest.WebhookModel.BaseModel campaignModel, PimcorePromotionModel pimcorePromotionModel) Create or Updates the campaign budget and processes the associated validation rules.createPromotion(@Valid CampaignModel campaignModel) This method invokes voucherify api and Creates campaign if promotions are not present alreadydeleteCampaign(WebhookRequest.WebhookModel model, PimcorePromotionModel pimcorePromotionModel) Deletes a campaign based on the providedWebhookRequest.WebhookModeland updates the correspondingPimcorePromotionModel.getCampaign(String campaignId) Retrieves a campaign by its ID and maps it to aCampaignModel.io.voucherify.client.model.CampaignsGetResponseBodygetVoucherifyCampaign(String campaignId) Retrieves the details of a specific campaign from Voucherify using the provided campaign ID.io.voucherify.client.model.CampaignsUpdateResponseBodyupdateCampaign(String campaignId, io.voucherify.client.model.CampaignsUpdateRequestBody requestBody) This method invokes voucherify api and Updates campaignupdateCampaignBudget(@Valid CampaignModel campaignModel) This method invokes voucherify api and Updates campaignvoidupdateCampaignBudgetWithOverdraftAmount(String campaignId, BigDecimal overdraftAmount) Updates the campaign budget with the given overdraft amount by iterating over the validation rule assignments.voidupdateCampaignBudgetWithPartialRefundAmount(String campaignId, BigDecimal partialRefundAmount) Updates the campaign budget with the given partial refund amount by iterating over the validation rule assignments.
-
Constructor Details
-
VoucherifyCampaignService
public VoucherifyCampaignService()
-
-
Method Details
-
getCampaign
Retrieves a campaign by its ID and maps it to aCampaignModel.- Parameters:
campaignId- the ID of the campaign to be retrieved.- Returns:
- a
CampaignModelrepresenting the retrieved campaign or an error model if an exception occurred during retrieval.
-
createCampaign
This method invokes voucherify api and Creates campaign- Parameters:
campaignModel-CampaignModelCreate Campaign Request- Returns:
CampaignModelCreate Campaign Response
-
updateCampaignBudget
This method invokes voucherify api and Updates campaign- Parameters:
campaignModel-CampaignModelUpdate Campaign Request- Returns:
CampaignsUpdateResponseBodyUpdate Campaign Response
-
updateCampaign
public io.voucherify.client.model.CampaignsUpdateResponseBody updateCampaign(String campaignId, io.voucherify.client.model.CampaignsUpdateRequestBody requestBody) This method invokes voucherify api and Updates campaign- Parameters:
campaignId-StringCampaign IdrequestBody-CampaignsUpdateRequestBodyUpdate Campaign Request- Returns:
CampaignsUpdateResponseBodyUpdate Campaign Response
-
createPromotion
This method invokes voucherify api and Creates campaign if promotions are not present already- Parameters:
campaignModel-CampaignModelCreate Campaign Request- Returns:
CampaignModelCreate Campaign Response
-
getVoucherifyCampaign
public io.voucherify.client.model.CampaignsGetResponseBody getVoucherifyCampaign(String campaignId) throws VoucherifyApiException Retrieves the details of a specific campaign from Voucherify using the provided campaign ID.- Parameters:
campaignId- the ID of the campaign to be retrieved.- Returns:
- a
CampaignsGetResponseBodycontaining the details of the requested campaign. - Throws:
VoucherifyApiException- if an error occurs while retrieving the campaign, such as an invalid campaign ID.
-
deleteCampaign
public List<PimcorePromotionModel> deleteCampaign(WebhookRequest.WebhookModel model, PimcorePromotionModel pimcorePromotionModel) Deletes a campaign based on the providedWebhookRequest.WebhookModeland updates the correspondingPimcorePromotionModel.- Parameters:
model- theWebhookRequest.WebhookModelcontaining the details of the campaign to be deleted.pimcorePromotionModel- thePimcorePromotionModelto be updated for each deleted campaign.- Returns:
- a
ListofPimcorePromotionModelrepresenting the updated promotions marked as deleted.
-
createOrUpdateCampaignBudget
public void createOrUpdateCampaignBudget(@Valid @Valid WebhookRequest.WebhookModel.BaseModel campaignModel, PimcorePromotionModel pimcorePromotionModel) Create or Updates the campaign budget and processes the associated validation rules.- Parameters:
campaignModel- The base model containing the campaign details to be updated.pimcorePromotionModel- The Pimcore promotion model that will be updated with the campaign details.
-
updateCampaignBudgetWithPartialRefundAmount
public void updateCampaignBudgetWithPartialRefundAmount(String campaignId, BigDecimal partialRefundAmount) throws VoucherifyApiException, io.voucherify.client.ApiException Updates the campaign budget with the given partial refund amount by iterating over the validation rule assignments. For each validation rule assignment, the associated validation rule's budget is updated.- Parameters:
campaignId- The ID of the campaign whose budget is being updated.partialRefundAmount- The partial refund amount to be added to the campaign's budget.- Throws:
VoucherifyApiException- If there is an issue with the Voucherify API call.io.voucherify.client.ApiException- If there is a general API exception.
-
updateCampaignBudgetWithOverdraftAmount
public void updateCampaignBudgetWithOverdraftAmount(String campaignId, BigDecimal overdraftAmount) throws VoucherifyApiException, io.voucherify.client.ApiException Updates the campaign budget with the given overdraft amount by iterating over the validation rule assignments. For each validation rule assignment, the associated validation rule's budget is updated.- Parameters:
campaignId- The ID of the campaign whose budget is being updated.overdraftAmount- The overdraft amount to be added to the campaign's budget.- Throws:
VoucherifyApiException- If there is an issue with the Voucherify API call.io.voucherify.client.ApiException- If there is a general API exception.
-