use of com.arnaugarcia.uplace.domain.Agent in project uplace.es by Uplace.
the class AgentResource method getAgent.
/**
* GET /agents/:id : get the "id" agent.
*
* @param id the id of the agent to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the agent, or with status 404 (Not Found)
*/
@GetMapping("/agents/{id}")
@Timed
public ResponseEntity<Agent> getAgent(@PathVariable Long id) {
log.debug("REST request to get Agent : {}", id);
Agent agent = agentService.findOne(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(agent));
}
use of com.arnaugarcia.uplace.domain.Agent in project uplace.es by Uplace.
the class AgentResource method createAgent.
/**
* POST /agents : Create a new agent.
*
* @param agent the agent to create
* @return the ResponseEntity with status 201 (Created) and with body the new agent, or with status 400 (Bad Request) if the agent has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/agents")
@Timed
public ResponseEntity<Agent> createAgent(@Valid @RequestBody Agent agent) throws URISyntaxException {
log.debug("REST request to save Agent : {}", agent);
if (agent.getId() != null) {
throw new BadRequestAlertException("A new agent cannot already have an ID", ENTITY_NAME, "idexists");
}
Agent result = agentService.save(agent);
return ResponseEntity.created(new URI("/api/agents/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
use of com.arnaugarcia.uplace.domain.Agent in project uplace.es by Uplace.
the class AgentResource method updateAgent.
/**
* PUT /agents : Updates an existing agent.
*
* @param agent the agent to update
* @return the ResponseEntity with status 200 (OK) and with body the updated agent,
* or with status 400 (Bad Request) if the agent is not valid,
* or with status 500 (Internal Server Error) if the agent couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/agents")
@Timed
public ResponseEntity<Agent> updateAgent(@Valid @RequestBody Agent agent) throws URISyntaxException {
log.debug("REST request to update Agent : {}", agent);
if (agent.getId() == null) {
return createAgent(agent);
}
Agent result = agentService.save(agent);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, agent.getId().toString())).body(result);
}
Aggregations