package com.airlock.iam.authentication.infrastructure.transfer.response;

import com.fasterxml.jackson.annotation.JsonTypeName;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.NonNull;

@JsonTypeName("authentication.cronto.challenge")
public final class CrontoChallengeData {
   public static final String CRONTO_CHALLENGE_TYPE = "authentication.cronto.challenge";
   @Schema(description = "Challenge image (cryptogram) in format \"image/png\" encoded into a base64 string.")
   @NonNull
   private final String challengeImage;
   @Schema(description = "The secure channel challenge (for use in app-to-app scenarios).")
   @NonNull
   private final String secureChannelChallenge;
   @Schema(description = "Indicates whether \"online validation\" is available (if true, the Cronto app can directly send the OTP to the server).")
   private final boolean onlineValidation;
   @Schema(description = "Indicates whether the challenge has been pushed directly to the device / Cronto app.")
   private final boolean pushed;
   @Schema(
      description = "Optional login ID that has been pushed to the device. Only set if the challenge has been pushed directly and login ID generation is enabled."
   )
   private final String pushLoginId;
   @ArraySchema(arraySchema = @Schema(description = "Contains information about the device if the challenge has been pushed."))
   private final List<CrontoChallengeData.CrontoChallengePushDeviceData> pushDevices;

   @SuppressFBWarnings(justification = "generated code")
   CrontoChallengeData(
      @NonNull String challengeImage,
      @NonNull String secureChannelChallenge,
      boolean onlineValidation,
      boolean pushed,
      String pushLoginId,
      List<CrontoChallengeData.CrontoChallengePushDeviceData> pushDevices
   ) {
      if (challengeImage == null) {
         throw new NullPointerException("challengeImage is marked non-null but is null");
      }

      if (secureChannelChallenge == null) {
         throw new NullPointerException("secureChannelChallenge is marked non-null but is null");
      }

      this.challengeImage = challengeImage;
      this.secureChannelChallenge = secureChannelChallenge;
      this.onlineValidation = onlineValidation;
      this.pushed = pushed;
      this.pushLoginId = pushLoginId;
      this.pushDevices = pushDevices;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof CrontoChallengeData other)) {
         return false;
      } else {
         if (this.onlineValidation != other.onlineValidation) {
            return false;
         }

         if (this.pushed != other.pushed) {
            return false;
         }

         Object this$challengeImage = this.challengeImage;
         Object other$challengeImage = other.challengeImage;
         if (this$challengeImage == null ? other$challengeImage == null : this$challengeImage.equals(other$challengeImage)) {
            Object this$secureChannelChallenge = this.secureChannelChallenge;
            Object other$secureChannelChallenge = other.secureChannelChallenge;
            if (this$secureChannelChallenge == null ? other$secureChannelChallenge == null : this$secureChannelChallenge.equals(other$secureChannelChallenge)) {
               Object this$pushLoginId = this.pushLoginId;
               Object other$pushLoginId = other.pushLoginId;
               if (this$pushLoginId == null ? other$pushLoginId == null : this$pushLoginId.equals(other$pushLoginId)) {
                  Object this$pushDevices = this.pushDevices;
                  Object other$pushDevices = other.pushDevices;
                  return this$pushDevices == null ? other$pushDevices == null : this$pushDevices.equals(other$pushDevices);
               } else {
                  return false;
               }
            } else {
               return false;
            }
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      result = result * 59 + (this.onlineValidation ? 79 : 97);
      result = result * 59 + (this.pushed ? 79 : 97);
      Object $challengeImage = this.challengeImage;
      result = result * 59 + ($challengeImage == null ? 43 : $challengeImage.hashCode());
      Object $secureChannelChallenge = this.secureChannelChallenge;
      result = result * 59 + ($secureChannelChallenge == null ? 43 : $secureChannelChallenge.hashCode());
      Object $pushLoginId = this.pushLoginId;
      result = result * 59 + ($pushLoginId == null ? 43 : $pushLoginId.hashCode());
      Object $pushDevices = this.pushDevices;
      return result * 59 + ($pushDevices == null ? 43 : $pushDevices.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "CrontoChallengeData(challengeImage="
         + this.getChallengeImage()
         + ", secureChannelChallenge="
         + this.getSecureChannelChallenge()
         + ", onlineValidation="
         + this.isOnlineValidation()
         + ", pushed="
         + this.isPushed()
         + ", pushLoginId="
         + this.getPushLoginId()
         + ", pushDevices="
         + this.getPushDevices()
         + ")";
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public String getChallengeImage() {
      return this.challengeImage;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public String getSecureChannelChallenge() {
      return this.secureChannelChallenge;
   }

   @SuppressFBWarnings(justification = "generated code")
   public boolean isOnlineValidation() {
      return this.onlineValidation;
   }

   @SuppressFBWarnings(justification = "generated code")
   public boolean isPushed() {
      return this.pushed;
   }

   @SuppressFBWarnings(justification = "generated code")
   public String getPushLoginId() {
      return this.pushLoginId;
   }

   @SuppressFBWarnings(justification = "generated code")
   public List<CrontoChallengeData.CrontoChallengePushDeviceData> getPushDevices() {
      return this.pushDevices;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class CrontoChallengeDataBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String challengeImage;
      @SuppressFBWarnings(justification = "generated code")
      private String secureChannelChallenge;
      @SuppressFBWarnings(justification = "generated code")
      private boolean onlineValidation;
      @SuppressFBWarnings(justification = "generated code")
      private boolean pushed;
      @SuppressFBWarnings(justification = "generated code")
      private String pushLoginId;
      @SuppressFBWarnings(justification = "generated code")
      private List<CrontoChallengeData.CrontoChallengePushDeviceData> pushDevices;

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

      @SuppressFBWarnings(justification = "generated code")
      public CrontoChallengeData.CrontoChallengeDataBuilder challengeImage(@NonNull String challengeImage) {
         if (challengeImage == null) {
            throw new NullPointerException("challengeImage is marked non-null but is null");
         }

         this.challengeImage = challengeImage;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public CrontoChallengeData.CrontoChallengeDataBuilder secureChannelChallenge(@NonNull String secureChannelChallenge) {
         if (secureChannelChallenge == null) {
            throw new NullPointerException("secureChannelChallenge is marked non-null but is null");
         }

         this.secureChannelChallenge = secureChannelChallenge;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public CrontoChallengeData.CrontoChallengeDataBuilder onlineValidation(boolean onlineValidation) {
         this.onlineValidation = onlineValidation;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public CrontoChallengeData.CrontoChallengeDataBuilder pushed(boolean pushed) {
         this.pushed = pushed;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public CrontoChallengeData.CrontoChallengeDataBuilder pushLoginId(String pushLoginId) {
         this.pushLoginId = pushLoginId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public CrontoChallengeData.CrontoChallengeDataBuilder pushDevices(List<CrontoChallengeData.CrontoChallengePushDeviceData> pushDevices) {
         this.pushDevices = pushDevices;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public CrontoChallengeData build() {
         return new CrontoChallengeData(
            this.challengeImage, this.secureChannelChallenge, this.onlineValidation, this.pushed, this.pushLoginId, this.pushDevices
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "CrontoChallengeData.CrontoChallengeDataBuilder(challengeImage="
            + this.challengeImage
            + ", secureChannelChallenge="
            + this.secureChannelChallenge
            + ", onlineValidation="
            + this.onlineValidation
            + ", pushed="
            + this.pushed
            + ", pushLoginId="
            + this.pushLoginId
            + ", pushDevices="
            + this.pushDevices
            + ")";
      }
   }

   public static final class CrontoChallengePushDeviceData {
      @Schema(description = "The device ID.")
      @NonNull
      private final String id;
      @Schema(description = "Optional label of the push device.")
      private final String label;
      @Schema(description = "The device platform. One of 'IOS' or 'ANDROID'.")
      private final String platform;

      @SuppressFBWarnings(justification = "generated code")
      CrontoChallengePushDeviceData(@NonNull String id, String label, String platform) {
         if (id == null) {
            throw new NullPointerException("id is marked non-null but is null");
         }

         this.id = id;
         this.label = label;
         this.platform = platform;
      }

      @SuppressFBWarnings(justification = "generated code")
      public static CrontoChallengeData.CrontoChallengePushDeviceData.CrontoChallengePushDeviceDataBuilder builder() {
         return new CrontoChallengeData.CrontoChallengePushDeviceData.CrontoChallengePushDeviceDataBuilder();
      }

      @NonNull
      @SuppressFBWarnings(justification = "generated code")
      public String getId() {
         return this.id;
      }

      @SuppressFBWarnings(justification = "generated code")
      public String getLabel() {
         return this.label;
      }

      @SuppressFBWarnings(justification = "generated code")
      public String getPlatform() {
         return this.platform;
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public boolean equals(Object o) {
         if (o == this) {
            return true;
         } else if (!(o instanceof CrontoChallengeData.CrontoChallengePushDeviceData other)) {
            return false;
         } else {
            Object this$id = this.id;
            Object other$id = other.id;
            if (this$id == null ? other$id == null : this$id.equals(other$id)) {
               Object this$label = this.label;
               Object other$label = other.label;
               if (this$label == null ? other$label == null : this$label.equals(other$label)) {
                  Object this$platform = this.platform;
                  Object other$platform = other.platform;
                  return this$platform == null ? other$platform == null : this$platform.equals(other$platform);
               } else {
                  return false;
               }
            } else {
               return false;
            }
         }
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public int hashCode() {
         int PRIME = 59;
         int result = 1;
         Object $id = this.id;
         result = result * 59 + ($id == null ? 43 : $id.hashCode());
         Object $label = this.label;
         result = result * 59 + ($label == null ? 43 : $label.hashCode());
         Object $platform = this.platform;
         return result * 59 + ($platform == null ? 43 : $platform.hashCode());
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "CrontoChallengeData.CrontoChallengePushDeviceData(id="
            + this.getId()
            + ", label="
            + this.getLabel()
            + ", platform="
            + this.getPlatform()
            + ")";
      }

      @SuppressFBWarnings(justification = "generated code")
      public static class CrontoChallengePushDeviceDataBuilder {
         @SuppressFBWarnings(justification = "generated code")
         private String id;
         @SuppressFBWarnings(justification = "generated code")
         private String label;
         @SuppressFBWarnings(justification = "generated code")
         private String platform;

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

         @SuppressFBWarnings(justification = "generated code")
         public CrontoChallengeData.CrontoChallengePushDeviceData.CrontoChallengePushDeviceDataBuilder id(@NonNull String id) {
            if (id == null) {
               throw new NullPointerException("id is marked non-null but is null");
            }

            this.id = id;
            return this;
         }

         @SuppressFBWarnings(justification = "generated code")
         public CrontoChallengeData.CrontoChallengePushDeviceData.CrontoChallengePushDeviceDataBuilder label(String label) {
            this.label = label;
            return this;
         }

         @SuppressFBWarnings(justification = "generated code")
         public CrontoChallengeData.CrontoChallengePushDeviceData.CrontoChallengePushDeviceDataBuilder platform(String platform) {
            this.platform = platform;
            return this;
         }

         @SuppressFBWarnings(justification = "generated code")
         public CrontoChallengeData.CrontoChallengePushDeviceData build() {
            return new CrontoChallengeData.CrontoChallengePushDeviceData(this.id, this.label, this.platform);
         }

         @SuppressFBWarnings(justification = "generated code")
         @Override
         public String toString() {
            return "CrontoChallengeData.CrontoChallengePushDeviceData.CrontoChallengePushDeviceDataBuilder(id="
               + this.id
               + ", label="
               + this.label
               + ", platform="
               + this.platform
               + ")";
         }
      }
   }
}
