// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: speechly/analytics/v1/analytics_api.proto
//
// For information on using the generated types, please see the documentation:
//   https://github.com/apple/swift-protobuf/

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  typealias Version = _2
}

/// Includes keys for the UtteranceStatistics method.
/// If no keys are given, the token's project is used.
/// Token needs to have access to the given app / project.
public struct Speechly_Analytics_V1_UtteranceStatisticsRequest {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  /// Limit statistics to a single app_id.
  /// Default is none, returning statistics for all apps in the project.
  public var appID: String = String()

  /// Amount of days to include in the result.
  /// Default is 14 days.
  public var days: Int32 = 0

  /// Scope of returned data.
  /// Default is UTTERANCES.
  public var scope: Speechly_Analytics_V1_UtteranceStatisticsRequest.Scope = .invalid

  /// Aggregation of the data.
  /// Default is DAILY
  public var aggregation: Speechly_Analytics_V1_Aggregation = .invalid

  /// Start of requested statistics period.
  /// Default is 15 days ago.
  /// Must be YYYY-mm-DD formatted string if given.
  public var startDate: String = String()

  /// End of requested statistics period.
  /// Default is 1 day ago, resulting in two full weeks.
  /// Must be YYYY-mm-DD formatted string if given.
  public var endDate: String = String()

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  /// The scope of the returned items.
  public enum Scope: SwiftProtobuf.Enum {
    public typealias RawValue = Int
    case invalid // = 0

    /// Include only utterance data.
    case utterances // = 1

    /// Include annotated data.
    case annotations // = 2

    /// Include both utterance and annotated data.
    case all // = 3
    case UNRECOGNIZED(Int)

    public init() {
      self = .invalid
    }

    public init?(rawValue: Int) {
      switch rawValue {
      case 0: self = .invalid
      case 1: self = .utterances
      case 2: self = .annotations
      case 3: self = .all
      default: self = .UNRECOGNIZED(rawValue)
      }
    }

    public var rawValue: Int {
      switch self {
      case .invalid: return 0
      case .utterances: return 1
      case .annotations: return 2
      case .all: return 3
      case .UNRECOGNIZED(let i): return i
      }
    }

  }

  public init() {}
}

#if swift(>=4.2)

extension Speechly_Analytics_V1_UtteranceStatisticsRequest.Scope: CaseIterable {
  // The compiler won't synthesize support with the UNRECOGNIZED case.
  public static var allCases: [Speechly_Analytics_V1_UtteranceStatisticsRequest.Scope] = [
    .invalid,
    .utterances,
    .annotations,
    .all,
  ]
}

#endif  // swift(>=4.2)

/// Contains a list of statistics entries for utterances, based on the requested scope.
public struct Speechly_Analytics_V1_UtteranceStatisticsResponse {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  /// Start of this statistics period.
  /// YYYY-mm-DD formatted string.
  public var startDate: String = String()

  /// End of this statistics period.
  /// YYYY-mm-DD formatted string.
  public var endDate: String = String()

  /// Time period length.
  public var aggregation: Speechly_Analytics_V1_Aggregation = .invalid

  /// Aggregated results.
  public var items: [Speechly_Analytics_V1_UtteranceStatisticsPeriod] = []

  /// Amount of utterances in this response
  public var totalUtterances: Int32 = 0

  /// Total duration of utterances in seconds.
  public var totalDurationSeconds: Int32 = 0

  /// Total duration of annotated utterances in seconds.
  public var totalAnnotatedSeconds: Int32 = 0

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}
}

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "speechly.analytics.v1"

