public void GetStatus() { Twizo twizo = new Twizo(this.apiKey, this.apiHost); var backup = twizo.GetBackupCode(this.identifier); LogResponse(backup); }
public void ValidationExceptionTest() { //Arrange Twizo twizo = new Twizo(TwizoTests.apiKey, TwizoTests.apiHost); var verification = twizo.CreateVerification("601151174973"); verification.tokenLength = 11; verification.tag = "This tag contains more than 30 characters."; verification.validity = 1; //Act try { verification.Send(); } catch (ValidationException e) { var errors = e.errorFields; List <string> errorNames = errors.Select(x => x.name).ToList(); //Assert Assert.IsTrue(e.Message.StartsWith("Validation error for field")); Assert.AreEqual(errors.Count, 3); Assert.IsTrue(errorNames.Contains("tag") && errorNames.Contains("tokenLength") && errorNames.Contains("validity")); } }
public static void Main(string[] args) { CloudRail.AppKey = "[Your CloudRail Key]"; List <ISMS> services = new List <ISMS>(); Nexmo nexmo = new Nexmo(null, "[Nexmo API Key]", "[Nexmo API Secret]"); services.Add(nexmo); Twilio twilio = new Twilio(null, "[Twilio Account SID]", "[Twilio Auth Token]"); services.Add(twilio); Twizo twizo = new Twizo(null, "[Twizo Key]"); services.Add(twizo); foreach (ISMS service in services) { try { service.SendSMS("[Sending Number]", "[Receiving Number]", "Hello from " + service); } catch (Exception e) { Console.WriteLine(e); } } }
public void Update() { Twizo twizo = new Twizo(this.apiKey, this.apiHost); var backup = twizo.CreateBackupCode(this.identifier); backup.Update(); LogResponse(backup); }
public void Verify(string token) { Twizo twizo = new Twizo(this.apiKey, this.apiHost); var backup = twizo.CreateBackupCode(this.identifier); backup.Verify(token); LogResponse(backup); }
public Boolean Verify(string token) { Twizo twizo = new Twizo(this.apiKey, this.apiHost); var verification = twizo.GetTokenResult(token, this.messageId); LogResponse(verification); return(verification.statusCode == (int)TwizoAPI.Entity.VerificationStatusCode.SUCCESS); }
public void GetVerificationTestNull() { //Arrange string messageId = null; Twizo twizo = new Twizo(apiKey, apiHost); //Act twizo.GetVerification(messageId); }
public void CreateBalanceTest() { //Arrange Twizo twizo = new Twizo(apiKey, apiHost); //Act var balance = twizo.CreateBalance(); //Assert Assert.IsNotNull(balance); }
public void GetNumberLookupResultsTest() { //Arrange Twizo twizo = new Twizo(apiKey, apiHost); //Act var results = twizo.GetNumberLookupResults(); //Assert Assert.IsNotNull(results); }
public void CreateBackupCodeTest() { //Arrange string identifier = "myIdentifier"; Twizo twizo = new Twizo(apiKey, apiHost); //Act var backup = twizo.CreateBackupCode(identifier); //Assert Assert.AreEqual(backup.identifier, identifier); }
public void CreateVerificationTestNull() { //Arrange string recipient = null; Twizo twizo = new Twizo(apiKey, apiHost); //Act var verification = twizo.CreateVerification(recipient); //Assert Assert.AreEqual(verification.recipient, recipient); }
public void CreateNumberLookupTestNull() { //Arrange string[] numbers = null; Twizo twizo = new Twizo(apiKey, apiHost); //Act var lookup = twizo.CreateNumberLookup(numbers); //Assert Assert.AreEqual(lookup.numbers, numbers); }
public void Send() { //Create entity Twizo twizo = new Twizo(this.apiKey, this.apiHost); var sms = twizo.CreateSms(this.recipients, this.body, this.sender); sms.resultType = 2; //Set variables if (this.senderTon >= 0) { sms.senderTon = this.senderTon; } if (this.senderNpi >= 0) { sms.senderNpi = this.senderNpi; } if (this.pid >= 0) { sms.pid = this.pid; } //sms.scheduledDelivery = this.scheduledDelivery.ToString("yyyy-MM-ddTHH:mm:ssZ"); if (this.tag != "") { sms.tag = this.tag; } sms.validity = this.validity; if (this.resultType >= 0) { sms.resultType = this.resultType; } if (this.callbackUrl != "") { sms.callbackUrl = this.callbackUrl; } if (this.dcs >= 0) { sms.dcs = this.dcs; } if (this.udh != "") { sms.udh = this.udh; } //Send sms.Send(); //Log LogResponse(sms); this.messageId = sms.messageId; }
public void CreateVerificationCallTest() { //Arrange string recipient = "601151174973"; Twizo twizo = new Twizo(apiKey, apiHost); //Act var verification = twizo.CreateVerificationCall(recipient); //Assert Assert.AreEqual(verification.recipient, recipient); Assert.AreEqual(verification.type, Verification.TYPE_CALL); }
public void CreateWidgetSessionTestNull() { //Arrange string[] allowedTypes = new[] { WidgetSession.TYPE_SMS, WidgetSession.TYPE_BACKUP_CODE }; string recipient = null; Twizo twizo = new Twizo(apiKey, apiHost); //Act var session = twizo.CreateWidgetSession(allowedTypes, recipient); //Assert Assert.AreEqual(session.allowedTypes, allowedTypes); Assert.AreEqual(session.recipient, recipient); }
private void Balance() { Twizo twizo = new Twizo(apiKey, apiHost); var balance = twizo.CreateBalance(); balance.LoadData(); Console.WriteLine(); Console.WriteLine("Wallet name: " + balance.wallet); Console.WriteLine("Currency code: " + balance.currencyCode); Console.WriteLine("Balance: " + balance.credit.ToString()); Console.WriteLine("Free verifications: " + balance.freeVerification.ToString()); Console.WriteLine(); RunMenu(); }
public void GetNumberLookupTest() { //Arrange string recipient = "601151174973"; Twizo twizo = new Twizo(apiKey, apiHost); //Act var lookup = twizo.CreateNumberLookup(recipient); lookup.Send(); string messageId = lookup.messageId; var newLookup = twizo.GetNumberLookup(messageId); //Assert Assert.AreEqual(lookup.messageId, newLookup.messageId); }
public void CreateSmsTestNull() { //Arrange string recipient = null; string body = "This is a unit test"; string sender = "Unit tester"; Twizo twizo = new Twizo(apiKey, apiHost); //Act var sms = twizo.CreateSms(recipient, body, sender); //Assert Assert.AreEqual(sms.recipient, recipient); Assert.AreEqual(sms.body, body); Assert.AreEqual(sms.sender, sender); }
public void LoadDataTest() { //Arrange Twizo twizo = new Twizo(TwizoTests.apiKey, TwizoTests.apiHost); //Act var balance = twizo.CreateBalance(); balance.LoadData(); //Assert Assert.IsNotNull(balance.credit); Assert.IsNotNull(balance.freeVerification); Assert.IsNotNull(balance.currencyCode); Assert.IsNotNull(balance.wallet); }
public void Send() { //Create entity Twizo twizo = new Twizo(this.apiKey, this.apiHost); TwizoAPI.Entity.Verification verification; if (call) { verification = twizo.CreateVerificationCall(this.recipient); } else { verification = twizo.CreateVerification(this.recipient); } //Set variables verification.type = this.type; verification.tokenLength = this.tokenLength; verification.tokenType = this.tokenType; if (this.tag != "") { verification.tag = this.tag; } if (this.sessionId != "") { verification.sessionId = this.sessionId; } verification.validity = this.validity; verification.bodyTemplate = this.bodyTemplate; verification.sender = this.sender; if (this.senderTon >= 0) { verification.senderTon = this.senderTon; } if (this.senderTon >= 0) { verification.senderNpi = this.senderNpi; } verification.dcs = this.dcs; //Send verification.Send(); //Log LogResponse(verification); this.messageId = verification.messageId; }
public void GetVerificationTest() { //Arrange string recipient = "601151174973"; Twizo twizo = new Twizo(apiKey, apiHost); //Act var verification = twizo.CreateVerification(recipient); verification.Send(); string messageId = verification.messageId; var newVerficiation = twizo.GetVerification(messageId); //Assert Assert.AreEqual(verification.messageId, newVerficiation.messageId); Assert.AreEqual(verification.recipient, newVerficiation.recipient); }
private void Results() { string file = Menu.MyResultsFolder + @"\TwizoTestLogResults.txt"; File.Delete(file); Twizo twizo = new Twizo(apiKey, apiHost); var SmsReports = twizo.GetSmsResults(); var LookupResults = twizo.GetNumberLookupResults(); StringBuilder sb = new StringBuilder(); sb.AppendLine("---------------SMS REPORTS---------------"); foreach (var sms in SmsReports) { Type type = sms.GetType(); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo property in properties) { sb.AppendLine(String.Format("{0, -25} : {1}", property.Name, property.GetValue(sms, null))); } sb.AppendLine(Environment.NewLine); sb.AppendLine("----------------------"); } sb.AppendLine("----------NUMBER LOOKUP RESULTS----------"); foreach (var lookup in LookupResults) { Type type = lookup.GetType(); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo property in properties) { sb.AppendLine(String.Format("{0, -25} : {1}", property.Name, property.GetValue(lookup, null))); } sb.AppendLine(Environment.NewLine); sb.AppendLine("----------------------"); } File.AppendAllText(file, sb.ToString()); Process.Start(file); Console.WriteLine("Results were succesfully requested and written to TwizoTestLogResults.txt"); Console.WriteLine("Press any key to return to main menu."); Console.ReadKey(true); RunMenu(); }
public void GetWidgetSessionTest() { //Arrange string recipient = "601151174973"; string[] allowedTypes = new[] { WidgetSession.TYPE_SMS }; Twizo twizo = new Twizo(apiKey, apiHost); //Act var session = twizo.CreateWidgetSession(allowedTypes, recipient); session.Create(); string token = session.sessionToken; var newSession = twizo.GetWidgetSession(token, recipient); //Assert Assert.AreEqual(session.sessionToken, newSession.sessionToken); Assert.AreEqual(session.recipient, newSession.recipient); }
public void GetSmsTest() { //Arrange string recipient = "601151174973"; string body = "This is a unit test"; string sender = "Unit tester"; Twizo twizo = new Twizo(apiKey, apiHost); //Act var sms = twizo.CreateSms(recipient, body, sender); sms.Send(); string messageId = sms.messageId; var newSms = twizo.GetSms(messageId); //Assert Assert.AreEqual(sms.messageId, newSms.messageId); Assert.AreEqual(sms.recipient, newSms.recipient); }
public void Send() { Twizo twizo = new Twizo(this.apiKey, this.apiHost); var lookup = twizo.CreateNumberLookup(numbers); if (this.tag != "") { lookup.tag = this.tag; } lookup.validity = this.validity; lookup.resultType = this.resultType; if (this.callbackUrl != "") { lookup.callbackUrl = this.callbackUrl; } lookup.Send(); LogResponse(lookup); this.messageId = lookup.messageId; }
public TwizoAPI.Entity.Verification Refresh() { Twizo twizo = new Twizo(this.apiKey, this.apiHost); return(twizo.GetVerification(this.messageId)); }
public TwizoAPI.Entity.Sms Refresh() { Twizo twizo = new Twizo(this.apiKey, this.apiHost); return(twizo.GetSms(this.messageId)); }
public TwizoAPI.Entity.NumberLookup Refresh() { Twizo twizo = new Twizo(this.apiKey, this.apiHost); return(twizo.GetNumberLookup(this.messageId)); }