From 4de7ca3fa0027f04f3ba1c4b001448a452b28d95 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 8 Nov 2018 20:59:48 +0300 Subject: [PATCH] Add SmsSenderExtensions and add constructor to the SmsMessage class. --- .../Volo.Abp.Sms/Volo/Abp/Sms/SmsMessage.cs | 19 +++++++++++++------ .../Volo/Abp/Sms/SmsSenderExtensions.cs | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 framework/src/Volo.Abp.Sms/Volo/Abp/Sms/SmsSenderExtensions.cs diff --git a/framework/src/Volo.Abp.Sms/Volo/Abp/Sms/SmsMessage.cs b/framework/src/Volo.Abp.Sms/Volo/Abp/Sms/SmsMessage.cs index 8e8c9d3c1c..fd1049b1b0 100644 --- a/framework/src/Volo.Abp.Sms/Volo/Abp/Sms/SmsMessage.cs +++ b/framework/src/Volo.Abp.Sms/Volo/Abp/Sms/SmsMessage.cs @@ -1,15 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; +using JetBrains.Annotations; namespace Volo.Abp.Sms { public class SmsMessage { - public string PhoneNumber { get; set; } + public string PhoneNumber { get; } - public string Text { get; set; } + public string Text { get; } - public IDictionary Properties { get; set; } + public IDictionary Properties { get; } + + public SmsMessage([NotNull] string phoneNumber, [NotNull] string text) + { + PhoneNumber = Check.NotNullOrWhiteSpace(phoneNumber, nameof(phoneNumber)); + Text = Check.NotNullOrWhiteSpace(text, nameof(text)); + + Properties = new Dictionary(); + } } } diff --git a/framework/src/Volo.Abp.Sms/Volo/Abp/Sms/SmsSenderExtensions.cs b/framework/src/Volo.Abp.Sms/Volo/Abp/Sms/SmsSenderExtensions.cs new file mode 100644 index 0000000000..30b2ecca86 --- /dev/null +++ b/framework/src/Volo.Abp.Sms/Volo/Abp/Sms/SmsSenderExtensions.cs @@ -0,0 +1,14 @@ +using JetBrains.Annotations; +using System.Threading.Tasks; + +namespace Volo.Abp.Sms +{ + public static class SmsSenderExtensions + { + public static Task SendAsync([NotNull] this ISmsSender smsSender, [NotNull] string phoneNumber, [NotNull] string text) + { + Check.NotNull(smsSender, nameof(smsSender)); + return smsSender.SendAsync(new SmsMessage(phoneNumber, text)); + } + } +}