/*
 * DO NOT EDIT.
 *
 * Generated by the protocol buffer compiler.
 * Source: error.proto
 *
 */

import Foundation
import SwiftProtobuf


struct NetworkError: SwiftProtobuf.Message, SwiftProtobuf.Proto3Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf.ProtoNameProviding {
  public var swiftClassName: String {return "NetworkError"}
  public var protoMessageName: String {return "NetworkError"}
  public var protoPackageName: String {return ""}
  public static let _protobuf_fieldNames: FieldNameMap = [
    1: .same(proto: "code", swift: "code"),
    2: .same(proto: "message", swift: "message"),
  ]


  enum Code: SwiftProtobuf.Enum {
    typealias RawValue = Int

    ///   Unknown
    case unknown // = 0

    ///   400
    case badRequest // = 400
    case UNRECOGNIZED(Int)

    init() {
      self = .unknown
    }

    init?(rawValue: Int) {
      switch rawValue {
      case 0: self = .unknown
      case 400: self = .badRequest
      default: self = .UNRECOGNIZED(rawValue)
      }
    }

    init?(name: String) {
      switch name {
      case "unknown": self = .unknown
      case "badRequest": self = .badRequest
      default: return nil
      }
    }

    init?(jsonName: String) {
      switch jsonName {
      case "UNKNOWN": self = .unknown
      case "BAD_REQUEST": self = .badRequest
      default: return nil
      }
    }

    init?(protoName: String) {
      switch protoName {
      case "UNKNOWN": self = .unknown
      case "BAD_REQUEST": self = .badRequest
      default: return nil
      }
    }

    var rawValue: Int {
      get {
        switch self {
        case .unknown: return 0
        case .badRequest: return 400
        case .UNRECOGNIZED(let i): return i
        }
      }
    }

    var json: String {
      get {
        switch self {
        case .unknown: return "\"UNKNOWN\""
        case .badRequest: return "\"BAD_REQUEST\""
        case .UNRECOGNIZED(let i): return String(i)
        }
      }
    }

    var hashValue: Int { return rawValue }

    var debugDescription: String {
      get {
        switch self {
        case .unknown: return ".unknown"
        case .badRequest: return ".badRequest"
        case .UNRECOGNIZED(let v): return ".UNRECOGNIZED(\(v))"
        }
      }
    }

  }

  ///   Error code
  var code: NetworkError.Code = NetworkError.Code.unknown

  ///   Optional: Message
  var message: String = ""

  init() {}

  public mutating func _protoc_generated_decodeField(setter: inout SwiftProtobuf.FieldDecoder, protoFieldNumber: Int) throws {
    switch protoFieldNumber {
    case 1: try setter.decodeSingularField(fieldType: NetworkError.Code.self, value: &code)
    case 2: try setter.decodeSingularField(fieldType: SwiftProtobuf.ProtobufString.self, value: &message)
    default: break
    }
  }

  public func _protoc_generated_traverse(visitor: inout SwiftProtobuf.Visitor) throws {
    if code != NetworkError.Code.unknown {
      try visitor.visitSingularField(fieldType: NetworkError.Code.self, value: code, protoFieldNumber: 1)
    }
    if message != "" {
      try visitor.visitSingularField(fieldType: SwiftProtobuf.ProtobufString.self, value: message, protoFieldNumber: 2)
    }
  }

  public func _protoc_generated_isEqualTo(other: NetworkError) -> Bool {
    if code != other.code {return false}
    if message != other.message {return false}
    return true
  }
}
