| 21464 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
| 21468 |
kshitij.so |
4 |
import java.util.ArrayList;
|
|
|
5 |
import java.util.List;
|
|
|
6 |
import java.util.Map;
|
| 21464 |
kshitij.so |
7 |
|
|
|
8 |
import javax.servlet.http.HttpServletRequest;
|
|
|
9 |
|
|
|
10 |
import org.slf4j.Logger;
|
|
|
11 |
import org.slf4j.LoggerFactory;
|
|
|
12 |
import org.springframework.http.HttpStatus;
|
|
|
13 |
import org.springframework.http.MediaType;
|
|
|
14 |
import org.springframework.http.ResponseEntity;
|
|
|
15 |
import org.springframework.stereotype.Controller;
|
|
|
16 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
17 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
18 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
19 |
|
|
|
20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 21468 |
kshitij.so |
21 |
import com.spice.profitmandi.common.util.Utils;
|
| 21464 |
kshitij.so |
22 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
|
|
23 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
|
|
24 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
|
|
25 |
|
| 21468 |
kshitij.so |
26 |
import in.shop2020.model.v1.order.DenominationType;
|
| 21464 |
kshitij.so |
27 |
import in.shop2020.model.v1.order.DeviceNumberInfo;
|
| 21468 |
kshitij.so |
28 |
import in.shop2020.model.v1.order.RechargeDenomination;
|
| 21464 |
kshitij.so |
29 |
import in.shop2020.model.v1.order.RechargeType;
|
|
|
30 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
31 |
import io.swagger.annotations.ApiImplicitParams;
|
|
|
32 |
import io.swagger.annotations.ApiOperation;
|
|
|
33 |
|
|
|
34 |
@Controller
|
|
|
35 |
public class RechargeController {
|
|
|
36 |
|
|
|
37 |
private static final Logger log=LoggerFactory.getLogger(RechargeController.class);
|
|
|
38 |
|
|
|
39 |
@RequestMapping(value = ProfitMandiConstants.URL_GET_SERVICE_PROVIDER, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
40 |
@ApiImplicitParams({
|
|
|
41 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
|
|
42 |
required = true, dataType = "string", paramType = "header")
|
|
|
43 |
})
|
|
|
44 |
@ApiOperation(value = "")
|
|
|
45 |
public ResponseEntity<?> getServiceProvider(HttpServletRequest request, @RequestParam(value="deviceNumber") String deviceNumber, @RequestParam(value="rechargeType") String rechargeType){
|
|
|
46 |
DeviceNumberInfo deviceInfo = null;
|
|
|
47 |
TransactionClient tcl;
|
|
|
48 |
try {
|
|
|
49 |
tcl = new TransactionClient();
|
|
|
50 |
deviceInfo = tcl.getClient().getServiceProviderForDevice(RechargeType.valueOf(rechargeType), deviceNumber.substring(0,4));
|
|
|
51 |
} catch (Exception e) {
|
|
|
52 |
log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " + rechargeType, e);
|
|
|
53 |
}
|
|
|
54 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, deviceInfo);
|
|
|
55 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
56 |
}
|
| 21468 |
kshitij.so |
57 |
|
|
|
58 |
@RequestMapping(value = ProfitMandiConstants.URL_GET_ALL_DENOMINATIONS, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
59 |
@ApiImplicitParams({
|
|
|
60 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
|
|
61 |
required = true, dataType = "string", paramType = "header")
|
|
|
62 |
})
|
|
|
63 |
@ApiOperation(value = "")
|
|
|
64 |
public ResponseEntity<?> getAllDenominations(HttpServletRequest request, @RequestParam(value="operatorId") long operatorId, @RequestParam(value="circleCode") String circleCode, @RequestParam(value="denominationType") String denominationType){
|
|
|
65 |
List<RechargeDenomination> rechargeDenominations = new ArrayList<RechargeDenomination>();
|
|
|
66 |
TransactionClient tcl;
|
|
|
67 |
try {
|
|
|
68 |
tcl = new TransactionClient();
|
|
|
69 |
rechargeDenominations = tcl.getClient().getRechargeDenominations(operatorId, circleCode, DenominationType.valueOf(denominationType));
|
|
|
70 |
} catch (Exception e) {
|
|
|
71 |
log.error("Unable to get rechargeDenominations for operatorId " + operatorId + " and circleCode : " + circleCode + " and DenominationType : " + denominationType, e);
|
|
|
72 |
}
|
|
|
73 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, rechargeDenominations);
|
|
|
74 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
@RequestMapping(value = ProfitMandiConstants.URL_MOBILE_OPERATORS, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
78 |
@ApiImplicitParams({
|
|
|
79 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
|
|
80 |
required = true, dataType = "string", paramType = "header")
|
|
|
81 |
})
|
|
|
82 |
@ApiOperation(value = "")
|
|
|
83 |
public ResponseEntity<?> getAllMobileOperators(HttpServletRequest request){
|
|
|
84 |
Map<Long, String> mobileProviderMap = Utils.getMobileProvidersMap();
|
|
|
85 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, mobileProviderMap);
|
|
|
86 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
@RequestMapping(value = ProfitMandiConstants.URL_DTH_OPERATORS, method=RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
90 |
@ApiImplicitParams({
|
|
|
91 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
|
|
92 |
required = true, dataType = "string", paramType = "header")
|
|
|
93 |
})
|
|
|
94 |
@ApiOperation(value = "")
|
|
|
95 |
public ResponseEntity<?> getAllDTHOperators(HttpServletRequest request){
|
|
|
96 |
Map<Long, String> dthProviderMap = Utils.getDthProvidersMap();
|
|
|
97 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, dthProviderMap);
|
|
|
98 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
99 |
}
|
|
|
100 |
|
| 21464 |
kshitij.so |
101 |
}
|