twilio.sugar.Model.PhoneAutomation.SendSMSMessage C# (CSharp) Method

SendSMSMessage() public method

public SendSMSMessage ( String from, String to, String body, String statusCallback = "" ) : twilio.sugar.Model.SMSMessage
from String
to String
body String
statusCallback String
return twilio.sugar.Model.SMSMessage
        public SMSMessage SendSMSMessage(String from, String to, String body, String statusCallback = "")
        {
            _parameters.Clear();
            _parameters.Add("From", from);
            _parameters.Add("To", to);
            _parameters.Add("Body", body);
            if (!String.IsNullOrEmpty(statusCallback))
            {
                _parameters.Add("StatusCallback", statusCallback);
            }

            _twilioResponse = _account.request(String.Format("Accounts/{0}/SMS/Messages.json", _account.id), "POST", _parameters);
            dynamic data = ParseResponseData(_twilioResponse);

            var sms = new SMSMessage
            {
                account_sid = data.account_sid,
                api_version = data.api_version,
                body = data.body,
                date_created = !String.IsNullOrEmpty(data.date_created) ? Convert.ToDateTime(data.date_created) : null,
                date_sent = !String.IsNullOrEmpty(data.date_sent) ? Convert.ToDateTime(data.date_sent) : null,
                date_updated = !String.IsNullOrEmpty(data.date_updated) ? Convert.ToDateTime(data.date_updated) : null,
                direction = data.direction,
                from = data.from,
                price = !String.IsNullOrEmpty(data.price) ? Convert.ToDecimal(data.price) : null,
                sid = data.sid,
                status = data.status,
                to = data.to,
                uri = data.uri
            };

            return sms;
        }
    }

Usage Example

        public void SendSMSMessageShouldReturnSMSMessageResource()
        {
            var account = new TwilioAccountMock();
            var phoneAutomation = new PhoneAutomation(account);
            var message = phoneAutomation.SendSMSMessage("Test_From", "Test_To", "Test_body");

            Assert.IsNotNull(message);
        }