|
@@ -22,6 +22,8 @@ import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import es.uv.garcosda.shared.domain.Mail;
|
|
|
import es.uv.garcosda.shared.domain.MailDTO;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/api/v1")
|
|
@@ -38,11 +40,15 @@ public class MailerController {
|
|
|
private String data_api;
|
|
|
|
|
|
@GetMapping("status")
|
|
|
+ @SecurityRequirement(name = "Bearer Authentication")
|
|
|
+ @Operation(summary="Is running?", description="Tests if the service is running")
|
|
|
public ResponseEntity<String> test(){
|
|
|
return new ResponseEntity<String>("Running", HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
@GetMapping("{mail}")
|
|
|
+ @SecurityRequirement(name = "Bearer Authentication")
|
|
|
+ @Operation(summary="Get inbox", description="Get inbox for a certain user by its email")
|
|
|
public ResponseEntity<?> getMails(@PathVariable String mail, @RequestHeader("x-auth-user-id") String user){
|
|
|
ResponseEntity<MailDTO[]> response;
|
|
|
List<MailDTO> mails = new ArrayList<MailDTO>();
|
|
@@ -66,6 +72,8 @@ public class MailerController {
|
|
|
}
|
|
|
|
|
|
@DeleteMapping("{id}")
|
|
|
+ @SecurityRequirement(name = "Bearer Authentication")
|
|
|
+ @Operation(summary="Delete email", description="Delete one email by id")
|
|
|
public ResponseEntity<?> deleteMail(@PathVariable String id){
|
|
|
try {
|
|
|
template.delete(input_api+"/"+id);
|
|
@@ -77,6 +85,8 @@ public class MailerController {
|
|
|
}
|
|
|
|
|
|
@PostMapping
|
|
|
+ @SecurityRequirement(name = "Bearer Authentication")
|
|
|
+ @Operation(summary="Send email", description="Send email to a user")
|
|
|
public ResponseEntity<?> sendMail(@RequestBody Mail mail){
|
|
|
ResponseEntity<Mail> response;
|
|
|
try {
|