New paste Repaste Download
Old controller
create
@PostMapping(value = { "/points/redeem" },consumes = "application/json")
@ApiOperation(value = "Redeem points", produces = "application/json", response = LoyaltyMemberDetailsRS.class, responseContainer = "List")
@ResponseStatus(HttpStatus.OK)
public ResponseEntity<CreateRedemptionOrderRS> createRedemptionOrder(@RequestBody final CreateRedemptionOrderRQ createRedemptionOrderRQ)
throws ServiceException {
ILoyaltyRedemption loyaltyRedemption = redemptionFactory.getLoyaltyRedemption(createRedemptionOrderRQ.getPartner());
return ResponseEntity.ok(loyaltyRedemption.createRedemption(createRedemptionOrderRQ));
}
cancel
@PostMapping(value = { "/points/refund" },consumes = "application/json")
@ApiOperation(value = "Refunds the points", produces = "application/json", response = LoyaltyMemberDetailsRS.class, responseContainer = "List")
@ResponseStatus(HttpStatus.OK)
public ResponseEntity<CancelRedemptionOrderRS> cancelRedemptionOrder(@RequestBody final CancelRedemptionOrderRQ cancelRedemptionOrderRQ)
throws ServiceException {
ILoyaltyRedemption loyaltyRedemption = redemptionFactory.getLoyaltyRedemption(cancelRedemptionOrderRQ.getPartner());
return ResponseEntity.ok(loyaltyRedemption.cancelRedemption(cancelRedemptionOrderRQ));
}
redemption factory code
package com.abg.loyaltyservice.factory;
import java.util.Map;
import com.abg.loyaltyservice.services.ILoyaltyRedemption;
public class RedemptionFactory {
private final static String DEFAULT = "DEFAULT";
private Map<String, ILoyaltyRedemption> redemptionServiceMap;
public void setRedemptionService(Map<String, ILoyaltyRedemption> redemptionService) {
this.redemptionServiceMap = redemptionService;
}
public ILoyaltyRedemption getLoyaltyRedemption(String partner) {
ILoyaltyRedemption loyaltyRedemption = null;
if (partner != null) {
loyaltyRedemption = redemptionServiceMap.get(partner.toUpperCase());
}
if (loyaltyRedemption == null) {
loyaltyRedemption = redemptionServiceMap.get(DEFAULT);
}
return loyaltyRedemption;
}
}
Filename: None. Size: 2kb. View raw, , hex, or download this file.

This paste expires on 2025-02-06 07:00:50.246088. Pasted through web.