package com.airlock.iam.publicselfservice.infrastructure.transfer;

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 jakarta.validation.constraints.NotNull;
import java.util.List;

@JsonTypeName("public-self-service.approval.cronto.challenge")
public final class PublicSelfServiceCrontoChallengeData {
   public static final String CRONTO_CHALLENGE_TYPE = "public-self-service.approval.cronto.challenge";
   @NotNull
   @Schema(description = "Challenge image (cryptogram) in format \"image/png\" encoded into a base64 string.")
   private final String challengeImage;
   @NotNull
   @Schema(description = "The secure channel challenge (for use in app-to-app scenarios).")
   private final String secureChannelChallenge;
   @NotNull
   @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;
   @NotNull
   @Schema(description = "Indicates whether the challenge has been pushed directly to the device / Cronto app.")
   private final boolean pushed;
   @ArraySchema(arraySchema = @Schema(description = "Contains information about the device if the challenge has been pushed."))
   private final List<PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData> pushDevices;

   @SuppressFBWarnings(justification = "generated code")
   PublicSelfServiceCrontoChallengeData(
      String challengeImage,
      String secureChannelChallenge,
      boolean onlineValidation,
      boolean pushed,
      List<PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData> pushDevices
   ) {
      this.challengeImage = challengeImage;
      this.secureChannelChallenge = secureChannelChallenge;
      this.onlineValidation = onlineValidation;
      this.pushed = pushed;
      this.pushDevices = pushDevices;
   }

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

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

   @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 List<PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData> getPushDevices() {
      return this.pushDevices;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof PublicSelfServiceCrontoChallengeData 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$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;
         }
      }
   }

   @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 $pushDevices = this.pushDevices;
      return result * 59 + ($pushDevices == null ? 43 : $pushDevices.hashCode());
   }

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

   public static final class CrontoPushDeviceData {
      @NotNull
      @Schema(description = "The device ID.")
      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")
      CrontoPushDeviceData(String id, String label, String platform) {
         this.id = id;
         this.label = label;
         this.platform = platform;
      }

      @SuppressFBWarnings(justification = "generated code")
      public static PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData.CrontoPushDeviceDataBuilder builder() {
         return new PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData.CrontoPushDeviceDataBuilder();
      }

      @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 PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData 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 "PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData(id="
            + this.getId()
            + ", label="
            + this.getLabel()
            + ", platform="
            + this.getPlatform()
            + ")";
      }

      @SuppressFBWarnings(justification = "generated code")
      public static class CrontoPushDeviceDataBuilder {
         @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")
         CrontoPushDeviceDataBuilder() {
         }

         @SuppressFBWarnings(justification = "generated code")
         public PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData.CrontoPushDeviceDataBuilder id(String id) {
            this.id = id;
            return this;
         }

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

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

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

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

   @SuppressFBWarnings(justification = "generated code")
   public static class PublicSelfServiceCrontoChallengeDataBuilder {
      @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 List<PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData> pushDevices;

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

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

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

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

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

      @SuppressFBWarnings(justification = "generated code")
      public PublicSelfServiceCrontoChallengeData.PublicSelfServiceCrontoChallengeDataBuilder pushDevices(
         List<PublicSelfServiceCrontoChallengeData.CrontoPushDeviceData> pushDevices
      ) {
         this.pushDevices = pushDevices;
         return this;
      }

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

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