// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.5
//   protoc               v7.34.1
// source: ErrorMessage.proto

/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";

export const protobufPackage = "protobuf";

export interface ErrorMessage {
  id?: number | undefined;
  errorTime?: number | undefined;
  errorCode?: number | undefined;
  errorMsg?: string | undefined;
  advancedOrderRejectJson?: string | undefined;
}

function createBaseErrorMessage(): ErrorMessage {
  return {
    id: undefined,
    errorTime: undefined,
    errorCode: undefined,
    errorMsg: undefined,
    advancedOrderRejectJson: undefined,
  };
}

export const ErrorMessage: MessageFns<ErrorMessage> = {
  encode(message: ErrorMessage, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.id !== undefined) {
      writer.uint32(8).int32(message.id);
    }
    if (message.errorTime !== undefined) {
      writer.uint32(16).int64(message.errorTime);
    }
    if (message.errorCode !== undefined) {
      writer.uint32(24).int32(message.errorCode);
    }
    if (message.errorMsg !== undefined) {
      writer.uint32(34).string(message.errorMsg);
    }
    if (message.advancedOrderRejectJson !== undefined) {
      writer.uint32(42).string(message.advancedOrderRejectJson);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): ErrorMessage {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    const end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseErrorMessage();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 8) {
            break;
          }

          message.id = reader.int32();
          continue;
        }
        case 2: {
          if (tag !== 16) {
            break;
          }

          message.errorTime = longToNumber(reader.int64());
          continue;
        }
        case 3: {
          if (tag !== 24) {
            break;
          }

          message.errorCode = reader.int32();
          continue;
        }
        case 4: {
          if (tag !== 34) {
            break;
          }

          message.errorMsg = reader.string();
          continue;
        }
        case 5: {
          if (tag !== 42) {
            break;
          }

          message.advancedOrderRejectJson = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): ErrorMessage {
    return {
      id: isSet(object.id) ? globalThis.Number(object.id) : undefined,
      errorTime: isSet(object.errorTime) ? globalThis.Number(object.errorTime) : undefined,
      errorCode: isSet(object.errorCode) ? globalThis.Number(object.errorCode) : undefined,
      errorMsg: isSet(object.errorMsg) ? globalThis.String(object.errorMsg) : undefined,
      advancedOrderRejectJson: isSet(object.advancedOrderRejectJson)
        ? globalThis.String(object.advancedOrderRejectJson)
        : undefined,
    };
  },

  toJSON(message: ErrorMessage): unknown {
    const obj: any = {};
    if (message.id !== undefined) {
      obj.id = Math.round(message.id);
    }
    if (message.errorTime !== undefined) {
      obj.errorTime = Math.round(message.errorTime);
    }
    if (message.errorCode !== undefined) {
      obj.errorCode = Math.round(message.errorCode);
    }
    if (message.errorMsg !== undefined) {
      obj.errorMsg = message.errorMsg;
    }
    if (message.advancedOrderRejectJson !== undefined) {
      obj.advancedOrderRejectJson = message.advancedOrderRejectJson;
    }
    return obj;
  },

  create(base?: DeepPartial<ErrorMessage>): ErrorMessage {
    return ErrorMessage.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<ErrorMessage>): ErrorMessage {
    const message = createBaseErrorMessage();
    message.id = object.id ?? undefined;
    message.errorTime = object.errorTime ?? undefined;
    message.errorCode = object.errorCode ?? undefined;
    message.errorMsg = object.errorMsg ?? undefined;
    message.advancedOrderRejectJson = object.advancedOrderRejectJson ?? undefined;
    return message;
  },
};

type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;

export type DeepPartial<T> = T extends Builtin ? T
  : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
  : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;

function longToNumber(int64: { toString(): string }): number {
  const num = globalThis.Number(int64.toString());
  if (num > globalThis.Number.MAX_SAFE_INTEGER) {
    throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
  }
  if (num < globalThis.Number.MIN_SAFE_INTEGER) {
    throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
  }
  return num;
}

function isSet(value: any): boolean {
  return value !== null && value !== undefined;
}

export interface MessageFns<T> {
  encode(message: T, writer?: BinaryWriter): BinaryWriter;
  decode(input: BinaryReader | Uint8Array, length?: number): T;
  fromJSON(object: any): T;
  toJSON(message: T): unknown;
  create(base?: DeepPartial<T>): T;
  fromPartial(object: DeepPartial<T>): T;
}