extension Speechly_Analytics_V1_UtteranceStatisticsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = _protobuf_package + ".UtteranceStatisticsRequest"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .standard(proto: "app_id"),
    2: .same(proto: "days"),
    3: .same(proto: "scope"),
    4: .same(proto: "aggregation"),
    5: .standard(proto: "start_date"),
    6: .standard(proto: "end_date"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularStringField(value: &self.appID) }()
      case 2: try { try decoder.decodeSingularInt32Field(value: &self.days) }()
      case 3: try { try decoder.decodeSingularEnumField(value: &self.scope) }()
      case 4: try { try decoder.decodeSingularEnumField(value: &self.aggregation) }()
      case 5: try { try decoder.decodeSingularStringField(value: &self.startDate) }()
      case 6: try { try decoder.decodeSingularStringField(value: &self.endDate) }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if !self.appID.isEmpty {
      try visitor.visitSingularStringField(value: self.appID, fieldNumber: 1)
    }
    if self.days != 0 {
      try visitor.visitSingularInt32Field(value: self.days, fieldNumber: 2)
    }
    if self.scope != .invalid {
      try visitor.visitSingularEnumField(value: self.scope, fieldNumber: 3)
    }
    if self.aggregation != .invalid {
      try visitor.visitSingularEnumField(value: self.aggregation, fieldNumber: 4)
    }
    if !self.startDate.isEmpty {
      try visitor.visitSingularStringField(value: self.startDate, fieldNumber: 5)
    }
    if !self.endDate.isEmpty {
      try visitor.visitSingularStringField(value: self.endDate, fieldNumber: 6)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: Speechly_Analytics_V1_UtteranceStatisticsRequest, rhs: Speechly_Analytics_V1_UtteranceStatisticsRequest) -> Bool {
    if lhs.appID != rhs.appID {return false}
    if lhs.days != rhs.days {return false}
    if lhs.scope != rhs.scope {return false}
    if lhs.aggregation != rhs.aggregation {return false}
    if lhs.startDate != rhs.startDate {return false}
    if lhs.endDate != rhs.endDate {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension Speechly_Analytics_V1_UtteranceStatisticsRequest.Scope: SwiftProtobuf._ProtoNameProviding {
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    0: .same(proto: "SCOPE_INVALID"),
    1: .same(proto: "SCOPE_UTTERANCES"),
    2: .same(proto: "SCOPE_ANNOTATIONS"),
    3: .same(proto: "SCOPE_ALL"),
  ]
}

extension Speechly_Analytics_V1_UtteranceStatisticsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = _protobuf_package + ".UtteranceStatisticsResponse"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .standard(proto: "start_date"),
    2: .standard(proto: "end_date"),
    3: .same(proto: "aggregation"),
    4: .same(proto: "items"),
    5: .standard(proto: "total_utterances"),
    6: .standard(proto: "total_duration_seconds"),
    7: .standard(proto: "total_annotated_seconds"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularStringField(value: &self.startDate) }()
      case 2: try { try decoder.decodeSingularStringField(value: &self.endDate) }()
      case 3: try { try decoder.decodeSingularEnumField(value: &self.aggregation) }()
      case 4: try { try decoder.decodeRepeatedMessageField(value: &self.items) }()
      case 5: try { try decoder.decodeSingularInt32Field(value: &self.totalUtterances) }()
      case 6: try { try decoder.decodeSingularInt32Field(value: &self.totalDurationSeconds) }()
      case 7: try { try decoder.decodeSingularInt32Field(value: &self.totalAnnotatedSeconds) }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if !self.startDate.isEmpty {
      try visitor.visitSingularStringField(value: self.startDate, fieldNumber: 1)
    }
    if !self.endDate.isEmpty {
      try visitor.visitSingularStringField(value: self.endDate, fieldNumber: 2)
    }
    if self.aggregation != .invalid {
      try visitor.visitSingularEnumField(value: self.aggregation, fieldNumber: 3)
    }
    if !self.items.isEmpty {
      try visitor.visitRepeatedMessageField(value: self.items, fieldNumber: 4)
    }
    if self.totalUtterances != 0 {
      try visitor.visitSingularInt32Field(value: self.totalUtterances, fieldNumber: 5)
    }
    if self.totalDurationSeconds != 0 {
      try visitor.visitSingularInt32Field(value: self.totalDurationSeconds, fieldNumber: 6)
    }
    if self.totalAnnotatedSeconds != 0 {
      try visitor.visitSingularInt32Field(value: self.totalAnnotatedSeconds, fieldNumber: 7)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: Speechly_Analytics_V1_UtteranceStatisticsResponse, rhs: Speechly_Analytics_V1_UtteranceStatisticsResponse) -> Bool {
    if lhs.startDate != rhs.startDate {return false}
    if lhs.endDate != rhs.endDate {return false}
    if lhs.aggregation != rhs.aggregation {return false}
    if lhs.items != rhs.items {return false}
    if lhs.totalUtterances != rhs.totalUtterances {return false}
    if lhs.totalDurationSeconds != rhs.totalDurationSeconds {return false}
    if lhs.totalAnnotatedSeconds != rhs.totalAnnotatedSeconds {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}
