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

import com.airlock.iam.core.misc.sms.SmsGateway;
import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.property.PluginProperty;
import com.airlock.iam.plugin.api.annotation.property.StringProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;

@Plugin(
   description = "<p>Enables the following SMS endpoints in the Adminapp REST API when configured:</p>\n<ul>\n<li><code>POST /&lt;adminapp-uri&gt;/rest/sms</code></li>\n<li><code>GET /&lt;adminapp-uri&gt;/rest/sms/&lt;messageId&gt;</code></li>\n</ul>\n<p>This permits sending SMS, as well as verifying the delivery status of a previously sent SMS using its identity.\nSee the Airlock IAM REST documentation for more information.</p>",
   displayName = "SMS Service"
)
public class SmsServiceConfig {
   @StringProperty(
      description = "The originator is displayed as the sender of the SMS on the recipient's phone. If configured, clients are not allowed to specify an originator in the request.",
      minLength = 1,
      maxLength = 16,
      optional = true
   )
   private String originator;
   @PluginProperty(description = "SMS gateway to use when sending an SMS and checking its delivery status.", displayName = "SMS Gateway", optional = false)
   private SmsGateway smsGateway;

   public Optional<String> getOriginator() {
      return Optional.ofNullable(this.originator);
   }

   public SmsGateway getSmsGateway() {
      return this.smsGateway;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public SmsServiceConfig(String originator, SmsGateway smsGateway) {
      this.originator = originator;
      this.smsGateway = smsGateway;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public static class SmsServiceConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String originator;
      @SuppressFBWarnings(justification = "generated code")
      private SmsGateway smsGateway;

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

      @SuppressFBWarnings(justification = "generated code")
      public SmsServiceConfig.SmsServiceConfigBuilder originator(String originator) {
         this.originator = originator;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public SmsServiceConfig.SmsServiceConfigBuilder smsGateway(SmsGateway smsGateway) {
         this.smsGateway = smsGateway;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public SmsServiceConfig build() {
         return new SmsServiceConfig(this.originator, this.smsGateway);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "SmsServiceConfig.SmsServiceConfigBuilder(originator=" + this.originator + ", smsGateway=" + this.smsGateway + ")";
      }
   }
}
