mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 15:49:33 -05:00
fix(account): implement DeleteAlternateContact (#5560)
* fix(account): implement DeleteAlternateContact Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * docs(account): document DeleteAlternateContact Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> --------- Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
1 parent
ad8fba7f45
commit
9174147cb6
6 files changed
+51
-1
No files matched your search
@@ -47,6 +47,13 @@ public class AccountController {
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/deleteAlternateContact")
|
||||
public Response deleteAlternateContact(String body) {
|
||||
accountService.deleteAlternateContact(requestContext.getAccountId(), readTree(body));
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
private JsonNode readTree(String body) {
|
||||
try {
|
||||
return objectMapper.reader()
|
||||
|
||||
@@ -56,6 +56,17 @@ public class AccountService implements Resettable {
|
||||
"The alternate contact does not exist for the specified account and contact type.", 404));
|
||||
}
|
||||
|
||||
public synchronized void deleteAlternateContact(String callerAccountId, JsonNode request) {
|
||||
String targetAccountId = resolveTargetAccount(callerAccountId, request);
|
||||
String type = requireContactType(request);
|
||||
boolean exists = contacts.getForAccount(targetAccountId, type).isPresent();
|
||||
if (!exists) {
|
||||
throw new AwsException("ResourceNotFoundException",
|
||||
"The alternate contact does not exist for the specified account and contact type.", 404);
|
||||
}
|
||||
contacts.deleteForAccount(targetAccountId, type);
|
||||
}
|
||||
|
||||
private String resolveTargetAccount(String callerAccountId, JsonNode request) {
|
||||
JsonNode accountIdNode = request == null ? null : request.get("AccountId");
|
||||
if (accountIdNode == null || accountIdNode.isNull()) {
|
||||
|
||||
Reference in new issue
Block a user