-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMailController.java
More file actions
50 lines (42 loc) · 1.77 KB
/
MailController.java
File metadata and controls
50 lines (42 loc) · 1.77 KB
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
package idealab.api.controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import idealab.api.dto.request.MailRequest;
import idealab.api.dto.request.UpdateEmailInfoRequest;
import idealab.api.dto.response.GenericResponse;
import idealab.api.operations.PropertyOperations;
import idealab.api.service.EmailService;
@RestController
@RequestMapping("/api/mail")
public class MailController {
private EmailService emailService;
private final PropertyOperations propertyOperations;
public MailController(EmailService emailService, PropertyOperations propertyOperations) {
this.emailService = emailService;
this.propertyOperations = propertyOperations;
}
@PostMapping
public ResponseEntity<?> sendEmail(@RequestBody MailRequest mailRequest) {
emailService.sendSimpleMessage(mailRequest);
GenericResponse response = new GenericResponse();
response.setSuccess(true);
response.setMessage("Email sent successfully");
response.setHttpStatus(HttpStatus.ACCEPTED);
return new ResponseEntity<>(response, response.getHttpStatus());
}
/**
* This updates the email and password associated with the application.
* @param request
* @return
*/
@PostMapping("/info")
public GenericResponse updateEmailInfo(@RequestBody UpdateEmailInfoRequest request) {
String email = request.getEmail();
String pw = request.getPassword();
return propertyOperations.updateEmailInfo(email, pw);
}
}