| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.security.Key;
|
- |
|
| 4 |
import java.time.LocalDate;
|
- |
|
| 5 |
import java.time.LocalDateTime;
|
- |
|
| 6 |
import java.time.ZoneId;
|
- |
|
| 7 |
import java.time.format.DateTimeFormatter;
|
- |
|
| 8 |
import java.util.Arrays;
|
- |
|
| 9 |
import java.util.HashMap;
|
- |
|
| 10 |
import java.util.List;
|
- |
|
| 11 |
import java.util.Map;
|
- |
|
| 12 |
|
- |
|
| 13 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 14 |
|
- |
|
| 15 |
import org.apache.http.Header;
|
- |
|
| 16 |
import org.apache.http.HttpResponse;
|
- |
|
| 17 |
import org.apache.http.conn.HttpHostConnectException;
|
- |
|
| 18 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 19 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 20 |
import org.json.JSONObject;
|
- |
|
| 21 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 22 |
import org.springframework.beans.factory.annotation.Value;
|
- |
|
| 23 |
import org.springframework.http.MediaType;
|
- |
|
| 24 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 25 |
import org.springframework.stereotype.Controller;
|
3 |
import org.springframework.stereotype.Controller;
|
| 26 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 27 |
import org.springframework.web.bind.annotation.RequestBody;
|
- |
|
| 28 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 29 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 30 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 31 |
|
4 |
|
| - |
|
5 |
/*
|
| - |
|
6 |
* import java.security.Key;
|
| - |
|
7 |
* import java.time.LocalDate;
|
| - |
|
8 |
* import java.time.LocalDateTime;
|
| - |
|
9 |
* import java.time.ZoneId;
|
| - |
|
10 |
* import java.time.format.DateTimeFormatter;
|
| - |
|
11 |
* import java.util.Arrays;
|
| - |
|
12 |
* import java.util.HashMap;
|
| - |
|
13 |
* import java.util.List;
|
| - |
|
14 |
* import java.util.Map;
|
| - |
|
15 |
*
|
| - |
|
16 |
* import javax.servlet.http.HttpServletRequest;
|
| - |
|
17 |
*
|
| - |
|
18 |
* import org.apache.http.Header;
|
| - |
|
19 |
* import org.apache.http.HttpResponse;
|
| - |
|
20 |
* import org.apache.http.conn.HttpHostConnectException;
|
| - |
|
21 |
* import org.apache.logging.log4j.LogManager;
|
| - |
|
22 |
* import org.apache.logging.log4j.Logger;
|
| - |
|
23 |
* import org.json.JSONObject;
|
| - |
|
24 |
* import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
25 |
* import org.springframework.beans.factory.annotation.Value;
|
| - |
|
26 |
* import org.springframework.http.MediaType;
|
| - |
|
27 |
* import org.springframework.http.ResponseEntity;
|
| - |
|
28 |
* import org.springframework.stereotype.Controller;
|
| - |
|
29 |
* import org.springframework.web.bind.annotation.RequestBody;
|
| - |
|
30 |
* import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
31 |
* import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
32 |
* import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
33 |
*
|
| 32 |
import com.google.gson.Gson;
|
34 |
* import com.google.gson.Gson;
|
| 33 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
35 |
* import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 34 |
import com.spice.profitmandi.common.web.client.RestClient;
|
36 |
* import com.spice.profitmandi.common.web.client.RestClient;
|
| 35 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
37 |
* import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 36 |
import com.spice.profitmandi.dao.entity.fofo.Campaign;
|
38 |
* import com.spice.profitmandi.dao.entity.fofo.Campaign;
|
| 37 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
39 |
* import com.spice.profitmandi.dao.entity.fofo.Customer;
|
| 38 |
import com.spice.profitmandi.dao.entity.fofo.ThriweMembers;
|
40 |
* import com.spice.profitmandi.dao.entity.fofo.ThriweMembers;
|
| 39 |
import com.spice.profitmandi.dao.model.thriwe.benefit.BenefitGroup;
|
41 |
* import com.spice.profitmandi.dao.model.thriwe.benefit.BenefitGroup;
|
| 40 |
import com.spice.profitmandi.dao.model.thriwe.benefit.BenefitResponse;
|
42 |
* import com.spice.profitmandi.dao.model.thriwe.benefit.BenefitResponse;
|
| 41 |
import com.spice.profitmandi.dao.model.thriwe.benefitConfiguration.BenefitConfigurationResponse;
|
43 |
* import com.spice.profitmandi.dao.model.thriwe.benefitConfiguration.BenefitConfigurationResponse;
|
| 42 |
import com.spice.profitmandi.dao.repository.fofo.CampaignRepository;
|
44 |
* import com.spice.profitmandi.dao.repository.fofo.CampaignRepository;
|
| 43 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
45 |
* import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
| 44 |
import com.spice.profitmandi.dao.repository.fofo.ThriweMemberRepository;
|
46 |
* import com.spice.profitmandi.dao.repository.fofo.ThriweMemberRepository;
|
| - |
|
47 |
*
|
| - |
|
48 |
* //import io.jsonwebtoken.Jwts;
|
| - |
|
49 |
* //import io.jsonwebtoken.security.Keys;
|
| - |
|
50 |
* import io.swagger.annotations.ApiImplicitParam;
|
| - |
|
51 |
* import io.swagger.annotations.ApiImplicitParams;
|
| - |
|
52 |
* import io.swagger.annotations.ApiOperation;
|
| - |
|
53 |
*/
|
| 45 |
|
54 |
|
| 46 |
import io.jsonwebtoken.Jwts;
|
- |
|
| 47 |
import io.jsonwebtoken.security.Keys;
|
- |
|
| 48 |
import io.swagger.annotations.ApiImplicitParam;
|
- |
|
| 49 |
import io.swagger.annotations.ApiImplicitParams;
|
- |
|
| 50 |
import io.swagger.annotations.ApiOperation;
|
55 |
import org.springframework.transaction.annotation.Transactional;
|
| 51 |
|
56 |
|
| 52 |
@Controller
|
57 |
@Controller
|
| 53 |
@Transactional(rollbackFor = Throwable.class)
|
58 |
@Transactional(rollbackFor = Throwable.class)
|
| 54 |
public class ThriweController {
|
59 |
public class ThriweController {
|
| 55 |
|
60 |
|
| 56 |
@Autowired
|
61 |
/* @Autowired
|
| 57 |
private ResponseSender<?> responseSender;
|
62 |
private ResponseSender<?> responseSender;
|
| 58 |
|
63 |
|
| 59 |
@Autowired
|
64 |
@Autowired
|
| 60 |
private CustomerRepository customerRepository;
|
65 |
private CustomerRepository customerRepository;
|
| 61 |
|
66 |
|
| 62 |
@Autowired
|
67 |
@Autowired
|
| 63 |
RestClient restClient;
|
68 |
RestClient restClient;
|
| 64 |
|
69 |
|
| 65 |
// @Value("${thriwe.account.token}")
|
70 |
// @Value("${thriwe.account.token}")
|
| 66 |
private String token;
|
71 |
private String token;
|
| 67 |
|
72 |
|
| 68 |
@Autowired
|
73 |
@Autowired
|
| 69 |
CampaignRepository campaignRepository;
|
74 |
CampaignRepository campaignRepository;
|
| 70 |
|
75 |
|
| 71 |
@Autowired
|
76 |
@Autowired
|
| 72 |
private ThriweMemberRepository thriweMemberRepository;
|
77 |
private ThriweMemberRepository thriweMemberRepository;
|
| 73 |
|
78 |
|
| 74 |
@Autowired
|
79 |
@Autowired
|
| 75 |
private Gson gson;
|
80 |
private Gson gson;
|
| 76 |
|
81 |
|
| 77 |
|
82 |
|
| 78 |
private static final Logger LOGGER = LogManager.getLogger(ThriweController.class);
|
83 |
private static final Logger LOGGER = LogManager.getLogger(ThriweController.class);
|
| 79 |
|
84 |
|
| 80 |
|
85 |
|
| 81 |
@RequestMapping(value = "/thriwe/validate/customer", method = RequestMethod.GET)
|
86 |
@RequestMapping(value = "/thriwe/validate/customer", method = RequestMethod.GET)
|
| 82 |
public ResponseEntity<?> validateCustomer(HttpServletRequest request) throws HttpHostConnectException, ProfitMandiBusinessException {
|
87 |
public ResponseEntity<?> validateCustomer(HttpServletRequest request) throws HttpHostConnectException, ProfitMandiBusinessException {
|
| 83 |
|
88 |
|
| 84 |
List<Campaign> campaigns = campaignRepository.selectAll();
|
89 |
List<Campaign> campaigns = campaignRepository.selectAll();
|
| 85 |
String memberShipId = null;
|
90 |
String memberShipId = null;
|
| 86 |
if (!campaigns.isEmpty()) {
|
91 |
if (!campaigns.isEmpty()) {
|
| 87 |
|
92 |
|
| 88 |
Campaign campaign = campaigns.get(0);
|
93 |
Campaign campaign = campaigns.get(0);
|
| 89 |
Customer customer = customerRepository.selectById(32697);
|
94 |
Customer customer = customerRepository.selectById(32697);
|
| 90 |
|
95 |
|
| 91 |
Map<String, String> params = new HashMap<String, String>();
|
96 |
Map<String, String> params = new HashMap<String, String>();
|
| 92 |
String userName = customer.getId() + "-" + campaign.getId();
|
97 |
String userName = customer.getId() + "-" + campaign.getId();
|
| 93 |
LOGGER.info("token {}", token);
|
98 |
LOGGER.info("token {}", token);
|
| 94 |
|
99 |
|
| 95 |
|
100 |
|
| 96 |
String secretKey = "smartdukan@thriwe_123smartdukaan";
|
101 |
String secretKey = "smartdukan@thriwe_123smartdukaan";
|
| 97 |
|
102 |
|
| 98 |
JSONObject jsonObject = new JSONObject();
|
103 |
JSONObject jsonObject = new JSONObject();
|
| 99 |
jsonObject.put("exp", LocalDateTime.now().plusDays(4).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000);
|
104 |
jsonObject.put("exp", LocalDateTime.now().plusDays(4).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000);
|
| 100 |
jsonObject.put("iat", LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000);
|
105 |
jsonObject.put("iat", LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000);
|
| 101 |
jsonObject.put("userName", userName);
|
106 |
jsonObject.put("userName", userName);
|
| 102 |
jsonObject.put("email", customer.getEmailId());
|
107 |
jsonObject.put("email", customer.getEmailId());
|
| 103 |
jsonObject.put("mobileNumber", customer.getMobileNumber());
|
108 |
jsonObject.put("mobileNumber", customer.getMobileNumber());
|
| 104 |
jsonObject.put("firstName", customer.getFirstName());
|
109 |
jsonObject.put("firstName", customer.getFirstName());
|
| 105 |
jsonObject.put("lastName", customer.getLastName());
|
110 |
jsonObject.put("lastName", customer.getLastName());
|
| 106 |
jsonObject.put("expiryDate", LocalDate.now().plusDays(4).format(DateTimeFormatter.ofPattern("dd/MM/yyyy")));
|
111 |
jsonObject.put("expiryDate", LocalDate.now().plusDays(4).format(DateTimeFormatter.ofPattern("dd/MM/yyyy")));
|
| 107 |
|
112 |
|
| 108 |
LOGGER.info("jsonObject {}", jsonObject.toString());
|
113 |
LOGGER.info("jsonObject {}", jsonObject.toString());
|
| 109 |
|
114 |
|
| 110 |
Map<String, Object> headersjwt = new HashMap<>();
|
115 |
Map<String, Object> headersjwt = new HashMap<>();
|
| 111 |
headersjwt.put("alg", "HS256");
|
116 |
headersjwt.put("alg", "HS256");
|
| 112 |
headersjwt.put("typ", "JWT");
|
117 |
headersjwt.put("typ", "JWT");
|
| 113 |
|
118 |
|
| 114 |
Key key = Keys.hmacShaKeyFor(secretKey.getBytes());
|
119 |
Key key = Keys.hmacShaKeyFor(secretKey.getBytes());
|
| 115 |
|
120 |
|
| 116 |
String jwt = Jwts.builder().setHeaderParam("alg", "HS256").setHeaderParam("typ", "JWT").setPayload(jsonObject.toString()).signWith(key).compact();
|
121 |
String jwt = Jwts.builder().setHeaderParam("alg", "HS256").setHeaderParam("typ", "JWT").setPayload(jsonObject.toString()).signWith(key).compact();
|
| 117 |
|
122 |
|
| 118 |
LOGGER.info("jwt {}", jwt);
|
123 |
LOGGER.info("jwt {}", jwt);
|
| 119 |
|
124 |
|
| 120 |
|
125 |
|
| 121 |
Map<String, String> headers = new HashMap<String, String>();
|
126 |
Map<String, String> headers = new HashMap<String, String>();
|
| 122 |
headers.put("Project-Code", "SMART_DUKAAN");
|
127 |
headers.put("Project-Code", "SMART_DUKAAN");
|
| 123 |
headers.put("X-Auth-Token", jwt);
|
128 |
headers.put("X-Auth-Token", jwt);
|
| 124 |
String url = "https://staging-india-api-gateway.thriwe.com/validate-user";
|
129 |
String url = "https://staging-india-api-gateway.thriwe.com/validate-user";
|
| 125 |
HttpResponse response = restClient.getResponse(url, params, headers);
|
130 |
HttpResponse response = restClient.getResponse(url, params, headers);
|
| 126 |
LOGGER.info("response {}", response);
|
131 |
LOGGER.info("response {}", response);
|
| 127 |
|
132 |
|
| 128 |
|
133 |
|
| 129 |
Header[] authToken = response.getHeaders("Authorization");
|
134 |
Header[] authToken = response.getHeaders("Authorization");
|
| 130 |
LOGGER.info("authToken {}", Arrays.asList(authToken).get(0).getValue());
|
135 |
LOGGER.info("authToken {}", Arrays.asList(authToken).get(0).getValue());
|
| 131 |
|
136 |
|
| 132 |
ThriweMembers thriweMember = thriweMemberRepository.selectByUsername(userName, campaign.getStartDate(), campaign.getEndDate());
|
137 |
ThriweMembers thriweMember = thriweMemberRepository.selectByUsername(userName, campaign.getStartDate(), campaign.getEndDate());
|
| 133 |
LOGGER.info("thriweMembers {}", thriweMember);
|
138 |
LOGGER.info("thriweMembers {}", thriweMember);
|
| 134 |
|
139 |
|
| 135 |
if (thriweMember != null) {
|
140 |
if (thriweMember != null) {
|
| 136 |
|
141 |
|
| 137 |
thriweMember.setAuthToken(Arrays.asList(authToken).get(0).getValue());
|
142 |
thriweMember.setAuthToken(Arrays.asList(authToken).get(0).getValue());
|
| 138 |
|
143 |
|
| 139 |
try {
|
144 |
try {
|
| 140 |
String responseString = restClient.toString(response.getEntity().getContent());
|
145 |
String responseString = restClient.toString(response.getEntity().getContent());
|
| 141 |
LOGGER.info("responseString {}", new JSONObject(responseString).get("membershipId"));
|
146 |
LOGGER.info("responseString {}", new JSONObject(responseString).get("membershipId"));
|
| 142 |
JSONObject responseJson = new JSONObject(responseString);
|
147 |
JSONObject responseJson = new JSONObject(responseString);
|
| 143 |
String membershipId = responseJson.getString("membershipId");
|
148 |
String membershipId = responseJson.getString("membershipId");
|
| 144 |
thriweMember.setMembershipId(membershipId);
|
149 |
thriweMember.setMembershipId(membershipId);
|
| 145 |
memberShipId = thriweMember.getMembershipId();
|
150 |
memberShipId = thriweMember.getMembershipId();
|
| 146 |
} catch (Exception e) {
|
151 |
} catch (Exception e) {
|
| 147 |
// TODO: handle exception
|
152 |
// TODO: handle exception
|
| 148 |
}
|
153 |
}
|
| 149 |
|
154 |
|
| 150 |
|
155 |
|
| 151 |
}
|
156 |
}
|
| 152 |
}
|
157 |
}
|
| 153 |
|
158 |
|
| 154 |
return responseSender.ok(memberShipId);
|
159 |
return responseSender.ok(memberShipId);
|
| 155 |
}
|
160 |
}
|
| 156 |
|
161 |
|
| 157 |
@RequestMapping(value = "/thriwe/benefit-configs", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
162 |
@RequestMapping(value = "/thriwe/benefit-configs", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 158 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
163 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 159 |
@ApiOperation(value = "")
|
164 |
@ApiOperation(value = "")
|
| 160 |
public ResponseEntity<?> benefitConfigs(HttpServletRequest request, @RequestParam String membershipId) throws HttpHostConnectException, ProfitMandiBusinessException {
|
165 |
public ResponseEntity<?> benefitConfigs(HttpServletRequest request, @RequestParam String membershipId) throws HttpHostConnectException, ProfitMandiBusinessException {
|
| 161 |
|
166 |
|
| 162 |
|
167 |
|
| 163 |
ThriweMembers thriweMember = thriweMemberRepository.selectByMembershipId(membershipId);
|
168 |
ThriweMembers thriweMember = thriweMemberRepository.selectByMembershipId(membershipId);
|
| 164 |
|
169 |
|
| 165 |
Map<String, String> params = new HashMap<String, String>();
|
170 |
Map<String, String> params = new HashMap<String, String>();
|
| 166 |
Map<String, String> headers = new HashMap<String, String>();
|
171 |
Map<String, String> headers = new HashMap<String, String>();
|
| 167 |
|
172 |
|
| 168 |
headers.put("Authorization", thriweMember.getAuthToken());
|
173 |
headers.put("Authorization", thriweMember.getAuthToken());
|
| 169 |
headers.put("Project-Code", "SMART_DUKAAN");
|
174 |
headers.put("Project-Code", "SMART_DUKAAN");
|
| 170 |
|
175 |
|
| 171 |
String url = "https://staging-india-api-gateway.thriwe.com/client/benefit-configs";
|
176 |
String url = "https://staging-india-api-gateway.thriwe.com/client/benefit-configs";
|
| 172 |
|
177 |
|
| 173 |
String response = restClient.get(url, params, headers);
|
178 |
String response = restClient.get(url, params, headers);
|
| 174 |
LOGGER.info("response {}", response);
|
179 |
LOGGER.info("response {}", response);
|
| 175 |
|
180 |
|
| 176 |
BenefitConfigurationResponse benefitConfigurationResponse = gson.fromJson(response, BenefitConfigurationResponse.class);
|
181 |
BenefitConfigurationResponse benefitConfigurationResponse = gson.fromJson(response, BenefitConfigurationResponse.class);
|
| 177 |
|
182 |
|
| 178 |
LOGGER.info("benefitConfigurationResponse {}", benefitConfigurationResponse);
|
183 |
LOGGER.info("benefitConfigurationResponse {}", benefitConfigurationResponse);
|
| 179 |
|
184 |
|
| 180 |
return responseSender.ok(benefitConfigurationResponse);
|
185 |
return responseSender.ok(benefitConfigurationResponse);
|
| 181 |
}
|
186 |
}
|
| 182 |
|
187 |
|
| 183 |
@RequestMapping(value = "/thriwe/benefits", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
188 |
@RequestMapping(value = "/thriwe/benefits", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 184 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
189 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 185 |
@ApiOperation(value = "")
|
190 |
@ApiOperation(value = "")
|
| 186 |
public ResponseEntity<?> benefits(HttpServletRequest request, @RequestParam String membershipId, @RequestParam String configId) throws HttpHostConnectException, ProfitMandiBusinessException {
|
191 |
public ResponseEntity<?> benefits(HttpServletRequest request, @RequestParam String membershipId, @RequestParam String configId) throws HttpHostConnectException, ProfitMandiBusinessException {
|
| 187 |
|
192 |
|
| 188 |
ThriweMembers thriweMember = thriweMemberRepository.selectByMembershipId(membershipId);
|
193 |
ThriweMembers thriweMember = thriweMemberRepository.selectByMembershipId(membershipId);
|
| 189 |
|
194 |
|
| 190 |
Map<String, String> params = new HashMap<String, String>();
|
195 |
Map<String, String> params = new HashMap<String, String>();
|
| 191 |
|
196 |
|
| 192 |
params.put("configId", configId);
|
197 |
params.put("configId", configId);
|
| 193 |
|
198 |
|
| 194 |
Map<String, String> headers = new HashMap<String, String>();
|
199 |
Map<String, String> headers = new HashMap<String, String>();
|
| 195 |
|
200 |
|
| 196 |
headers.put("Authorization", thriweMember.getAuthToken());
|
201 |
headers.put("Authorization", thriweMember.getAuthToken());
|
| 197 |
headers.put("Project-Code", "SMART_DUKAAN");
|
202 |
headers.put("Project-Code", "SMART_DUKAAN");
|
| 198 |
|
203 |
|
| 199 |
String url = "https://staging-india-api-gateway.thriwe.com/client/benefit-items";
|
204 |
String url = "https://staging-india-api-gateway.thriwe.com/client/benefit-items";
|
| 200 |
String response = restClient.get(url, params, headers);
|
205 |
String response = restClient.get(url, params, headers);
|
| 201 |
|
206 |
|
| 202 |
BenefitResponse benefitResponse = gson.fromJson(response, BenefitResponse.class);
|
207 |
BenefitResponse benefitResponse = gson.fromJson(response, BenefitResponse.class);
|
| 203 |
|
208 |
|
| 204 |
LOGGER.info("benefitResponse {}", benefitResponse);
|
209 |
LOGGER.info("benefitResponse {}", benefitResponse);
|
| 205 |
|
210 |
|
| 206 |
return responseSender.ok(benefitResponse);
|
211 |
return responseSender.ok(benefitResponse);
|
| 207 |
|
212 |
|
| 208 |
}
|
213 |
}
|
| 209 |
|
214 |
|
| 210 |
|
215 |
|
| 211 |
@RequestMapping(value = "/thriwe/createBooking", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
216 |
@RequestMapping(value = "/thriwe/createBooking", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 212 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
217 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 213 |
@ApiOperation(value = "")
|
218 |
@ApiOperation(value = "")
|
| 214 |
public ResponseEntity<?> createBooking(HttpServletRequest request, @RequestBody BenefitGroup benefitGroup) throws HttpHostConnectException, ProfitMandiBusinessException {
|
219 |
public ResponseEntity<?> createBooking(HttpServletRequest request, @RequestBody BenefitGroup benefitGroup) throws HttpHostConnectException, ProfitMandiBusinessException {
|
| 215 |
|
220 |
|
| 216 |
ThriweMembers thriweMember = thriweMemberRepository.selectByMembershipId(benefitGroup.getMembershipId());
|
221 |
ThriweMembers thriweMember = thriweMemberRepository.selectByMembershipId(benefitGroup.getMembershipId());
|
| 217 |
|
222 |
|
| 218 |
Map<String, String> headers = new HashMap<String, String>();
|
223 |
Map<String, String> headers = new HashMap<String, String>();
|
| 219 |
|
224 |
|
| 220 |
headers.put("token", token);
|
225 |
headers.put("token", token);
|
| 221 |
headers.put("Project-Code", "SMART_DUKAAN");
|
226 |
headers.put("Project-Code", "SMART_DUKAAN");
|
| 222 |
|
227 |
|
| 223 |
String url = "https://staging-india-api-gateway.thriwe.com/create-booking";
|
228 |
String url = "https://staging-india-api-gateway.thriwe.com/create-booking";
|
| 224 |
String response = restClient.post(url, benefitGroup.toString(), headers);
|
229 |
String response = restClient.post(url, benefitGroup.toString(), headers);
|
| 225 |
|
230 |
|
| 226 |
LOGGER.info("response {}", response);
|
231 |
LOGGER.info("response {}", response);
|
| 227 |
return responseSender.ok(true);
|
232 |
return responseSender.ok(true);
|
| 228 |
}
|
233 |
}
|
| 229 |
|
234 |
|
| 230 |
|
235 |
*/
|
| 231 |
}
|
236 |
}
|