/
TriggerController.cs
67 lines (60 loc) · 2.08 KB
/
TriggerController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Altinn.Notifications.Core.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
namespace Altinn.Notifications.Controllers;
/// <summary>
/// Controller for all trigger operations
/// </summary>
[Route("notifications/api/v1/trigger")]
[ApiController]
[ApiExplorerSettings(IgnoreApi = true)]
public class TriggerController : ControllerBase
{
private readonly IOrderProcessingService _orderProcessingService;
private readonly IEmailNotificationService _emailNotificationService;
private readonly ISmsNotificationService _smsNotificationService;
/// <summary>
/// Initializes a new instance of the <see cref="TriggerController"/> class.
/// </summary>
public TriggerController(
IOrderProcessingService orderProcessingService,
IEmailNotificationService emailNotificationService,
ISmsNotificationService smsNotificationService)
{
_orderProcessingService = orderProcessingService;
_emailNotificationService = emailNotificationService;
_smsNotificationService = smsNotificationService;
}
/// <summary>
/// Endpoint for starting the processing of past due orders
/// </summary>
[HttpPost]
[Consumes("application/json")]
[Route("pastdueorders")]
public async Task<ActionResult> Trigger_PastDueOrders()
{
await _orderProcessingService.StartProcessingPastDueOrders();
return Ok();
}
/// <summary>
/// Endpoint for starting the processing of emails that are ready to be sent
/// </summary>
[HttpPost]
[Consumes("application/json")]
[Route("sendemail")]
public async Task<ActionResult> Trigger_SendEmailNotifications()
{
await _emailNotificationService.SendNotifications();
return Ok();
}
/// <summary>
/// Endpoint for starting the processing of sms that are ready to be sent
/// </summary>
[HttpPost]
[Consumes("application/json")]
[Route("sendsms")]
public async Task<ActionResult> Trigger_SendSmsNotifications()
{
await _smsNotificationService.SendNotifications();
return Ok();
}
}