use of org.openhab.ui.habot.card.Card in project habot by ghys.
the class CreateRuleSkill method interpret.
@Override
public IntentInterpretation interpret(Intent intent, String language) {
IntentInterpretation interpretation = new IntentInterpretation();
Card card = new Card("HbCreateRuleCard");
// TODO: try to parse a day/time to pre-configure the new rule card
interpretation.setAnswer(answerFormatter.getRandomAnswer("answer_create_rule"));
interpretation.setCard(card);
return interpretation;
}
use of org.openhab.ui.habot.card.Card in project habot by ghys.
the class HABotResource method createCard.
@POST
@Path("/cards")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Creates a new card in the card deck.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "The card was created"), @ApiResponse(code = 500, message = "An error occured") })
public Response createCard(@ApiParam(value = "card", required = true) Card card) {
card.updateTimestamp();
card.setEphemeral(false);
Card existingCard = this.cardRegistry.get(card.getUID());
if (existingCard != null && existingCard.isEphemeral()) {
this.cardRegistry.remove(card.getUID());
}
Card createdCard = this.cardRegistry.add(card);
return Response.ok(createdCard).build();
}
use of org.openhab.ui.habot.card.Card in project habot by ghys.
the class HABotResource method unsetCardBookmark.
@DELETE
@Path("/cards/{cardUID}/bookmark")
@ApiOperation(value = "Removes the bookmark on a card.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "The card with the provided UID doesn't exist"), @ApiResponse(code = 500, message = "An error occured") })
public Response unsetCardBookmark(@PathParam("cardUID") @ApiParam(value = "cardUID", required = true) String cardUID) {
Card card = this.cardRegistry.get(cardUID);
if (card == null) {
return Response.status(Status.NOT_FOUND).build();
}
card.setBookmark(false);
this.cardRegistry.update(card);
return Response.ok().build();
}
use of org.openhab.ui.habot.card.Card in project habot by ghys.
the class HABotResource method updateCard.
@PUT
@Path("/cards/{cardUID}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Updates a card in the card deck.")
public Response updateCard(@PathParam("cardUID") @ApiParam(value = "cardUID", required = true) String cardUID, @ApiParam(value = "card", required = true) Card card) {
if (!card.getUID().equals(cardUID)) {
throw new InvalidParameterException("The card UID in the body of the request should match the UID in the URL");
}
card.updateTimestamp();
Card updatedCard = this.cardRegistry.update(card);
return Response.ok(updatedCard).build();
}
use of org.openhab.ui.habot.card.Card in project habot by ghys.
the class HABotResource method updateCardTimestamp.
@PUT
@Path("/cards/{cardUID}/timestamp")
@ApiOperation(value = "Updates the timestamp on a card to the current time")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 404, message = "The card with the provided UID doesn't exist"), @ApiResponse(code = 500, message = "An error occured") })
public Response updateCardTimestamp(@PathParam("cardUID") @ApiParam(value = "cardUID", required = true) String cardUID) {
Card card = this.cardRegistry.get(cardUID);
if (card == null) {
return Response.status(Status.NOT_FOUND).build();
}
card.updateTimestamp();
this.cardRegistry.update(card);
return Response.ok().build();
}
Aggregations