package com.airlock.iam.flow.shared.domain.model.airlock2fa;

import com.airlock.iam.base.api.domain.model.mapification.Mapifiable;
import com.airlock.iam.base.api.domain.model.mapification.MapifiedValues;
import com.airlock.iam.base.domain.model.mapification.MapifiedValuesBuilder;
import com.airlock.iam.factor.domain.model.airlock2fa.Airlock2FAMobileAuthUri;
import com.airlock.iam.factor.domain.model.airlock2fa.qrcode.Airlock2FAQrCodeImage;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public final class Airlock2FAOnlineQrCodeChallenge implements Mapifiable {
   private static final String CHALLENGE_IMAGE_KEY = "challengeImage";
   private static final String MOBILE_AUTH_URI_KEY = "mobileAuthUri";
   private final Airlock2FAQrCodeImage challengeImage;
   private final Airlock2FAMobileAuthUri mobileAuthUri;

   @Override
   public MapifiedValues mapify() {
      return MapifiedValuesBuilder.mapifiedValues()
         .put("challengeImage", this.challengeImage.getEncodedImage())
         .put("mobileAuthUri", this.mobileAuthUri.uri())
         .build();
   }

   public static Airlock2FAOnlineQrCodeChallenge demapify(MapifiedValues values) {
      return new Airlock2FAOnlineQrCodeChallenge(
         values.simpleValue("challengeImage", Airlock2FAQrCodeImage::new), values.simpleValue("mobileAuthUri", Airlock2FAMobileAuthUri::new)
      );
   }

   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FAOnlineQrCodeChallenge(Airlock2FAQrCodeImage challengeImage, Airlock2FAMobileAuthUri mobileAuthUri) {
      this.challengeImage = challengeImage;
      this.mobileAuthUri = mobileAuthUri;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public Airlock2FAMobileAuthUri getMobileAuthUri() {
      return this.mobileAuthUri;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "Airlock2FAOnlineQrCodeChallenge(challengeImage=" + this.getChallengeImage() + ", mobileAuthUri=" + this.getMobileAuthUri() + ")";
   }
}
