com.onegini.sdk.model.config.v2.notifications.EmailNotificationConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of idp-sdk Show documentation
Show all versions of idp-sdk Show documentation
Java SDK to connect to the Onegini platform
/*
* Copyright 2013-2020 Onegini b.v.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.onegini.sdk.model.config.v2.notifications;
import java.util.Optional;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class EmailNotificationConfiguration {
@JsonProperty("administrator_account_blocked")
private Boolean administratorAccountBlocked;
@JsonProperty("configuration_error_for_account_linking")
private Boolean configurationErrorForAccountLinking;
@JsonProperty("validation_of_id_card_completed")
private Boolean validationOfIdCardCompleted;
@JsonProperty("validation_of_id_card_failed")
private Boolean validationOfIdCardFailed;
@JsonProperty("account_invitation")
private Boolean accountInvitation;
@JsonProperty("identity_coupled_to_account")
private Boolean identityCoupledToAccount;
@JsonProperty("password_blocked")
private Boolean passwordBlocked;
@JsonProperty("password_reset")
private Boolean passwordReset;
@JsonProperty("password_reset_for_account_without_password")
private Boolean passwordResetForAccountWithoutPassword;
@JsonProperty("account_removed")
private Boolean accountRemoved;
@JsonProperty("step_up_authentication")
private Boolean stepUpAuthentication;
@JsonProperty("pin_reset")
private Boolean pinReset;
@JsonProperty("email_verification")
private EmailVerification emailVerification;
@JsonProperty("welcome")
private Welcome welcome;
@JsonProperty("attributes_update")
private AttributesUpdate attributesUpdate;
@JsonIgnore
public Optional getByType(final NotificationType notification) {
switch (notification) {
case ADMIN_BLOCKED:
return Optional.ofNullable(getAdministratorAccountBlocked());
case SUPPORT_NOTIFICATION:
return Optional.ofNullable(getConfigurationErrorForAccountLinking());
case INVITATION:
return Optional.ofNullable(getAccountInvitation());
case LINKED_IDPS:
return Optional.ofNullable(getIdentityCoupledToAccount());
case PASSWORD_BLOCKED:
return Optional.ofNullable(getPasswordBlocked());
case PASSWORD_RESET:
return Optional.ofNullable(getPasswordReset());
case PASSWORD_RESET_NO_PASSWORD:
return Optional.ofNullable(getPasswordResetForAccountWithoutPassword());
case PERSON_REMOVED:
return Optional.ofNullable(getAccountRemoved());
case STEP_UP:
return Optional.ofNullable(getStepUpAuthentication());
case TEMP_PIN:
return Optional.ofNullable(getPinReset());
case VERIFICATION:
return Optional.ofNullable(getEmailVerification())
.map(EmailVerification::getOnWebEnabled);
case VERIFICATION_API:
return Optional.ofNullable(getEmailVerification())
.map(EmailVerification::getOnApiEnabled);
case WELCOME_EMAIL:
return Optional.ofNullable(getWelcome())
.map(Welcome::getOnWebEnabled);
case WELCOME_EMAIL_API:
return Optional.ofNullable(getWelcome())
.map(Welcome::getOnApiEnabled);
case WELCOME_EMAIL_MIGRATION:
return Optional.ofNullable(getWelcome())
.map(Welcome::getOnMigrationEnabled);
case NOTIFICATION_ACCOUNT_UPDATE_ALL:
return Optional.ofNullable(getAttributesUpdate())
.map(AttributesUpdate::getOnAllUpdated);
case NOTIFICATION_ACCOUNT_UPDATE_EMAIL:
return Optional.ofNullable(getAttributesUpdate())
.map(AttributesUpdate::getOnEmailUpdated);
case NOTIFICATION_ACCOUNT_UPDATE_PASSWORD:
return Optional.ofNullable(getAttributesUpdate())
.map(AttributesUpdate::getOnPasswordUpdated);
case NOTIFICATION_ACCOUNT_UPDATE_MOBILE_PHONE:
return Optional.ofNullable(getAttributesUpdate())
.map(AttributesUpdate::getOnPhoneNumberUpdated);
default:
throw new IllegalArgumentException(String.format("Cannot get value by type %s", notification));
}
}
@SuppressWarnings("java:S3776")
@JsonIgnore
public void setByType(final NotificationType notification, final boolean value) {
switch (notification) {
case ADMIN_BLOCKED:
setAdministratorAccountBlocked(value);
break;
case SUPPORT_NOTIFICATION:
setConfigurationErrorForAccountLinking(value);
break;
case INVITATION:
setAccountInvitation(value);
break;
case LINKED_IDPS:
setIdentityCoupledToAccount(value);
break;
case PASSWORD_BLOCKED:
setPasswordBlocked(value);
break;
case PASSWORD_RESET:
setPasswordReset(value);
break;
case PASSWORD_RESET_NO_PASSWORD:
setPasswordResetForAccountWithoutPassword(value);
break;
case PERSON_REMOVED:
setAccountRemoved(value);
break;
case STEP_UP:
setStepUpAuthentication(value);
break;
case TEMP_PIN:
setPinReset(value);
break;
case VERIFICATION:
if (getEmailVerification() == null) {
setEmailVerification(new EmailVerification());
}
getEmailVerification().setOnWebEnabled(value);
break;
case VERIFICATION_API:
if (getEmailVerification() == null) {
setEmailVerification(new EmailVerification());
}
getEmailVerification().setOnApiEnabled(value);
break;
case WELCOME_EMAIL:
if (getWelcome() == null) {
setWelcome(new Welcome());
}
getWelcome().setOnWebEnabled(value);
break;
case WELCOME_EMAIL_API:
if (getWelcome() == null) {
setWelcome(new Welcome());
}
getWelcome().setOnApiEnabled(value);
break;
case WELCOME_EMAIL_MIGRATION:
if (getWelcome() == null) {
setWelcome(new Welcome());
}
getWelcome().setOnMigrationEnabled(value);
break;
case NOTIFICATION_ACCOUNT_UPDATE_ALL:
if (getAttributesUpdate() == null) {
setAttributesUpdate(new AttributesUpdate());
}
getAttributesUpdate().setOnAllUpdated(value);
break;
case NOTIFICATION_ACCOUNT_UPDATE_EMAIL:
if (getAttributesUpdate() == null) {
setAttributesUpdate(new AttributesUpdate());
}
getAttributesUpdate().setOnEmailUpdated(value);
break;
case NOTIFICATION_ACCOUNT_UPDATE_PASSWORD:
if (getAttributesUpdate() == null) {
setAttributesUpdate(new AttributesUpdate());
}
getAttributesUpdate().setOnPasswordUpdated(value);
break;
case NOTIFICATION_ACCOUNT_UPDATE_MOBILE_PHONE:
if (getAttributesUpdate() == null) {
setAttributesUpdate(new AttributesUpdate());
}
getAttributesUpdate().setOnPhoneNumberUpdated(value);
break;
default:
throw new IllegalArgumentException(String.format("Cannot set value by type %s", notification));
}
}
}