private static CreateMessageOptions CreateSMS(InvoiceNotificationRequest request) { return(new CreateMessageOptions(new PhoneNumber("+15005550006")) { Body = $"You have new invoice {request.InvoiceForNotification.InvoiceNumber} for {request.InvoiceForNotification.TotalCost.ToString()}." }); }
private static SendGridMessage CreateEmail(InvoiceNotificationRequest request) { var email = new SendGridMessage(); email.AddTo("*****@*****.**"); email.AddContent("text/html", $"You have new invoice {request.InvoiceForNotification.InvoiceNumber} for {request.InvoiceForNotification.TotalCost.ToString()}."); email.SetFrom(new EmailAddress("*****@*****.**")); email.SetSubject($"New Invoice - {request.InvoiceForNotification.InvoiceNumber}"); return(email); }
public static void Run( [QueueTrigger("invoice-notification-request")] InvoiceNotificationRequest notificationRequest, [SendGrid(ApiKey = "SendGridApiKey")] out SendGridMessage email, [TwilioSms(AccountSidSetting = "TwilioAccountSid", AuthTokenSetting = "TwilioAuthToken", From = "+15005550006")] out CreateMessageOptions sms, ILogger log) { log.LogInformation($"[NotifyInvoiceFunc] Queue trigger. Function processed: {notificationRequest}"); email = CreateEmail(notificationRequest); sms = CreateSMS(notificationRequest); }
private static BillingFunctionsStubs.CreateMessageOptions CreateSMS_NoBugs(InvoiceNotificationRequest request) { BillingFunctionsStubs.CreateMessageOptions createMessageOptions = new BillingFunctionsStubs.CreateMessageOptions(new BillingFunctionsStubs.PhoneNumber("+15005550006")) { Body = $"You have new invoice {request.InvoiceForNotification.InvoiceNumber} for {request.InvoiceForNotification.TotalCost.ToString()}." }; Contract.Assert(createMessageOptions.Body == $"You have new invoice {request.InvoiceForNotification.InvoiceNumber} for {request.InvoiceForNotification.TotalCost.ToString()}."); //Contract.Assert(createMessageOptions.To.Number == "+15005550006"); return(createMessageOptions); }
private static BillingFunctionsStubs.SendGridMessage CreateEmail_Bugged(InvoiceNotificationRequest request) { var email = new BillingFunctionsStubs.SendGridMessage(); email.AddTo("*****@*****.**"); email.AddContent("text/html", $"You have new invoice {request.InvoiceForNotification.InvoiceNumber} for {request.InvoiceForNotification.TotalCost.ToString()}."); email.SetFrom(new BillingFunctionsStubs.EmailAddress("*****@*****.**")); email.SetSubject($"New Invoice - {request.InvoiceForNotification.InvoiceNumber}"); //Contract.Assert(email.To != "*****@*****.**"); //Contract.Assert(email.From.Email != "*****@*****.**"); //Contract.Assert(email.Subject != $"New Invoice - {request.InvoiceForNotification.InvoiceNumber}"); Contract.Assert(email.Content != $"You have new invoice {request.InvoiceForNotification.InvoiceNumber} for {request.InvoiceForNotification.TotalCost.ToString()}."); return(email); }
public static void Run( [QueueTrigger("invoice-generation-request")] InvoiceGenerationRequest request, [Table("billingItems")] CloudTable billingItems, [CosmosDB("crm", "invoices", ConnectionStringSetting = "cosmosDb")] out dynamic generatedInvoice, [Queue("invoice-print-request")] out InvoicePrintRequest printRequest, [Queue("invoice-notification-request")] out InvoiceNotificationRequest notificationRequest, ILogger log) { log.LogInformation($"[GenerateInvoiceFunc] Queue trigger. Function processed: {request.CustomerCode} {request.Year} {request.Month}"); var generator = new InvoiceGenerator(); var items = GetBillingItemsFromTable(billingItems, request); var invoice = generator.Generate(request, items); generatedInvoice = invoice; printRequest = new InvoicePrintRequest { InvoiceToPrint = invoice }; notificationRequest = new InvoiceNotificationRequest { InvoiceForNotification = invoice }; }