Class VoucherifyVoucherService
java.lang.Object
org.bhn.promotion.voucherify.service.VoucherifyVoucherService
This class contains all methods related to Voucherify Voucher Service
-
Constructor Summary
ConstructorsConstructorDescriptionVoucherifyVoucherService(VoucherifyClient voucherifyClient, VoucherifyValidationService voucherifyValidationService, VoucherifyCampaignService voucherifyCampaignService, PromotionServiceProxy promotionServiceProxy) -
Method Summary
Modifier and TypeMethodDescriptioncreateBulkVouchers(WebhookRequest request) Creates a list of Pimcore promotion models for bulk vouchers associated with a specific campaign.voidcreateOrUpdateVoucher(String voucherId, PimcorePromotionModel pimcorePromotionModel) Creates or updates aPimcorePromotionModelbased on the providedWebhookRequest.WebhookModel.BaseModelresponse.voiddeleteVoucher(WebhookRequest.WebhookModel.BaseModel voucher, PimcorePromotionModel pimcorePromotionModel) Marks a voucher as deleted based on the providedWebhookRequest.WebhookModel.BaseModelmodel.voidenableOrDisableVoucher(WebhookRequest.WebhookModel.BaseModel voucher, PimcorePromotionModel pimcorePromotionModel) Enables or disables a voucher based on the providedWebhookRequest.WebhookModel.BaseModel.List<io.voucherify.client.model.VoucherWithCategories>getCampaignVouchers(String campaignId, LocalDateTime campaignCreatedAt) Retrieves a list of vouchers for a specific campaign IDio.voucherify.client.model.VouchersGetResponseBodygetVoucher(@NotNull String voucherId) Retrieves the details of a specific voucher from Voucherify using the provided voucher ID.io.voucherify.client.model.VouchersListResponseBodygetVouchers(Integer limit, Integer page, String campaignId, io.voucherify.client.model.ParameterCreatedBeforeAfter createdAt) Retrieves a list of vouchers for a specific campaign ID with optional filters for limit, page, and creation date.io.voucherify.client.model.VouchersUpdateResponseBodyupdateVoucher(String voucherCode, io.voucherify.client.model.VouchersUpdateRequestBody vouchersUpdateRequestBody) Update VoucherupdateVouchers(Map<String, io.voucherify.client.model.VouchersUpdateRequestBody> vouchersUpdateRequestMap) Update a list of Vouchers
-
Constructor Details
-
VoucherifyVoucherService
@Autowired public VoucherifyVoucherService(VoucherifyClient voucherifyClient, VoucherifyValidationService voucherifyValidationService, VoucherifyCampaignService voucherifyCampaignService, PromotionServiceProxy promotionServiceProxy)
-
-
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
VouchersGetResponseBodycontaining 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
VouchersListResponseBodycontaining 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 idcampaignCreatedAt- Campaign creation time- Returns:
- a
ListofVoucherWithCategoriescontaining 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 aPimcorePromotionModelbased on the providedWebhookRequest.WebhookModel.BaseModelresponse.- Parameters:
voucherId- theStringcontaining the voucher information.pimcorePromotionModel- thePimcorePromotionModelto 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 providedWebhookRequest.WebhookModel.BaseModel.- Parameters:
voucher- theWebhookRequest.WebhookModel.BaseModelcontaining the voucher information.pimcorePromotionModel- thePimcorePromotionModelto 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 providedWebhookRequest.WebhookModel.BaseModelmodel.- Parameters:
voucher- theWebhookRequest.WebhookModel.BaseModelcontaining the voucher information.pimcorePromotionModel- thePimcorePromotionModelto 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
PimcorePromotionModelobjects 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 andVouchersUpdateRequestBody- Returns:
- a Map of Voucher Code and
VouchersUpdateResponseBodywith 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 CodevouchersUpdateRequestBody- aVouchersUpdateRequestBodycontaining details to update.- Returns:
- a
VouchersUpdateResponseBodycontaining updated details.
-