use of org.killbill.billing.jaxrs.json.AccountEmailJson in project killbill by killbill.
the class AccountResource method getEmails.
/*
* ************************* EMAILS *****************************
*/
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAILS)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve an account emails", response = AccountEmailJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied") })
public Response getEmails(@PathParam(ID_PARAM_NAME) final String id, @javax.ws.rs.core.Context final HttpServletRequest request) {
final UUID accountId = UUID.fromString(id);
final List<AccountEmail> emails = accountUserApi.getEmails(accountId, context.createContext(request));
final List<AccountEmailJson> emailsJson = new ArrayList<AccountEmailJson>();
for (final AccountEmail email : emails) {
emailsJson.add(new AccountEmailJson(email.getAccountId().toString(), email.getEmail()));
}
return Response.status(Status.OK).entity(emailsJson).build();
}
use of org.killbill.billing.jaxrs.json.AccountEmailJson in project killbill by killbill.
the class AccountResource method removeEmail.
@TimedResource
@DELETE
@Path("/{accountId:" + UUID_PATTERN + "}/" + EMAILS + "/{email}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Delete email from account")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied") })
public Response removeEmail(@PathParam(ID_PARAM_NAME) final String id, @PathParam("email") final String email, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) {
final UUID accountId = UUID.fromString(id);
final List<AccountEmail> emails = accountUserApi.getEmails(accountId, context.createContext(request));
for (final AccountEmail cur : emails) {
if (cur.getEmail().equals(email)) {
final AccountEmailJson accountEmailJson = new AccountEmailJson(accountId.toString(), email);
final AccountEmail accountEmail = accountEmailJson.toAccountEmail(cur.getId());
accountUserApi.removeEmail(accountId, accountEmail, context.createContext(createdBy, reason, comment, request));
}
}
return Response.status(Status.OK).build();
}
Aggregations