| 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;
|
| }
|
|
|
| }
|