package com.bankaudit.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;

/**
 * {@link TwilioSmsService} provides the method to send the message to
 * particular mobile or phone number
 * 
 * @author amit.patel
 * @version 1.0
 */
@Service("twilioSmsService")
public class TwilioSmsService {

	@Autowired
	TwilioRestClient twilioRestClient;
	
	@Autowired 
	Environment environment;
	
	@Autowired
	UserService userService;
	
	public void sendSms(String to,Long userId) throws TwilioRestException{/*
		   String otp=RandomStringUtils.randomNumeric(4);
		   List<NameValuePair> params = new ArrayList<NameValuePair>();
		   params.add(new BasicNameValuePair("To", "+91"+to));
		   params.add(new BasicNameValuePair("From", environment.getRequiredProperty("twilio.phone.number")));
		   params.add(new BasicNameValuePair("Body", "HealersArk verification - OTP : "+otp));
		   MessageFactory messageFactory = twilioRestClient.getAccount().getMessageFactory();
		   messageFactory.create(params);
		   OtpVerification otpVerification=new OtpVerification();
		   otpVerification.setUserId(userId);
		   otpVerification.setOtp(passwordEncoder.encode(otp));
 	       userService.generateOtp(otpVerification); 	   
	*/}

}
