/* * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using QuantConnect.Util; namespace QuantConnect.Notifications { /// /// Local/desktop implementation of messaging system for Lean Engine. /// public abstract class Notification { /// /// Method for sending implementations of notification object types. /// /// SMS, Email and Web are all handled by the QC Messaging Handler. To implement your own notification type implement it here. public virtual void Send() { // } } /// /// Web Notification Class /// public class NotificationWeb : Notification { /// /// Send a notification message to this web address /// public string Address; /// /// Object data to send. /// public object Data; /// /// Constructor for sending a notification SMS to a specified phone number /// /// /// public NotificationWeb(string address, object data = null) { Address = address; Data = data; } } /// /// Sms Notification Class /// public class NotificationSms : Notification { /// /// Send a notification message to this phone number /// public string PhoneNumber; /// /// Message to send. Limited to 160 characters /// public string Message; /// /// Constructor for sending a notification SMS to a specified phone number /// /// /// public NotificationSms(string number, string message) { PhoneNumber = number; Message = message; } } /// /// Email notification data. /// public class NotificationEmail : Notification { /// /// Optional email headers /// public Dictionary Headers; /// /// Send to address: /// public string Address; /// /// Email subject /// public string Subject; /// /// Message to send. /// public string Message; /// /// Email Data /// public string Data; /// /// Default constructor for sending an email notification /// /// Address to send to. Will throw if invalid /// /// Subject of the email. Will set to if null /// Message body of the email. Will set to if null /// Data to attach to the email. Will set to if null /// Optional email headers to use public NotificationEmail(string address, string subject = "", string message = "", string data = "", Dictionary headers = null) { if (!Validate.EmailAddress(address)) { throw new ArgumentException($"Invalid email address: {address}"); } Address = address; Data = data ?? string.Empty; Message = message ?? string.Empty; Subject = subject ?? string.Empty; Headers = headers; } } }