From 7d9ab3b87aed944167d77244b00fbdd4224725e2 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 14 Nov 2024 14:30:42 +0200 Subject: Added support for SMS notifications on TS & X4. --- .../Controllers/PPCController.cs | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Controllers') diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs index 06b2fd232..d8f514c42 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/PPCController.cs @@ -25,6 +25,9 @@ using Tango.Core.Cryptography; using Tango.MachineService.Filters; using Tango.BL.DTO; using Z.EntityFramework.Plus; +using Twilio; +using Twilio.Rest.Api.V2010.Account; +using Twilio.Types; namespace Tango.MachineService.Controllers { @@ -48,6 +51,7 @@ namespace Tango.MachineService.Controllers { _pendingUploads = new List(); _pendingUpdates = new List(); + TwilioClient.Init(MachineServiceConfig.TWILIO_ACCOUNT_SID, MachineServiceConfig.TWILIO_AUTH_TOKEN); } public PPCController() @@ -830,6 +834,27 @@ namespace Tango.MachineService.Controllers #endregion + #region SMS + + [HttpPost] + [JwtTokenFilter] + public SendSMSResponse SendSMS(SendSMSRequest request) + { + var response = new SendSMSResponse(); + + if (MachineServiceConfig.TWILIO_ENABLE_SMS) + { + foreach (var phone in request.PhoneNumbers) + { + MessageResource.Create(from: MachineServiceConfig.TWILIO_FROM_NUMBER, to: new PhoneNumber(phone), body: request.Message); + } + } + + return response; + } + + #endregion + #region Version Upload [HttpPost] -- cgit v1.3.1