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

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

export const protobufPackage = "protobuf";

export interface ExerciseOptionsRequest {
  orderId?: number | undefined;
  contract?: Contract | undefined;
  exerciseAction?: number | undefined;
  exerciseQuantity?: number | undefined;
  account?: string | undefined;
  override?: boolean | undefined;
  manualOrderTime?: string | undefined;
  customerAccount?: string | undefined;
  professionalCustomer?: boolean | undefined;
}

function createBaseExerciseOptionsRequest(): ExerciseOptionsRequest {
  return {
    orderId: undefined,
    contract: undefined,
    exerciseAction: undefined,
    exerciseQuantity: undefined,
    account: undefined,
    override: undefined,
    manualOrderTime: undefined,
    customerAccount: undefined,
    professionalCustomer: undefined,
  };
}

export const ExerciseOptionsRequest: MessageFns<ExerciseOptionsRequest> = {
  encode(message: ExerciseOptionsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.orderId !== undefined) {
      writer.uint32(8).int32(message.orderId);
    }
    if (message.contract !== undefined) {
      Contract.encode(message.contract, writer.uint32(18).fork()).join();
    }
    if (message.exerciseAction !== undefined) {
      writer.uint32(24).int32(message.exerciseAction);
    }
    if (message.exerciseQuantity !== undefined) {
      writer.uint32(32).int32(message.exerciseQuantity);
    }
    if (message.account !== undefined) {
      writer.uint32(42).string(message.account);
    }
    if (message.override !== undefined) {
      writer.uint32(48).bool(message.override);
    }
    if (message.manualOrderTime !== undefined) {
      writer.uint32(58).string(message.manualOrderTime);
    }
    if (message.customerAccount !== undefined) {
      writer.uint32(66).string(message.customerAccount);
    }
    if (message.professionalCustomer !== undefined) {
      writer.uint32(72).bool(message.professionalCustomer);
    }
    return writer;
  },

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

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

          message.contract = Contract.decode(reader, reader.uint32());
          continue;
        }
        case 3: {
          if (tag !== 24) {
            break;
          }

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

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

          message.account = reader.string();
          continue;
        }
        case 6: {
          if (tag !== 48) {
            break;
          }

          message.override = reader.bool();
          continue;
        }
        case 7: {
          if (tag !== 58) {
            break;
          }

          message.manualOrderTime = reader.string();
          continue;
        }
        case 8: {
          if (tag !== 66) {
            break;
          }

          message.customerAccount = reader.string();
          continue;
        }
        case 9: {
          if (tag !== 72) {
            break;
          }

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

  fromJSON(object: any): ExerciseOptionsRequest {
    return {
      orderId: isSet(object.orderId) ? globalThis.Number(object.orderId) : undefined,
      contract: isSet(object.contract) ? Contract.fromJSON(object.contract) : undefined,
      exerciseAction: isSet(object.exerciseAction) ? globalThis.Number(object.exerciseAction) : undefined,
      exerciseQuantity: isSet(object.exerciseQuantity) ? globalThis.Number(object.exerciseQuantity) : undefined,
      account: isSet(object.account) ? globalThis.String(object.account) : undefined,
      override: isSet(object.override) ? globalThis.Boolean(object.override) : undefined,
      manualOrderTime: isSet(object.manualOrderTime) ? globalThis.String(object.manualOrderTime) : undefined,
      customerAccount: isSet(object.customerAccount) ? globalThis.String(object.customerAccount) : undefined,
      professionalCustomer: isSet(object.professionalCustomer)
        ? globalThis.Boolean(object.professionalCustomer)
        : undefined,
    };
  },

  toJSON(message: ExerciseOptionsRequest): unknown {
    const obj: any = {};
    if (message.orderId !== undefined) {
      obj.orderId = Math.round(message.orderId);
    }
    if (message.contract !== undefined) {
      obj.contract = Contract.toJSON(message.contract);
    }
    if (message.exerciseAction !== undefined) {
      obj.exerciseAction = Math.round(message.exerciseAction);
    }
    if (message.exerciseQuantity !== undefined) {
      obj.exerciseQuantity = Math.round(message.exerciseQuantity);
    }
    if (message.account !== undefined) {
      obj.account = message.account;
    }
    if (message.override !== undefined) {
      obj.override = message.override;
    }
    if (message.manualOrderTime !== undefined) {
      obj.manualOrderTime = message.manualOrderTime;
    }
    if (message.customerAccount !== undefined) {
      obj.customerAccount = message.customerAccount;
    }
    if (message.professionalCustomer !== undefined) {
      obj.professionalCustomer = message.professionalCustomer;
    }
    return obj;
  },

  create(base?: DeepPartial<ExerciseOptionsRequest>): ExerciseOptionsRequest {
    return ExerciseOptionsRequest.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<ExerciseOptionsRequest>): ExerciseOptionsRequest {
    const message = createBaseExerciseOptionsRequest();
    message.orderId = object.orderId ?? undefined;
    message.contract = (object.contract !== undefined && object.contract !== null)
      ? Contract.fromPartial(object.contract)
      : undefined;
    message.exerciseAction = object.exerciseAction ?? undefined;
    message.exerciseQuantity = object.exerciseQuantity ?? undefined;
    message.account = object.account ?? undefined;
    message.override = object.override ?? undefined;
    message.manualOrderTime = object.manualOrderTime ?? undefined;
    message.customerAccount = object.customerAccount ?? undefined;
    message.professionalCustomer = object.professionalCustomer ?? 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 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;
}
