Skip to content

Instantly share code, notes, and snippets.

@viveknaskar
Created October 11, 2022 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viveknaskar/0f8bcf0e2e0a3bda8473bafc51ff4b49 to your computer and use it in GitHub Desktop.
Save viveknaskar/0f8bcf0e2e0a3bda8473bafc51ff4b49 to your computer and use it in GitHub Desktop.
Alert Controller for sending SMS
import com.viveknaskar.smsalertsystem.domain.AlertMessage;
import com.viveknaskar.smsalertsystem.domain.User;
import com.viveknaskar.smsalertsystem.service.AlertService;
import org.springframework.beans.factory.annotation.Autowired;
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;
@RestController
@RequestMapping("/v1")
public class AlertController {
@Autowired
AlertService alertService;
@PostMapping("/sms")
public ResponseEntity<String> sendAlertMessage(@RequestBody AlertMessage alertMessage) {
User user = new User("Bruce", "Wayne", "+12025550001");
alertService.sendSMS(user, alertMessage);
return new ResponseEntity<>("Alert Message Sent Successfully!", HttpStatus.OK);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment