| Line 16... |
Line 16... |
| 16 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
16 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 17 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
17 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 18 |
import com.spice.profitmandi.dao.repository.whatsapp.WhatsappMessageRepository;
|
18 |
import com.spice.profitmandi.dao.repository.whatsapp.WhatsappMessageRepository;
|
| 19 |
import com.spice.profitmandi.service.user.RetailerService;
|
19 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 20 |
import com.spice.profitmandi.service.whatsapp.WhatsappMessageService;
|
20 |
import com.spice.profitmandi.service.whatsapp.WhatsappMessageService;
|
| - |
|
21 |
import com.spice.profitmandi.service.whatsapp.WhatsappMessageType;
|
| 21 |
import org.apache.logging.log4j.LogManager;
|
22 |
import org.apache.logging.log4j.LogManager;
|
| 22 |
import org.apache.logging.log4j.Logger;
|
23 |
import org.apache.logging.log4j.Logger;
|
| 23 |
import org.json.JSONObject;
|
24 |
import org.json.JSONObject;
|
| 24 |
import org.springframework.beans.factory.annotation.Autowired;
|
25 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 25 |
import org.springframework.beans.factory.annotation.Value;
|
26 |
import org.springframework.beans.factory.annotation.Value;
|
| Line 186... |
Line 187... |
| 186 |
}
|
187 |
}
|
| 187 |
|
188 |
|
| 188 |
@Override
|
189 |
@Override
|
| 189 |
public void sendWhatsappMessage(String message, String title, String mobile)
|
190 |
public void sendWhatsappMessage(String message, String title, String mobile)
|
| 190 |
throws Exception {
|
191 |
throws Exception {
|
| 191 |
this.sendWhatsappMessage(message, title, mobile, null, null);
|
192 |
this.sendWhatsappMessage(WhatsappMessageType.TEXT, message, title, mobile, null, null);
|
| 192 |
}
|
193 |
}
|
| 193 |
|
194 |
|
| 194 |
@Override
|
195 |
@Override
|
| 195 |
public void sendWhatsappMediaMessage(String message, String mobile, String mediaUrl, String fileName)
|
196 |
public void sendWhatsappMediaMessage(String message, String mobile, String mediaUrl, String fileName, WhatsappMessageType whatsappMessageType)
|
| 196 |
throws Exception {
|
197 |
throws Exception {
|
| 197 |
this.sendWhatsappMessage(message, null, mobile, mediaUrl, fileName);
|
198 |
this.sendWhatsappMessage(whatsappMessageType, message, null, mobile, mediaUrl, fileName);
|
| 198 |
|
199 |
|
| 199 |
}
|
200 |
}
|
| 200 |
|
201 |
|
| 201 |
@Override
|
202 |
@Override
|
| 202 |
public void optIn(String phoneNumber) throws Exception {
|
203 |
public void optIn(String phoneNumber) throws Exception {
|
| Line 215... |
Line 216... |
| 215 |
requestParams.put("channel", "WHATSAPP");
|
216 |
requestParams.put("channel", "WHATSAPP");
|
| 216 |
String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams, requestheaders);
|
217 |
String response = restClient.get("https://media.smsgupshup.com/GatewayAPI/rest", requestParams, requestheaders);
|
| 217 |
LOGGER.info("response" + response);
|
218 |
LOGGER.info("response" + response);
|
| 218 |
}
|
219 |
}
|
| 219 |
|
220 |
|
| 220 |
private void sendWhatsappMessage(String message, String title, String mobile, String mediaUrl, String fileName)
|
221 |
private void sendWhatsappMessage(WhatsappMessageType whatsappMessageType, String message, String title, String mobile, String mediaUrl, String fileName)
|
| 221 |
throws Exception {
|
222 |
throws Exception {
|
| 222 |
String sendTo = null;
|
223 |
String sendTo = null;
|
| 223 |
if (mobile.length() != 10) {
|
224 |
if (mobile.length() != 10) {
|
| 224 |
return;
|
225 |
return;
|
| 225 |
} else {
|
226 |
} else {
|
| Line 242... |
Line 243... |
| 242 |
optin.setMobile(mobile);
|
243 |
optin.setMobile(mobile);
|
| 243 |
optinRepository.persist(optin);
|
244 |
optinRepository.persist(optin);
|
| 244 |
}
|
245 |
}
|
| 245 |
if (mediaUrl == null) {
|
246 |
if (mediaUrl == null) {
|
| 246 |
requestParams.put("method", "SENDMESSAGE");
|
247 |
requestParams.put("method", "SENDMESSAGE");
|
| 247 |
requestParams.put("msg_type", "TEXT");
|
248 |
requestParams.put("msg_type", whatsappMessageType.name());
|
| 248 |
requestParams.put("msg", message);
|
249 |
requestParams.put("msg", message);
|
| 249 |
requestParams.put("isTemplate", "true");
|
250 |
requestParams.put("isTemplate", "true");
|
| 250 |
requestParams.put("header", title);
|
251 |
requestParams.put("header", title);
|
| 251 |
} else if (mediaUrl != null) {
|
252 |
} else if (mediaUrl != null) {
|
| 252 |
requestParams.put("method", "SENDMEDIAMESSAGE");
|
253 |
requestParams.put("method", "SENDMEDIAMESSAGE");
|
| 253 |
requestParams.put("msg_type", "DOCUMENT");
|
254 |
requestParams.put("msg_type", whatsappMessageType.name());
|
| 254 |
requestParams.put("caption", message);
|
255 |
requestParams.put("caption", message);
|
| 255 |
//requestParams.put("msg", message);
|
256 |
//requestParams.put("msg", message);
|
| 256 |
requestParams.put("media_url", mediaUrl);
|
257 |
requestParams.put("media_url", mediaUrl);
|
| 257 |
requestParams.put("filename", fileName);
|
258 |
requestParams.put("filename", fileName);
|
| 258 |
}
|
259 |
}
|