/// <summary> /// Validate Nexmo Settings and MailChimp Settings /// </summary> /// <returns>true or false</returns> public bool ValidateFields() { if (string.IsNullOrEmpty(txtNexmoAPI.Text.Trim())) { MessageBox.Show("Please enter the Nexmo Key.", "Nexmo Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNexmoAPI.Focus(); return(false); } if (string.IsNullOrEmpty(txtNexmoSecretKey.Text.Trim())) { MessageBox.Show("Please enter the Nexmo Secret. ", "Nexmo Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNexmoSecretKey.Focus(); return(false); } if (string.IsNullOrEmpty(txtMailChimpAPI.Text.Trim())) { MessageBox.Show("Please enter the MailChimp Api Key. ", "MailChimp Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtMailChimpAPI.Focus(); return(false); } try { string fromNumber = SmsSender.GetAccountNumber(txtNexmoAPI.Text.Trim(), txtNexmoSecretKey.Text.Trim()); if (string.IsNullOrEmpty(fromNumber.Trim())) { MessageBox.Show("Not found MISDN number in Nexmo.", "Nexmo Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } else { FromNumber = fromNumber; } } catch (Exception ex) { MessageBox.Show("Please enter valid Nexmo Key and Secret.", "Nexmo Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } try { MailChimpManager mc = new MailChimpManager(txtMailChimpAPI.Text.Trim()); var ss = mc.GetVerifiedDomains(); } catch (Exception ex) { MessageBox.Show("Please enter valid MailChimp API Key.", "MailChimp Settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } return(true); }
public string SendMessage([CustomSummary("Nexmo Key")] string apikey, [CustomSummary("Nexmo Secret")] string apiSecret, [CustomSummary("Recipient number")] string to, [CustomSummary("Message text")] string text, [CustomSummary("Enable SMS")] bool enable = true) { try { if (enable) { SmsSender s = new SmsSender(); string from = s.GetAccountNumber(apikey, apiSecret); s.SendSMS(to, from, apikey, apiSecret, Uri.EscapeUriString(text)); } else { return("disabled"); } } catch { return("fail"); } return("success"); }