public void CheckOriginatorWithOversize() { // Arrange // Act var data = new SendTextSMS("Userkey", "Password", null, "+41791234567,+41761234567", "Test Message", false, null, null, null, null, "SeqInstance001"); // Assert Assert.Equal("SeqInstance", data.Originator); }
public void CheckInvalidPhoneNumberOriginator() { // Arrange // Act var data = new SendTextSMS("Userkey", "Password", "+41 79 123 45 67", "+41791234567,+41761234567", "Test Message", false, null, null, null, null, null); // Assert Assert.Equal("Seq Server", data.Originator); }
public void CheckJsonOutput() { // Arrange var data = new SendTextSMS("Userkey", "Password", "SEQ", "+41791234567,+41761234567", "Test Message", false, null, null, null, null, null); // Act var json = data.GetAsJson(); // Assert Assert.Equal("SEQ", data.Originator); Assert.NotEmpty(json); }
public void On(Event <LogEventData> evt) { // Create MessageText var message = $"{evt.Data.LocalTimestamp.LocalDateTime} ({evt.Data.Level}) {evt.Data.RenderedMessage}"; // Fill in data var data = new SendTextSMS( Username, Password, Originator, Recipients, message, FlashingSMS, URLBufferedMessageNotification, URLDeliveryNotification, URLNonDeliveryNotification, AffiliateID, Host.InstanceName); // Send SMS using (var client = new WebClient()) { try { var result = client.UploadString($"{_postUrl}SendTextSMS", data.GetAsJson()); if (!LogStatus) { return; } try { var obj = new Result(result); if (LogAvailableCredits) { var credits = new CheckCredits(Username, Password); var creditResult = new Result(client.UploadString($"{_postUrl}CheckCredits", credits.GetAsJson())); Log.Information("SMS sent with {StatusCode} {StatusInfo} ({AvailableCredits} Credits left)", obj.StatusCode, obj.StatusInfo, creditResult.Credits); } else { Log.Information("SMS sent with {StatusCode} {StatusInfo}", obj.StatusCode, obj.StatusInfo); } } catch (Exception ex) { Log.Error(ex, "Can't parse status code from result", result); } } catch (Exception ex) { Log.Error(ex, "There was a problem sending SMS"); } } }