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

import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.property.StringProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(
   description = "The recipient address for this email notification comes from a value from the event. The same keys as in the message templates can be used if the event does not provide the specified key or the value is not a valid email address, no email notification is sent.",
   displayName = "Recipient From Event Value"
)
public final class EventValueRecipientConfig
   implements EventEmailRecipientConfig.AdminappEventEmailRecipientConfig,
   EventEmailRecipientConfig.LoginappEventEmailRecipientConfig {
   @StringProperty(
      description = "The event message key that is used for the recipient address.",
      optional = false,
      suggestedValues = {"event.data.oldEmailAddress", "event.data.newEmailAddress"}
   )
   private String eventKey;

   public String getEventKey() {
      return this.eventKey;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static EventValueRecipientConfig.EventValueRecipientConfigBuilder builder() {
      return new EventValueRecipientConfig.EventValueRecipientConfigBuilder();
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public EventValueRecipientConfig(String eventKey) {
      this.eventKey = eventKey;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class EventValueRecipientConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String eventKey;

      @SuppressFBWarnings(justification = "generated code")
      EventValueRecipientConfigBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public EventValueRecipientConfig.EventValueRecipientConfigBuilder eventKey(String eventKey) {
         this.eventKey = eventKey;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public EventValueRecipientConfig build() {
         return new EventValueRecipientConfig(this.eventKey);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "EventValueRecipientConfig.EventValueRecipientConfigBuilder(eventKey=" + this.eventKey + ")";
      }
   }
}
