Class VoucherifyVoucherService

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

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

  • Method Details

    • getVoucher

      public io.voucherify.client.model.VouchersGetResponseBody getVoucher(@NotNull @NotNull String voucherId) throws VoucherifyApiException
      Retrieves the details of a specific voucher from Voucherify using the provided voucher ID.
      Parameters:
      voucherId - the ID of the voucher to be retrieved. Must not be null.
      Returns:
      a VouchersGetResponseBody containing the details of the requested voucher.
      Throws:
      VoucherifyApiException - if an error occurs while retrieving the voucher, such as an invalid voucher ID.
    • getVouchers

      public io.voucherify.client.model.VouchersListResponseBody getVouchers(Integer limit, Integer page, String campaignId, io.voucherify.client.model.ParameterCreatedBeforeAfter createdAt) throws VoucherifyApiException
      Retrieves a list of vouchers for a specific campaign ID with optional filters for limit, page, and creation date.
      Parameters:
      limit - The maximum number of vouchers to retrieve in the response. (Optional)
      page - The page number to retrieve (useful for pagination). (Optional)
      campaignId - The ID of the campaign to filter vouchers by. (Required)
      createdAt - Filters vouchers based on their creation date (before or after). (Optional)
      Returns:
      A VouchersListResponseBody containing the list of vouchers and associated metadata.
      Throws:
      VoucherifyApiException - If an error occurs while fetching vouchers, such as an invalid campaign ID or API error.
    • getCampaignVouchers

      public List<io.voucherify.client.model.VoucherWithCategories> getCampaignVouchers(String campaignId, LocalDateTime campaignCreatedAt) throws VoucherifyApiException
      Retrieves a list of vouchers for a specific campaign ID
      Parameters:
      campaignId - Campaign id
      campaignCreatedAt - Campaign creation time
      Returns:
      a List of VoucherWithCategories containing the vouchers associated with the specified campaign
      Throws:
      VoucherifyApiException - if an error occurs while fetching vouchers from the Voucherify API
    • createOrUpdateVoucher

      public void createOrUpdateVoucher(String voucherId, PimcorePromotionModel pimcorePromotionModel) throws VoucherifyApiException
      Creates or updates a PimcorePromotionModel based on the provided WebhookRequest.WebhookModel.BaseModel response.
      Parameters:
      voucherId - the String containing the voucher information.
      pimcorePromotionModel - the PimcorePromotionModel to be updated with voucher details.
      Throws:
      VoucherifyApiException - if an error occurs while retrieving the voucher or processing validation rules.
    • enableOrDisableVoucher

      public void enableOrDisableVoucher(WebhookRequest.WebhookModel.BaseModel voucher, PimcorePromotionModel pimcorePromotionModel)
      Enables or disables a voucher based on the provided WebhookRequest.WebhookModel.BaseModel.
      Parameters:
      voucher - the WebhookRequest.WebhookModel.BaseModel containing the voucher information.
      pimcorePromotionModel - the PimcorePromotionModel to be updated with the voucher's active status.
    • deleteVoucher

      public void deleteVoucher(WebhookRequest.WebhookModel.BaseModel voucher, PimcorePromotionModel pimcorePromotionModel)
      Marks a voucher as deleted based on the provided WebhookRequest.WebhookModel.BaseModel model.
      Parameters:
      voucher - the WebhookRequest.WebhookModel.BaseModel containing the voucher information.
      pimcorePromotionModel - the PimcorePromotionModel to be updated to indicate the voucher's deletion.
    • createBulkVouchers

      public List<PimcorePromotionModel> createBulkVouchers(WebhookRequest request) throws VoucherifyApiException
      Creates a list of Pimcore promotion models for bulk vouchers associated with a specific campaign. This method handles the retrieval of vouchers in batches from the Voucherify API and processes them into Pimcore promotion models.
      Parameters:
      request - the webhook request containing campaign and timestamp details.
      Returns:
      a list of PimcorePromotionModel objects representing the processed vouchers.
      Throws:
      VoucherifyApiException - if an error occurs during API interaction with Voucherify.
    • updateVouchers

      public Map<String,io.voucherify.client.model.VouchersUpdateResponseBody> updateVouchers(Map<String,io.voucherify.client.model.VouchersUpdateRequestBody> vouchersUpdateRequestMap)
      Update a list of Vouchers
      Parameters:
      vouchersUpdateRequestMap - a Map of Voucher Code and VouchersUpdateRequestBody
      Returns:
      a Map of Voucher Code and VouchersUpdateResponseBody with successful updates. For failed update, return null
    • updateVoucher

      public io.voucherify.client.model.VouchersUpdateResponseBody updateVoucher(String voucherCode, io.voucherify.client.model.VouchersUpdateRequestBody vouchersUpdateRequestBody)
      Update Voucher
      Parameters:
      voucherCode - Voucher Code
      vouchersUpdateRequestBody - a VouchersUpdateRequestBody containing details to update.
      Returns:
      a VouchersUpdateResponseBody containing updated details.