/// <summary> /// Initializes Messente communication agent /// </summary> /// <param name="connectionSettings">explicit Messente connectivity parameters</param> /// <param name="defaultSmsSendingOptions">default sms sending options</param> public MessenteAgent(IMessenteConnectionSettings connectionSettings, ISmsSendingOptions defaultSmsSendingOptions) { if (connectionSettings == null) { throw new ArgumentNullException("connectionSettings"); } if (defaultSmsSendingOptions == null) { throw new ArgumentNullException("defaultSmsSendingOptions"); } InitializeSettings(connectionSettings, defaultSmsSendingOptions); }
/// <summary> /// Sends SMS. /// https://messente.com/pages/api#sms /// </summary> /// <param name="toPhoneNumber">reciepient mobile number</param> /// <param name="message">SMS text content</param> /// <param name="options">options to use instead of defaults</param> /// <returns>Successful responses contain unique SMS id for deliver reports.</returns> public MessenteResponse SendMessage(String toPhoneNumber, String message, ISmsSendingOptions options) { if (toPhoneNumber == null) { throw new ArgumentNullException("toPhoneNumber"); } if (message == null) { throw new ArgumentNullException("message"); } options = options ?? this.SmsSendingOptions; toPhoneNumber = PreparePhoneNumber(toPhoneNumber); StringBuilder postData = new StringBuilder(200); AppendAuthenticationParameters(postData); AppendPostParameter(postData, "to", toPhoneNumber, urlEncode: true); AppendPostParameter(postData, "text", message, urlEncode: true); //optional parameters: if (options.DeliveryReportUri != null) { AppendPostParameter(postData, "dlr-url", options.DeliveryReportUri.ToString(), urlEncode: true); } if (options.Sender != null) { AppendPostParameter(postData, "from", options.Sender, urlEncode: true); } if (options.DelayedSendTime != null) { var epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); var secondsSinceEpoch = Convert.ToInt64((options.DelayedSendTime.Value - epoch).TotalSeconds); postData.Append("&time_to_send=").Append(secondsSinceEpoch); // in unix timestamp. } return(SendRequest("send_sms/", postData.ToString())); }
private void InitializeSettings(IMessenteConnectionSettings connectionSettings, ISmsSendingOptions defaultSmsSendingOptions) { this.ConnectionSettings = connectionSettings ?? MessenteConnectionSettings.Default; ValidateConnectionConfiguration(); this.SmsSendingOptions = defaultSmsSendingOptions ?? new SmsSendingOptions(); }
/// <summary> /// Sends SMS. /// https://messente.com/pages/api#sms /// </summary> /// <param name="toPhoneNumber">reciepient mobile number</param> /// <param name="message">SMS text content</param> /// <param name="options">options to use instead of defaults</param> /// <returns>Successful responses contain unique SMS id for deliver reports.</returns> public MessenteResponse SendMessage(String toPhoneNumber, String message, ISmsSendingOptions options) { if (toPhoneNumber == null) { throw new ArgumentNullException("toPhoneNumber"); } if (message == null) { throw new ArgumentNullException("message"); } options = options ?? this.SmsSendingOptions; toPhoneNumber = PreparePhoneNumber(toPhoneNumber); StringBuilder postData = new StringBuilder(200); AppendAuthenticationParameters(postData); AppendPostParameter(postData, "to", toPhoneNumber, urlEncode: true); AppendPostParameter(postData, "text", message, urlEncode: true); //optional parameters: if (options.DeliveryReportUri != null) { AppendPostParameter(postData, "dlr-url", options.DeliveryReportUri.ToString(), urlEncode: true); } if (options.Sender != null) { AppendPostParameter(postData, "from", options.Sender, urlEncode: true); } if (options.DelayedSendTime != null) { var epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); var secondsSinceEpoch = Convert.ToInt64((options.DelayedSendTime.Value - epoch).TotalSeconds); postData.Append("&time_to_send=").Append(secondsSinceEpoch); // in unix timestamp. } return SendRequest("send_sms/", postData.ToString()); }