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

import com.airlock.iam.admin.api.application.configuration.event.AdminappDomainEventSubscriberConfig;
import com.airlock.iam.common.application.configuration.event.AdminappSubscribedEventConfig;
import com.airlock.iam.plugin.api.annotation.property.PluginProperty;
import com.google.common.annotations.VisibleForTesting;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public abstract class AdminappGeneralEventSubscriberConfig implements AdminappDomainEventSubscriberConfig {
   @VisibleForTesting
   protected static final String TEMPLATE_DESCRIPTION = "The following syntax can be used to include data in the template. <ul><li><tt>${contextDataName}</tt> for the value of <tt>contextDataName</tt> in the context-data of the managed user.</li><li><tt>${event.createdAt,date,format}</tt> for 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.addedRoles</tt> (list of strings)</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.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.crontoDeviceId</tt></li><li><tt>event.data.fidoCredentialId</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.newRoles</tt> (list of strings)</li><li><tt>event.data.oldEmailAddress</tt></li><li><tt>event.data.oldRoles</tt> (list of strings)</li><li><tt>event.data.previousAuthenticationMethod</tt></li><li><tt>event.data.removedRoles</tt> (list of strings)</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.adminId</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.";
   @PluginProperty(description = "The general Adminapp event about which the subscriber should be notified.", optional = false)
   private AdminappSubscribedEventConfig event;

   public AdminappGeneralEventSubscriberConfig(AdminappSubscribedEventConfig event) {
      this.event = event;
   }

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

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