Subversion Repositories SmartDukaan

Rev

Rev 30859 | Rev 30990 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30859 Rev 30989
Line 3... Line 3...
3
import com.google.gson.Gson;
3
import com.google.gson.Gson;
4
import com.spice.profitmandi.common.enumuration.MessageType;
4
import com.spice.profitmandi.common.enumuration.MessageType;
5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
6
import com.spice.profitmandi.common.model.ProfitMandiConstants;
6
import com.spice.profitmandi.common.model.ProfitMandiConstants;
7
import com.spice.profitmandi.common.model.SendNotificationModel;
7
import com.spice.profitmandi.common.model.SendNotificationModel;
-
 
8
import com.spice.profitmandi.common.web.client.RestClient;
8
import com.spice.profitmandi.dao.entity.auth.AuthUser;
9
import com.spice.profitmandi.dao.entity.auth.AuthUser;
9
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
10
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
10
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
11
import com.spice.profitmandi.dao.entity.dtr.PushNotifications;
11
import com.spice.profitmandi.dao.entity.dtr.User;
12
import com.spice.profitmandi.dao.entity.dtr.User;
12
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
13
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
Line 15... Line 16...
15
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
16
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
16
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
17
import com.spice.profitmandi.dao.repository.catalog.DeviceRepository;
17
import com.spice.profitmandi.dao.repository.cs.CsService;
18
import com.spice.profitmandi.dao.repository.cs.CsService;
18
import com.spice.profitmandi.dao.repository.dtr.*;
19
import com.spice.profitmandi.dao.repository.dtr.*;
19
import com.spice.profitmandi.service.user.RetailerService;
20
import com.spice.profitmandi.service.user.RetailerService;
-
 
21
 
-
 
22
import org.apache.http.conn.HttpHostConnectException;
20
import org.apache.logging.log4j.LogManager;
23
import org.apache.logging.log4j.LogManager;
21
import org.apache.logging.log4j.Logger;
24
import org.apache.logging.log4j.Logger;
22
import org.springframework.beans.factory.annotation.Autowired;
25
import org.springframework.beans.factory.annotation.Autowired;
23
import org.springframework.stereotype.Component;
26
import org.springframework.stereotype.Component;
24
 
27
 
Line 57... Line 60...
57
	PushNotificationRepository pushNotificationRepository;
60
	PushNotificationRepository pushNotificationRepository;
58
 
61
 
59
	@Autowired
62
	@Autowired
60
	private Gson gson;
63
	private Gson gson;
61
 
64
 
-
 
65
	@Autowired
-
 
66
	private RestClient restClient;
-
 
67
 
62
	private static final Logger LOGGER = LogManager.getLogger(NotificationService.class);
68
	private static final Logger LOGGER = LogManager.getLogger(NotificationService.class);
63
 
69
 
64
	@Override
70
	@Override
65
	public void sendNotification(SendNotificationModel sendNotificationModel) throws ProfitMandiBusinessException {
71
	public void sendNotification(SendNotificationModel sendNotificationModel) throws ProfitMandiBusinessException {
66
 
72
 
Line 177... Line 183...
177
		sendNotificationModel.setMessageType(messageType);
183
		sendNotificationModel.setMessageType(messageType);
178
		sendNotificationModel.setUrl(url);
184
		sendNotificationModel.setUrl(url);
179
		this.sendNotification(sendNotificationModel);
185
		this.sendNotification(sendNotificationModel);
180
	}
186
	}
181
 
187
 
-
 
188
	@Override
-
 
189
	public void sendWhatsappMessage(String message, String title, String mobile)
-
 
190
			throws HttpHostConnectException, ProfitMandiBusinessException {
-
 
191
		Map<String, String> requestheaders = new HashMap<>();
-
 
192
		requestheaders.put("Content-Type", "application/x-www-form-urlencoded");
-
 
193
		Map<String, String> requestParams = new HashMap<>();
-
 
194
		requestParams.put("userid", String.valueOf(2000215976));
-
 
195
		requestParams.put("password", "MFRd!BBL");
-
 
196
		requestParams.put("send_to", "919816068341");
-
 
197
		requestParams.put("auth_scheme", "plain");
-
 
198
		requestParams.put("v", "1.1");
-
 
199
 
-
 
200
		requestParams.put("format", "json");
-
 
201
 
-
 
202
		requestParams.put("msg_type", "HSM");
-
 
203
 
-
 
204
		requestParams.put("method", "SENDMESSAGE");
-
 
205
 
-
 
206
		requestParams.put("msg", message);
-
 
207
 
-
 
208
		requestParams.put("isTemplate", "true");
-
 
209
		requestParams.put("header", title);
-
 
210
		String response = restClient.post("https://media.smsgupshup.com/GatewayAPI/rest", requestParams,
-
 
211
				requestheaders);
-
 
212
		LOGGER.info("response" + response);
-
 
213
	}
-
 
214
 
182
}
215
}