We need to implement a service that will send SMS messages. It should support different providers.
We will define an ISmsService
interface that will contain a single method
void SendSms(string phoneNumber, string message)
The method is expected to throw an exception if message sending fails.
Then we need to create an SmsServiceAdapter
that will be responsible for sequential workflow interactions. It will support the SendSms
method. It will be similar to the current MailServiceAgent.
The model part should be added to the Root model.
We should also add new property to OrigamSettings
class – SmsService
that will, similarly to DataDataService
contain a classpath of the SMS Service implementation (e.g. Origam.Twilio.TwilioService, Origam.Twilio
). This way it will be possible to plug in different SMS service providers, depending on the customer’s needs.
Each implementation should then read its settings (e.g. authentication config) from general config file, e.g. appsettings.json
, similarly to the MailService
.
To recap the steps:
- Create
ISmsService
interface - Implement the
ISmsService
interface in a separate DLL project (e.g.Origam.Twilio
) - Add classpath config to
OrigamSettings
class so we can plug-in the implementation - Create a new
Origam.Workflow.SmsServiceAdapter
that will use the config to instantiate theISmsService
implementation using reflection - Register the new
SmsService
and its method in Root model so it can be used in models