public void TestGetSMSMessages() { List <TMSSMSMessage> messages = api.GetSMSMessages(); Assert.IsNotNull(messages); Assert.IsTrue(messages.Count > 0); TMSSMSMessage message = messages.First <TMSSMSMessage>(); Assert.IsNotNull(message); Assert.IsNotNull(message._links); Assert.IsNotNull(message._links["self"]); }
/** * Send an SMS message */ public TMSSMSMessage SendSMSMessage(TMSSMSMessage messageIn) { TMSResource services = GetServices(); var request = new RestRequest(); request.Resource = services._links["sms_messages"]; request.Method = Method.POST; request.JsonSerializer = new TMSJsonSerializer(); // anytime you want to send a POST you need to make sure // you tell the request object you want to send JSON // so that it can serialize correctly request.RequestFormat = DataFormat.Json; request.AddBody(messageIn); return(Execute <TMSSMSMessage>(request)); }
public void TestGetSMSRecipients() { List <TMSSMSMessage> messages = api.GetSMSMessages(); Assert.IsNotNull(messages); Assert.IsTrue(messages.Count > 0); // Look at the last message in the list in case // you are running all of the tests and you just // inserted one, the recipient list may not be built TMSSMSMessage message = messages.Last <TMSSMSMessage>(); Assert.IsNotNull(message); Assert.IsNotNull(message._links); Assert.IsNotNull(message._links["self"]); // recipients aren't available in the list view Assert.IsNull(message.recipients); List <SMSRecipient> recipients = api.Get <List <SMSRecipient> >(message._links["recipients"]); // recipients should now be there Assert.IsNotNull(recipients); Assert.IsTrue(recipients.Count > 0); // And you should be able to access the data in the recipient Assert.IsNotNull(recipients.First().phone); Assert.IsTrue(recipients.First().phone.Length > 1); Assert.IsNotNull(recipients.First().created_at); Assert.IsTrue(recipients.First().created_at > new DateTime(0)); Assert.IsNotNull(recipients.First().completed_at); Assert.IsTrue(recipients.First().completed_at > new DateTime(0)); Assert.IsNotNull(recipients.First().status); Assert.IsTrue(recipients.First().status.Length > 1); }
public void TestSendSMS() { TMSSMSMessage messageIn = new TMSSMSMessage(); messageIn.body = TestBody; messageIn.addRecipient(TestPhone); // Uncomment the below to actually send an email TMSSMSMessage messageOut = api.SendSMSMessage(messageIn); // We should have a valid self relation Assert.IsNotNull(messageOut._links["self"]); // Are all of the elements the same as what we passed in? Assert.AreEqual(messageIn.body, messageOut.body); // Recipient counts and the actual recipients List <SMSRecipient> recipients = api.Get <List <SMSRecipient> >(messageOut._links["recipients"]); Assert.AreEqual(messageIn.recipients.First().phone, recipients.First().phone); Assert.AreEqual(1, recipients.Count); }
public void TestGetSMSDetails() { List <TMSSMSMessage> messages = api.GetSMSMessages(); Assert.IsNotNull(messages); Assert.IsTrue(messages.Count > 0); // Look at the last message in the list in case // you are running all of the tests and you just // inserted one, the recipient list may not be built TMSSMSMessage message = messages.Last <TMSSMSMessage>(); Assert.IsNotNull(message); Assert.IsNotNull(message._links); Assert.IsNotNull(message._links["self"]); // body is available in the list view Assert.IsNotNull(message.body); message = api.Get <TMSSMSMessage>(message._links["self"]); // body is here too! Assert.IsNotNull(message.body); // recipients should not appear yet Assert.IsNull(message.recipients); // recipient counts are available though Assert.IsNotNull(message.recipient_counts); Assert.IsNotNull(message.recipient_counts["total"]); Assert.IsTrue(Convert.ToDecimal(message.recipient_counts["total"]) > 0); // created_at should be a positive date Assert.IsNotNull(message.created_at); Assert.IsTrue(message.created_at > new DateTime(0)); }