Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created March 11, 2025 14:54
Show Gist options
  • Save dcomartin/28a67c46525f64284867eedb5391b5cf to your computer and use it in GitHub Desktop.
Save dcomartin/28a67c46525f64284867eedb5391b5cf to your computer and use it in GitHub Desktop.
public class SendSmsWhenDelivered
{
private readonly GetShipmentContact _getShipmentContact;
private readonly SmsOptions _options;
public SendSmsWhenDelivered(IOptions<SmsOptions> options, GetShipmentContact getShipmentContact)
{
_getShipmentContact = getShipmentContact;
_options = options.Value;
}
public async Task Handle(Delivered delivered)
{
var contact = await _getShipmentContact(delivered.ReferenceNumber);
await MessageResource.CreateAsync(
body: $"{delivered.ReferenceNumber} Package Delivered!",
from: new PhoneNumber(_options.From),
to: new PhoneNumber(contact.PhoneNumber)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment