/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.arrebol.taxiservicios.beans;

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.logging.log4j.core.util.Patterns;

/**
 *
 * @author Oscar
 */
public class SendMSN {

    public static final String ACCOUNT_SID = "AC3f21ebff784532f98229abfd8bc0e227";
    public static final String AUTH_TOKEN = "08e8c76db40ea5cc9ed772671909f292";
    private String text = "";
    private String phone = "";

    public SendMSN(String aMessage, String aPhone) {
        text = aMessage;
        phone = aPhone;
    }

    public void sendMessage() {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        Message message = Message.creator(
                new com.twilio.type.PhoneNumber(phone),
                new com.twilio.type.PhoneNumber("+18504076816"),
                text)
                .create();

        System.out.println(message.getSid());
    }

    public static boolean validarMovil(String movil) {
        Pattern p = Pattern.compile("^\\d{10}$");
        Matcher m = p.matcher(movil);
        return (m.matches());
    }
    
    public static String getNumberPhoneFormat(String movil)
    {
        return "+52" + movil.trim();
    }

}
