use of com.nexblocks.authguard.api.dto.entities.AccountDTO in project AuthGuard by AuthGuard.
the class AccountsRoute method getByExternalId.
public void getByExternalId(final Context context) {
final String accountId = context.pathParam("id");
final Optional<AccountDTO> account = accountsService.getByExternalId(accountId).map(restMapper::toDTO);
if (account.isPresent()) {
context.status(200).json(account.get());
} else {
context.status(404).json(new Error(ErrorCode.ACCOUNT_DOES_NOT_EXIST.getCode(), "Account not found"));
}
}
use of com.nexblocks.authguard.api.dto.entities.AccountDTO in project AuthGuard by AuthGuard.
the class AccountsRoute method updatePermissions.
public void updatePermissions(final Context context) {
final String accountId = context.pathParam("id");
final PermissionsRequestDTO request = permissionsRequestBodyHandler.getValidated(context);
final List<PermissionBO> permissions = request.getPermissions().stream().map(restMapper::toBO).collect(Collectors.toList());
final AccountDTO updatedAccount;
if (request.getAction() == PermissionsRequest.Action.GRANT) {
updatedAccount = restMapper.toDTO(accountsService.grantPermissions(accountId, permissions));
} else {
updatedAccount = restMapper.toDTO(accountsService.revokePermissions(accountId, permissions));
}
context.json(updatedAccount);
}
use of com.nexblocks.authguard.api.dto.entities.AccountDTO in project AuthGuard by AuthGuard.
the class AccountsRoute method deactivate.
public void deactivate(final Context context) {
final String accountId = context.pathParam("id");
final Optional<AccountDTO> account = accountsService.deactivate(accountId).map(restMapper::toDTO);
if (account.isPresent()) {
context.status(200).json(account.get());
} else {
context.status(404).json(new Error("404", "No account with ID " + accountId + " exists"));
}
}
use of com.nexblocks.authguard.api.dto.entities.AccountDTO in project AuthGuard by AuthGuard.
the class AccountsRoute method patchAccount.
@Override
public void patchAccount(final Context context) {
final String accountId = context.pathParam("id");
final UpdateAccountRequestDTO request = updateAccountRequestBodyHandler.getValidated(context);
final Optional<AccountDTO> account = accountsService.patch(accountId, restMapper.toBO(request)).map(restMapper::toDTO);
if (account.isPresent()) {
context.status(200).json(account.get());
} else {
context.status(404).json(new Error(ErrorCode.ACCOUNT_DOES_NOT_EXIST.getCode(), "Account not found"));
}
}
use of com.nexblocks.authguard.api.dto.entities.AccountDTO in project AuthGuard by AuthGuard.
the class AccountsRoute method activate.
public void activate(final Context context) {
final String accountId = context.pathParam("id");
final Optional<AccountDTO> account = accountsService.activate(accountId).map(restMapper::toDTO);
if (account.isPresent()) {
context.status(200).json(account.get());
} else {
context.status(404).json(new Error("404", "No account with ID " + accountId + " exists"));
}
}
Aggregations