// Code generated by sidekick. DO NOT EDIT.
//
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation
import GoogleCloudWkt

/// The request message to annotate an Assessment.
public struct AnnotateAssessmentRequest: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Required. The resource name of the Assessment, in the format
  /// `projects/{project}/assessments/{assessment}`.
  public var name: Swift.String = Swift.String()

  /// Optional. The annotation that is assigned to the Event. This field can be
  /// left empty to provide reasons that apply to an event without concluding
  /// whether the event is legitimate or fraudulent.
  public var annotation: AnnotateAssessmentRequest.Annotation =
    AnnotateAssessmentRequest.Annotation()

  /// Optional. Reasons for the annotation that are assigned to the event.
  public var reasons: [AnnotateAssessmentRequest.Reason] = []

  /// Optional. A stable account identifier to apply to the assessment. This is
  /// an alternative to setting `account_id` in `CreateAssessment`, for example
  /// when a stable account identifier is not yet known in the initial request.
  public var accountId: Swift.String = Swift.String()

  /// Optional. A stable hashed account identifier to apply to the assessment.
  /// This is an alternative to setting `hashed_account_id` in
  /// `CreateAssessment`, for example when a stable account identifier is not yet
  /// known in the initial request.
  public var hashedAccountId: Foundation.Data = Foundation.Data()

  /// Optional. If the assessment is part of a payment transaction, provide
  /// details on payment lifecycle events that occur in the transaction.
  public var transactionEvent: TransactionEvent? = nil

  /// Optional. If using an external multi-factor authentication provider,
  /// provide phone authentication details for fraud detection purposes.
  public var phoneAuthenticationEvent: PhoneAuthenticationEvent? = nil

  /// Initialize a new instance of `AnnotateAssessmentRequest`.
  public init() {}

  /// Use `config` to return a new instance of this object, with some fields updated.
  ///
  /// Commonly used to initialize the value, for example:
  ///
  /// ```
  /// let value = AnnotateAssessmentRequest().with { $0.name = ... }
  /// ```
  public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
    var copy = self
    try config(&copy)
    return copy
  }

  /// Enum that represents the types of annotations.
  public enum Annotation: Codable, Equatable, Sendable {
    /// Default unspecified type.
    case unspecified
    /// Provides information that the event turned out to be legitimate.
    case legitimate
    /// Provides information that the event turned out to be fraudulent.
    case fraudulent
    /// Provides information that the event was related to a login event in which
    /// the user typed the correct password. Deprecated, prefer indicating
    /// CORRECT_PASSWORD through the reasons field instead.
    @available(*, deprecated)
    case passwordCorrect
    /// Provides information that the event was related to a login event in which
    /// the user typed the incorrect password. Deprecated, prefer indicating
    /// INCORRECT_PASSWORD through the reasons field instead.
    @available(*, deprecated)
    case passwordIncorrect
    /// Encodes an unknown integer value.
    ///
    /// The most common cause for an unknown values is for the service to send
    /// a value unknown to the library. We recommend you update your library to
    /// the latest version.
    case unknownIntValue(Int)
    /// Encodes an unknown string value.
    ///
    /// The most common cause for an unknown values is for the service to send
    /// a value unknown to the library. We recommend you update your library to
    /// the latest version.
    case unknownStringValue(String)

    public init() {
      self = .unspecified
    }

    /// Returns the integer value associated with the enumeration.
    ///
    /// If the enumeration was initialized with an unknown string value, this returns `nil`.
    public var intValue: Int? {
      switch self {
      case .unspecified: return 0
      case .legitimate: return 1
      case .fraudulent: return 2
      case .passwordCorrect: return 3
      case .passwordIncorrect: return 4
      case .unknownIntValue(let v): return v
      case .unknownStringValue: return nil
      }
    }

    /// Returns the string value (or name) associated with the enumeration.
    ///
    /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
    public var stringValue: Swift.String? {
      switch self {
      case .unspecified: return "ANNOTATION_UNSPECIFIED"
      case .legitimate: return "LEGITIMATE"
      case .fraudulent: return "FRAUDULENT"
      case .passwordCorrect: return "PASSWORD_CORRECT"
      case .passwordIncorrect: return "PASSWORD_INCORRECT"
      case .unknownIntValue: return nil
      case .unknownStringValue(let v): return v
      }
    }

    /// Initialize from a string value.
    ///
    /// If the value is unknown, this initializes to [`unknownStringValue`](doc:Annotation/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "ANNOTATION_UNSPECIFIED": self = .unspecified
      case "LEGITIMATE": self = .legitimate
      case "FRAUDULENT": self = .fraudulent
      case "PASSWORD_CORRECT": self = .passwordCorrect
      case "PASSWORD_INCORRECT": self = .passwordIncorrect
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Annotation/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .legitimate
      case 2: self = .fraudulent
      case 3: self = .passwordCorrect
      case 4: self = .passwordIncorrect
      default: self = .unknownIntValue(intValue)
      }
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.singleValueContainer()
      if let v = try? container.decode(Int.self) {
        self.init(intValue: v)
        return
      }
      if let s = try? container.decode(String.self) {
        if let v = Int(s) {
          self.init(intValue: v)
        } else {
          self.init(stringValue: s)
        }
        return
      }
      throw DecodingError.dataCorruptedError(
        in: container, debugDescription: "Expected enum value, must be integer or string.")
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.singleValueContainer()
      switch self {
      case .unspecified: return try container.encode(0)
      case .legitimate: return try container.encode(1)
      case .fraudulent: return try container.encode(2)
      case .passwordCorrect: return try container.encode(3)
      case .passwordIncorrect: return try container.encode(4)
      case .unknownIntValue(let v): return try container.encode(v)
      case .unknownStringValue(let v): return try container.encode(v)
      }
    }
  }

  /// Enum that represents potential reasons for annotating an assessment.
  public enum Reason: Codable, Equatable, Sendable {
    /// Unspecified reason. Do not use.
    case unspecified
    /// Indicates that the transaction had a chargeback issued with no other
    /// details. When possible, specify the type by using CHARGEBACK_FRAUD or
    /// CHARGEBACK_DISPUTE instead.
    case chargeback
    /// Indicates the transaction associated with the assessment is suspected of
    /// being fraudulent based on the payment method, billing details, shipping
    /// address or other transaction information.
    case paymentHeuristics
    /// Indicates that the user passed a 2FA challenge.
    case passedTwoFactor
    /// Indicates that the user failed a 2FA challenge.
    case failedTwoFactor
    /// Indicates the user provided the correct password.
    case correctPassword
    /// Indicates the user provided an incorrect password.
    case incorrectPassword
    /// Indicates that the user was served a 2FA challenge. An old assessment
    /// with `ENUM_VALUES.INITIATED_TWO_FACTOR` reason that has not been
    /// overwritten with `PASSED_TWO_FACTOR` is treated as an abandoned 2FA flow.
    /// This is equivalent to `FAILED_TWO_FACTOR`.
    case initiatedTwoFactor
    /// Indicates that the transaction had a chargeback issued related to an
    /// alleged unauthorized transaction from the cardholder's perspective (for
    /// example, the card number was stolen).
    case chargebackFraud
    /// Indicates that the transaction had a chargeback issued related to the
    /// cardholder having provided their card details but allegedly not being
    /// satisfied with the purchase (for example, misrepresentation, attempted
    /// cancellation).
    case chargebackDispute
    /// Indicates that the completed payment transaction was refunded by the
    /// seller.
    case refund
    /// Indicates that the completed payment transaction was determined to be
    /// fraudulent by the seller, and was cancelled and refunded as a result.
    case refundFraud
    /// Indicates that the payment transaction was accepted, and the user was
    /// charged.
    case transactionAccepted
    /// Indicates that the payment transaction was declined, for example due to
    /// invalid card details.
    case transactionDeclined
    /// Indicates that the user sent unwanted and abusive messages to other users
    /// of the platform, such as spam, scams, phishing, or social engineering.
    case socialSpam
    /// Encodes an unknown integer value.
    ///
    /// The most common cause for an unknown values is for the service to send
    /// a value unknown to the library. We recommend you update your library to
    /// the latest version.
    case unknownIntValue(Int)
    /// Encodes an unknown string value.
    ///
    /// The most common cause for an unknown values is for the service to send
    /// a value unknown to the library. We recommend you update your library to
    /// the latest version.
    case unknownStringValue(String)

    public init() {
      self = .unspecified
    }

    /// Returns the integer value associated with the enumeration.
    ///
    /// If the enumeration was initialized with an unknown string value, this returns `nil`.
    public var intValue: Int? {
      switch self {
      case .unspecified: return 0
      case .chargeback: return 1
      case .paymentHeuristics: return 2
      case .passedTwoFactor: return 3
      case .failedTwoFactor: return 4
      case .correctPassword: return 5
      case .incorrectPassword: return 6
      case .initiatedTwoFactor: return 7
      case .chargebackFraud: return 8
      case .chargebackDispute: return 9
      case .refund: return 10
      case .refundFraud: return 11
      case .transactionAccepted: return 12
      case .transactionDeclined: return 13
      case .socialSpam: return 14
      case .unknownIntValue(let v): return v
      case .unknownStringValue: return nil
      }
    }

    /// Returns the string value (or name) associated with the enumeration.
    ///
    /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
    public var stringValue: Swift.String? {
      switch self {
      case .unspecified: return "REASON_UNSPECIFIED"
      case .chargeback: return "CHARGEBACK"
      case .paymentHeuristics: return "PAYMENT_HEURISTICS"
      case .passedTwoFactor: return "PASSED_TWO_FACTOR"
      case .failedTwoFactor: return "FAILED_TWO_FACTOR"
      case .correctPassword: return "CORRECT_PASSWORD"
      case .incorrectPassword: return "INCORRECT_PASSWORD"
      case .initiatedTwoFactor: return "INITIATED_TWO_FACTOR"
      case .chargebackFraud: return "CHARGEBACK_FRAUD"
      case .chargebackDispute: return "CHARGEBACK_DISPUTE"
      case .refund: return "REFUND"
      case .refundFraud: return "REFUND_FRAUD"
      case .transactionAccepted: return "TRANSACTION_ACCEPTED"
      case .transactionDeclined: return "TRANSACTION_DECLINED"
      case .socialSpam: return "SOCIAL_SPAM"
      case .unknownIntValue: return nil
      case .unknownStringValue(let v): return v
      }
    }

    /// Initialize from a string value.
    ///
    /// If the value is unknown, this initializes to [`unknownStringValue`](doc:Reason/unknownStringValue(_:)).
    public init(stringValue: Swift.String) {
      switch stringValue {
      case "REASON_UNSPECIFIED": self = .unspecified
      case "CHARGEBACK": self = .chargeback
      case "CHARGEBACK_FRAUD": self = .chargebackFraud
      case "CHARGEBACK_DISPUTE": self = .chargebackDispute
      case "REFUND": self = .refund
      case "REFUND_FRAUD": self = .refundFraud
      case "TRANSACTION_ACCEPTED": self = .transactionAccepted
      case "TRANSACTION_DECLINED": self = .transactionDeclined
      case "PAYMENT_HEURISTICS": self = .paymentHeuristics
      case "INITIATED_TWO_FACTOR": self = .initiatedTwoFactor
      case "PASSED_TWO_FACTOR": self = .passedTwoFactor
      case "FAILED_TWO_FACTOR": self = .failedTwoFactor
      case "CORRECT_PASSWORD": self = .correctPassword
      case "INCORRECT_PASSWORD": self = .incorrectPassword
      case "SOCIAL_SPAM": self = .socialSpam
      default: self = .unknownStringValue(stringValue)
      }
    }

    /// Initialize from an integer value.
    ///
    /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Reason/unknownIntValue(_:)).
    public init(intValue: Int) {
      switch intValue {
      case 0: self = .unspecified
      case 1: self = .chargeback
      case 2: self = .paymentHeuristics
      case 3: self = .passedTwoFactor
      case 4: self = .failedTwoFactor
      case 5: self = .correctPassword
      case 6: self = .incorrectPassword
      case 7: self = .initiatedTwoFactor
      case 8: self = .chargebackFraud
      case 9: self = .chargebackDispute
      case 10: self = .refund
      case 11: self = .refundFraud
      case 12: self = .transactionAccepted
      case 13: self = .transactionDeclined
      case 14: self = .socialSpam
      default: self = .unknownIntValue(intValue)
      }
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.singleValueContainer()
      if let v = try? container.decode(Int.self) {
        self.init(intValue: v)
        return
      }
      if let s = try? container.decode(String.self) {
        if let v = Int(s) {
          self.init(intValue: v)
        } else {
          self.init(stringValue: s)
        }
        return
      }
      throw DecodingError.dataCorruptedError(
        in: container, debugDescription: "Expected enum value, must be integer or string.")
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.singleValueContainer()
      switch self {
      case .unspecified: return try container.encode(0)
      case .chargeback: return try container.encode(1)
      case .paymentHeuristics: return try container.encode(2)
      case .passedTwoFactor: return try container.encode(3)
      case .failedTwoFactor: return try container.encode(4)
      case .correctPassword: return try container.encode(5)
      case .incorrectPassword: return try container.encode(6)
      case .initiatedTwoFactor: return try container.encode(7)
      case .chargebackFraud: return try container.encode(8)
      case .chargebackDispute: return try container.encode(9)
      case .refund: return try container.encode(10)
      case .refundFraud: return try container.encode(11)
      case .transactionAccepted: return try container.encode(12)
      case .transactionDeclined: return try container.encode(13)
      case .socialSpam: return try container.encode(14)
      case .unknownIntValue(let v): return try container.encode(v)
      case .unknownStringValue(let v): return try container.encode(v)
      }
    }
  }

  public static var _anyTypeUrl: Swift.String {
    return "type.googleapis.com/google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest"
  }
  public init(fromAny any: GoogleCloudWkt.`Any`) throws {
    self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
  }
  public func _pack() throws -> GoogleCloudWkt.Struct {
    return try GoogleCloudWkt._slowAnySerialize(message: self)
  }
}
