Class VoucherifyCampaignService

java.lang.Object
org.bhn.promotion.voucherify.service.VoucherifyCampaignService

@Service public class VoucherifyCampaignService extends Object
This class contains all methods related to Voucherify Campaign Service
  • Constructor Details

    • VoucherifyCampaignService

      public VoucherifyCampaignService()
  • Method Details

    • getCampaign

      public CampaignModel getCampaign(String campaignId)
      Retrieves a campaign by its ID and maps it to a CampaignModel.
      Parameters:
      campaignId - the ID of the campaign to be retrieved.
      Returns:
      a CampaignModel representing the retrieved campaign or an error model if an exception occurred during retrieval.
    • createCampaign

      public CampaignModel createCampaign(@Valid @Valid CampaignModel campaignModel)
      This method invokes voucherify api and Creates campaign
      Parameters:
      campaignModel - CampaignModel Create Campaign Request
      Returns:
      CampaignModel Create Campaign Response
    • updateCampaignBudget

      public CampaignModel updateCampaignBudget(@Valid @Valid CampaignModel campaignModel)
      This method invokes voucherify api and Updates campaign
      Parameters:
      campaignModel - CampaignModel Update Campaign Request
      Returns:
      CampaignsUpdateResponseBody Update 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 - String Campaign Id
      requestBody - CampaignsUpdateRequestBody Update Campaign Request
      Returns:
      CampaignsUpdateResponseBody Update Campaign Response
    • createPromotion

      public CampaignModel createPromotion(@Valid @Valid CampaignModel campaignModel)
      This method invokes voucherify api and Creates campaign if promotions are not present already
      Parameters:
      campaignModel - CampaignModel Create Campaign Request
      Returns:
      CampaignModel Create 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 CampaignsGetResponseBody containing 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 provided WebhookRequest.WebhookModel and updates the corresponding PimcorePromotionModel.
      Parameters:
      model - the WebhookRequest.WebhookModel containing the details of the campaign to be deleted.
      pimcorePromotionModel - the PimcorePromotionModel to be updated for each deleted campaign.
      Returns:
      a List of PimcorePromotionModel representing 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.