Skip to content

Commit

Permalink
Issue #9 chores:Removing + from the phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
shriharshs committed Nov 10, 2017
1 parent bfe2d32 commit 2da5c62
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.jboss.logging.Logger;
import org.sunbird.keycloak.KeycloakSmsAuthenticatorUtil;
import org.sunbird.sms.SMSConfigurationUtil;
import org.sunbird.sms.SmsConfigurationConstants;
import org.sunbird.sms.provider.ISmsProvider;
Expand Down Expand Up @@ -82,9 +81,11 @@ private boolean sendSms(String mobileNumber, String smsText) {
&& !StringUtils.isNullOrEmpty(mobileNumber) && !StringUtils.isNullOrEmpty(authKey) && !StringUtils.isNullOrEmpty(country)
&& !StringUtils.isNullOrEmpty(smsText)) {

mobileNumber = removePlusFromMobileNumber(mobileNumber);

if (httpMethod.equals(HttpMethod.GET)) {
logger.debug("Inside GET");
path = getCompletePath(BASE_URL + GET_URL, sender, smsRoute, KeycloakSmsAuthenticatorUtil.setDefaultCountryCodeIfZero(mobileNumber), authKey, country, URLEncoder.encode(smsText, "UTF-8"));
path = getCompletePath(BASE_URL + GET_URL, sender, smsRoute, mobileNumber, authKey, country, URLEncoder.encode(smsText, "UTF-8"));

logger.debug("Msg91SmsProvider -Executing request - " + path);

Expand Down Expand Up @@ -162,6 +163,13 @@ private boolean sendSms(String mobileNumber, String smsText) {
return false;
}

private String removePlusFromMobileNumber(String mobileNumber) {
if (mobileNumber.startsWith("+")){
return mobileNumber.substring(1);
}
return mobileNumber;
}

private String getCompletePath(String gateWayUrl, String sender, String smsRoute, String mobileNumber, String authKey, String country, String smsText) {
String completeUrl = gateWayUrl
+ "sender=" + sender
Expand Down

0 comments on commit 2da5c62

Please sign in to comment.