@@ -30,74 +30,98 @@ Install this NuGet library directly from the IDE package installer or by followi
3030
3131To incorporate PandaTech.Communicator into your project, you have a primary method to setup in your ` Program.cs ` :
3232
33- ` builder.AddPandaCommunicator (); `
33+ ` builder.AddCommunicator (); `
3434
3535Configuration options can be specified either in ` appsettings.json ` or directly in ` Program.cs ` , with the latter taking precedence.
3636
37+ There are several supported channels which must be kept during setup:
38+
39+ ``` csharp
40+ EmailChannels
41+ {
42+ " GeneralSender" ,
43+ " TransactionalSender" ,
44+ " NotificationSender" ,
45+ " MarketingSender" ,
46+ " SupportSender"
47+ };
48+
49+ SmsChannels
50+ {
51+ " GeneralSender" ,
52+ " TransactionalSender" ,
53+ " NotificationSender" ,
54+ " MarketingSender" ,
55+ " SupportSender"
56+ };
57+ ```
58+
59+ For each channel can be setup same provider, but it's recommended to have different sender, as they are dedicated for different purposes.
60+
3761### 1.3.1. Program.cs Example
3862
3963In case of using SSL by setting UseSsl = true use port number 456, otherwise use 587 for non SSL connection.
4064
4165``` csharp
42- builder .AddPandaCommunicator (options =>
66+ builder .AddCommunicator (options =>
4367{
4468 options .SmsFake = false ;
45- options .SmsConfigurations =
46- [
47- new SmsConfiguration
69+ options .SmsConfigurations = new Dictionary <string , SmsConfiguration >
70+ {
4871 {
49- Provider = " Dexatel" ,
50- BaseUrl = " https://api.dexatel.com" ,
51- From = " sender_name" ,
52- Properties = new ()
72+ " GeneralSender" , new SmsConfiguration
5373 {
54- { " X-Dexatel-Key" , " key" }
55- },
56- TimeoutMs = 10000 ,
57- Channel = " GeneralSender"
74+ Provider = " Dexatel" ,
75+ From = " sender_name" ,
76+ Properties = new Dictionary <string , string >
77+ {
78+ { " X-Dexatel-Key" , " key" }
79+ },
80+ TimeoutMs = 10000
81+ }
5882 },
59-
60- new SmsConfiguration
6183 {
62- Provider = " Twilio" ,
63- BaseUrl = " https://api.twilio.com" ,
64- From = " sender_number" ,
65- Properties = new ()
84+ " TransactionalSender" , new SmsConfiguration
6685 {
67- { " SID" , " key" },
68- { " AUTH_TOKEN" , " token" }
69- },
70- TimeoutMs = 10000 ,
71- Channel = " TransactionalSender"
86+ Provider = " Twilio" ,
87+ From = " sender_number" ,
88+ Properties = new Dictionary <string , string >
89+ {
90+ { " SID" , " key" },
91+ { " AUTH_TOKEN" , " token" }
92+ },
93+ TimeoutMs = 10000
94+ }
7295 }
73- ] ;
96+ } ;
7497 options .EmailFake = false ;
75- options .EmailConfigurations =
76- [
77- new EmailConfiguration
98+ options .EmailConfigurations = new Dictionary <string , EmailConfiguration >
99+ {
78100 {
79- SmtpServer = " smtp.test.com" ,
80- SmtpPort = 465 , // 587
81- SmtpUsername = " test" ,
82- SmtpPassword = " test123" ,
83- SenderEmail = " [email protected] " ,
84- UseSsl = true , // false
85- TimeoutMs = 10000 ,
86- Channel = " GeneralSender"
101+ " GeneralSender" , new EmailConfiguration
102+ {
103+ SmtpServer = " smtp.test.com" ,
104+ SmtpPort = 465 , // 587
105+ SmtpUsername = " test" ,
106+ SmtpPassword = " test123" ,
107+ SenderEmail = " [email protected] " ,
108+ UseSsl = true , // false
109+ TimeoutMs = 10000
110+ }
87111 },
88-
89- new EmailConfiguration
90112 {
91- SmtpServer = " smtp.gmail.com" ,
92- SmtpPort = 465 , // 587
93- SmtpUsername = " vazgen" ,
94- SmtpPassword = " vazgen123" ,
95- SenderEmail = " [email protected] " ,
96- UseSsl = true , // false
97- TimeoutMs = 10000 ,
98- Channel = " TransactionalSender"
113+ " TransactionalSender" , new EmailConfiguration
114+ {
115+ SmtpServer = " smtp.gmail.com" ,
116+ SmtpPort = 465 , // 587
117+ SmtpUsername = " vazgen" ,
118+ SmtpPassword = " vazgen123" ,
119+ SenderEmail = " [email protected] " ,
120+ UseSsl = true , // false
121+ TimeoutMs = 10000
122+ }
99123 }
100- ] ;
124+ } ;
101125});
102126
103127```
@@ -112,66 +136,60 @@ builder.AddPandaCommunicator(options =>
112136 "Microsoft.AspNetCore" : " Warning"
113137 }
114138 },
115- "PandaCommunicator " : {
139+ "Communicator " : {
116140 "SmsFake" : false ,
117- "SmsConfigurationOptions " : [
118- {
141+ "SmsConfigurations " : {
142+ "GeneralSender" : {
119143 "Provider" : " Dexatel" ,
120- "BaseUrl" : " https://api.dexatel.com" ,
121144 "From" : " sender_name" ,
122145 "Properties" : {
123146 "X-Dexatel-Key" : " key"
124147 },
125- "TimeoutMs" : " 10000" ,
126- "Channel" : " GeneralSender"
148+ "TimeoutMs" : " 10000"
127149 },
128- {
150+ "TransactionalSender" : {
129151 "Provider" : " Twilio" ,
130- "BaseUrl" : " https://api.twilio.com" ,
131- "From" : " twilio_sender_number" ,
152+ "From" : " sender_number" ,
132153 "Properties" : {
133154 "SID" : " key" ,
134155 "AUTH_TOKEN" : " token"
135156 },
136- "TimeoutMs" : " 10000" ,
137- "Channel" : " TransactionalSender"
157+ "TimeoutMs" : " 10000"
138158 }
139- ] ,
159+ } ,
140160 "EmailFake" : false ,
141- "EmailConfigurationOptions " : [
142- {
161+ "EmailConfigurations " : {
162+ "GeneralSender" : {
143163 "SmtpServer" : " smtp.gmail.com" ,
144- "SmtpPort" : " 465" , // 587
145- "SmtpUsername" : " test" ,
146- "SmtpPassword" : " test123" ,
147- "SenderEmail" :
" [email protected] " ,
148- "UseSsl" : " true" , // false
149- "TimeoutMs" : " 10000" ,
150- "Channel" : " GeneralSender"
164+ "SmtpPort" : 465 , // 587
165+ "SmtpUsername" : " vazgen" ,
166+ "SmtpPassword" : " vazgen123" ,
167+ "SenderEmail" :
" [email protected] " ,
168+ "UseSsl" : true , // false
169+ "TimeoutMs" : " 10000"
151170 },
152- {
171+ "TransactionalSender" : {
153172 "SmtpServer" : " smtp.gmail.com" ,
154- "SmtpPort" : " 465" , // 587
173+ "SmtpPort" : 465 , // 587
155174 "SmtpUsername" : " vazgen" ,
156175 "SmtpPassword" : " vazgen123" ,
157176 "SenderEmail" :
" [email protected] " ,
158- "UseSsl" : " true" , // false
159- "TimeoutMs" : " 10000" ,
160- "Channel" : " TransactionalSender"
177+ "UseSsl" : true , // false
178+ "TimeoutMs" : " 10000"
161179 }
162- ]
180+ }
163181 }
164182}
165183```
166184The configuration options in ` appsettings.json ` and ` program.cs ` (priority) are identical.
167185
168186## 1.4. Configuration Options Explained
169187
170- - ** PandaCommunicator :** Global settings for PandaTech.Communicator
188+ - ** Communicator :** Global settings for PandaTech.Communicator
171189- ** SmsFake:** This setup is for fake SMS service to be used which doesn't send real SMS messages and just return ` TTask.CompletedTask ` .
172- - ** SmsConfigurations:** SMS configurations given by ` appsettings.json ` or via ` builder.AddPandaCommunicator () ` options for SMS.
190+ - ** SmsConfigurations:** SMS configurations given by ` appsettings.json ` or via ` builder.AddCommunicator () ` options for SMS.
173191- ** EmailFake:** This setup is for fake Email service to be used which doesn't send real SMS messages and just return ` TTask.CompletedTask ` .
174- - ** EmailConfigurations:** Email configurations given by ` appsettings.json ` or via ` builder.AddPandaCommunicator () ` options for Email.
192+ - ** EmailConfigurations:** Email configurations given by ` appsettings.json ` or via ` builder.AddCommunicator () ` options for Email.
175193
176194## 1.5. Limitations
177195
0 commit comments