package com.airlock.iam.login.application.configuration.event;

import com.airlock.iam.common.application.configuration.event.LoginappSubscribedEventConfig;
import com.airlock.iam.flow.api.application.configuration.valueprovider.ValueMapProviderConfig;
import com.airlock.iam.login.api.application.configuration.event.LoginappDomainEventSubscriberConfig;
import com.airlock.iam.plugin.api.annotation.property.PluginListProperty;
import com.airlock.iam.plugin.api.annotation.property.PluginProperty;
import com.google.common.annotations.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;

public abstract class LoginappGeneralEventSubscriberConfig implements LoginappDomainEventSubscriberConfig {
   @VisibleForTesting
   protected static final String TEMPLATE_DESCRIPTION = "The following syntax can be used to include data in the template. <ul><li><tt>${valueMapKey}</tt> for the value of <tt>valueMapKey</tt> provided by any of the configured Value Map Providers.</li><li><tt>${event.createdAt,date,format}</tt> to include the date/time at which the event was created, where \"format\" is a date pattern like \"yyyy-MM-dd HH:mm:ss\".</li></ul>Depending on the event and on the conditions in which the event originated, the following variables may also be available: <ul><li><tt>event.createdAt</tt></li><li><tt>event.data.airlock2FAAccountId</tt></li><li><tt>event.data.airlock2FADeviceId</tt></li><li><tt>event.data.activeAuthenticationMethod</tt></li><li><tt>event.data.authenticationMethods</tt></li><li><tt>event.data.browser</tt></li><li><tt>event.data.city</tt></li><li><tt>event.data.contextDataChanged.%s.newValue</tt> (where \"%s\" is replaced by the context-data field name).</li><li><tt>event.data.contextDataChanged.%s.oldValue</tt> (where \"%s\" is replaced by the context-data field name).</li><li><tt>event.data.countryCode</tt></li><li><tt>event.data.crontoDeviceId</tt></li><li><tt>event.data.device</tt></li><li><tt>event.data.deviceTokenId</tt></li><li><tt>event.data.fidoCredentialId</tt></li><li><tt>event.data.fidoPublicKeyCredentialId</tt></li><li><tt>event.data.oauth2.authorizationServerId</tt></li><li><tt>event.data.fidoRelyingPartyId</tt></li><li><tt>event.data.lockReason</tt></li><li><tt>event.data.mtanNewPhoneNumber</tt></li><li><tt>event.data.mtanNumberId</tt></li><li><tt>event.data.mtanOldPhoneNumber</tt></li><li><tt>event.data.newEmailAddress</tt></li><li><tt>event.data.oauth2.acceptedScopes</tt></li><li><tt>event.data.oauth2.alwaysGrantedScopes</tt></li><li><tt>event.data.oauth2.clientId</tt></li><li><tt>event.data.oauth2.deniedScopes</tt></li><li><tt>event.data.oldEmailAddress</tt></li><li><tt>event.data.operatingSystem</tt></li><li><tt>event.data.previousAuthenticationMethod</tt></li><li><tt>event.data.stepResult.attributes.&lt;attribute-name&gt;</tt> (where &lt;attribute-name&gt ist the name of the additional attribute, could be nested.)</li><li><tt>event.data.stepResult.errorCode</tt></li><li><tt>event.data.stepResult.nextAction</tt></li><li><tt>event.data.stepResult.type</tt></li><li><tt>event.data.userId</tt></li><li><tt>event.id</tt></li><li><tt>event.metadata.requestIp</tt></li><li><tt>event.metadata.userAgent</tt></li><li><tt>event.source.applicationId</tt></li><li><tt>event.source.configurationContext</tt></li><li><tt>event.source.flowId</tt></li><li><tt>event.source.stepId</tt></li></ul>Variables that are not defined are replaced by an empty string. The Airlock IAM documentation provides further information about the availability of specific variables.";
   @PluginListProperty(
      description = "Mappings that are used to replace the variables in the localized templates for the notification's content. The value map providers are called in the configured order and their values are added to a map. Later added values will overwrite earlier ones if they have the same key.",
      optional = true
   )
   private List<ValueMapProviderConfig> valueMapProviders;
   @PluginProperty(description = "The general Loginapp event about which the subscriber should be notified.", optional = false)
   private LoginappSubscribedEventConfig event;

   public LoginappGeneralEventSubscriberConfig(LoginappSubscribedEventConfig event, List<ValueMapProviderConfig> valueMapProviders) {
      this.event = event;
      this.valueMapProviders = valueMapProviders;
   }

   public LoginappSubscribedEventConfig getEvent() {
      return this.event;
   }

   public List<ValueMapProviderConfig> getValueMapProviders() {
      return this.valueMapProviders;
   }

   @SuppressFBWarnings(justification = "generated code")
   public LoginappGeneralEventSubscriberConfig() {
   }
}
