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

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

export const protobufPackage = "protobuf";

export interface ApiSettingsConfig {
  readOnlyApi?: boolean | undefined;
  totalQuantityForMutualFunds?: boolean | undefined;
  downloadOpenOrdersOnConnection?: boolean | undefined;
  includeVirtualFxPositions?: boolean | undefined;
  prepareDailyPnL?: boolean | undefined;
  sendStatusUpdatesForVolatilityOrders?: boolean | undefined;
  encodeApiMessages?: string | undefined;
  socketPort?: number | undefined;
  useNegativeAutoRange?: boolean | undefined;
  createApiMessageLogFile?: boolean | undefined;
  includeMarketDataInLogFile?: boolean | undefined;
  exposeTradingScheduleToApi?: boolean | undefined;
  splitInsuredDepositFromCashBalance?: boolean | undefined;
  sendZeroPositionsForTodayOnly?: boolean | undefined;
  letApiAccountRequestsSwitchSubscription?: boolean | undefined;
  useAccountGroupsWithAllocationMethods?: boolean | undefined;
  loggingLevel?: string | undefined;
  masterClientId?: number | undefined;
  bulkDataTimeout?: number | undefined;
  componentExchSeparator?: string | undefined;
  showForexDataIn110Pips?: boolean | undefined;
  allowForexTradingIn110Pips?: boolean | undefined;
  roundAccountValuesToNearestWholeNumber?: boolean | undefined;
  sendMarketDataInLotsForUsStocks?: boolean | undefined;
  showAdvancedOrderRejectInUi?: boolean | undefined;
  rejectMessagesAboveMaxRate?: boolean | undefined;
  maintainConnectionOnIncorrectFields?: boolean | undefined;
  compatibilityModeNasdaqStocks?: boolean | undefined;
  sendInstrumentTimezone?: string | undefined;
  sendForexDataInCompatibilityMode?: boolean | undefined;
  maintainAndResubmitOrdersOnReconnect?: boolean | undefined;
  historicalDataMaxSize?: number | undefined;
  autoReportNettingEventContractTrades?: boolean | undefined;
  optionExerciseRequestType?: string | undefined;
  allowLocalhostOnly?: boolean | undefined;
  trustedIPs: string[];
}

function createBaseApiSettingsConfig(): ApiSettingsConfig {
  return {
    readOnlyApi: undefined,
    totalQuantityForMutualFunds: undefined,
    downloadOpenOrdersOnConnection: undefined,
    includeVirtualFxPositions: undefined,
    prepareDailyPnL: undefined,
    sendStatusUpdatesForVolatilityOrders: undefined,
    encodeApiMessages: undefined,
    socketPort: undefined,
    useNegativeAutoRange: undefined,
    createApiMessageLogFile: undefined,
    includeMarketDataInLogFile: undefined,
    exposeTradingScheduleToApi: undefined,
    splitInsuredDepositFromCashBalance: undefined,
    sendZeroPositionsForTodayOnly: undefined,
    letApiAccountRequestsSwitchSubscription: undefined,
    useAccountGroupsWithAllocationMethods: undefined,
    loggingLevel: undefined,
    masterClientId: undefined,
    bulkDataTimeout: undefined,
    componentExchSeparator: undefined,
    showForexDataIn110Pips: undefined,
    allowForexTradingIn110Pips: undefined,
    roundAccountValuesToNearestWholeNumber: undefined,
    sendMarketDataInLotsForUsStocks: undefined,
    showAdvancedOrderRejectInUi: undefined,
    rejectMessagesAboveMaxRate: undefined,
    maintainConnectionOnIncorrectFields: undefined,
    compatibilityModeNasdaqStocks: undefined,
    sendInstrumentTimezone: undefined,
    sendForexDataInCompatibilityMode: undefined,
    maintainAndResubmitOrdersOnReconnect: undefined,
    historicalDataMaxSize: undefined,
    autoReportNettingEventContractTrades: undefined,
    optionExerciseRequestType: undefined,
    allowLocalhostOnly: undefined,
    trustedIPs: [],
  };
}

export const ApiSettingsConfig: MessageFns<ApiSettingsConfig> = {
  encode(message: ApiSettingsConfig, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.readOnlyApi !== undefined) {
      writer.uint32(8).bool(message.readOnlyApi);
    }
    if (message.totalQuantityForMutualFunds !== undefined) {
      writer.uint32(16).bool(message.totalQuantityForMutualFunds);
    }
    if (message.downloadOpenOrdersOnConnection !== undefined) {
      writer.uint32(24).bool(message.downloadOpenOrdersOnConnection);
    }
    if (message.includeVirtualFxPositions !== undefined) {
      writer.uint32(32).bool(message.includeVirtualFxPositions);
    }
    if (message.prepareDailyPnL !== undefined) {
      writer.uint32(40).bool(message.prepareDailyPnL);
    }
    if (message.sendStatusUpdatesForVolatilityOrders !== undefined) {
      writer.uint32(48).bool(message.sendStatusUpdatesForVolatilityOrders);
    }
    if (message.encodeApiMessages !== undefined) {
      writer.uint32(58).string(message.encodeApiMessages);
    }
    if (message.socketPort !== undefined) {
      writer.uint32(64).int32(message.socketPort);
    }
    if (message.useNegativeAutoRange !== undefined) {
      writer.uint32(72).bool(message.useNegativeAutoRange);
    }
    if (message.createApiMessageLogFile !== undefined) {
      writer.uint32(80).bool(message.createApiMessageLogFile);
    }
    if (message.includeMarketDataInLogFile !== undefined) {
      writer.uint32(88).bool(message.includeMarketDataInLogFile);
    }
    if (message.exposeTradingScheduleToApi !== undefined) {
      writer.uint32(96).bool(message.exposeTradingScheduleToApi);
    }
    if (message.splitInsuredDepositFromCashBalance !== undefined) {
      writer.uint32(104).bool(message.splitInsuredDepositFromCashBalance);
    }
    if (message.sendZeroPositionsForTodayOnly !== undefined) {
      writer.uint32(112).bool(message.sendZeroPositionsForTodayOnly);
    }
    if (message.letApiAccountRequestsSwitchSubscription !== undefined) {
      writer.uint32(120).bool(message.letApiAccountRequestsSwitchSubscription);
    }
    if (message.useAccountGroupsWithAllocationMethods !== undefined) {
      writer.uint32(128).bool(message.useAccountGroupsWithAllocationMethods);
    }
    if (message.loggingLevel !== undefined) {
      writer.uint32(138).string(message.loggingLevel);
    }
    if (message.masterClientId !== undefined) {
      writer.uint32(144).int32(message.masterClientId);
    }
    if (message.bulkDataTimeout !== undefined) {
      writer.uint32(152).int32(message.bulkDataTimeout);
    }
    if (message.componentExchSeparator !== undefined) {
      writer.uint32(162).string(message.componentExchSeparator);
    }
    if (message.showForexDataIn110Pips !== undefined) {
      writer.uint32(168).bool(message.showForexDataIn110Pips);
    }
    if (message.allowForexTradingIn110Pips !== undefined) {
      writer.uint32(176).bool(message.allowForexTradingIn110Pips);
    }
    if (message.roundAccountValuesToNearestWholeNumber !== undefined) {
      writer.uint32(184).bool(message.roundAccountValuesToNearestWholeNumber);
    }
    if (message.sendMarketDataInLotsForUsStocks !== undefined) {
      writer.uint32(192).bool(message.sendMarketDataInLotsForUsStocks);
    }
    if (message.showAdvancedOrderRejectInUi !== undefined) {
      writer.uint32(200).bool(message.showAdvancedOrderRejectInUi);
    }
    if (message.rejectMessagesAboveMaxRate !== undefined) {
      writer.uint32(208).bool(message.rejectMessagesAboveMaxRate);
    }
    if (message.maintainConnectionOnIncorrectFields !== undefined) {
      writer.uint32(216).bool(message.maintainConnectionOnIncorrectFields);
    }
    if (message.compatibilityModeNasdaqStocks !== undefined) {
      writer.uint32(224).bool(message.compatibilityModeNasdaqStocks);
    }
    if (message.sendInstrumentTimezone !== undefined) {
      writer.uint32(234).string(message.sendInstrumentTimezone);
    }
    if (message.sendForexDataInCompatibilityMode !== undefined) {
      writer.uint32(240).bool(message.sendForexDataInCompatibilityMode);
    }
    if (message.maintainAndResubmitOrdersOnReconnect !== undefined) {
      writer.uint32(248).bool(message.maintainAndResubmitOrdersOnReconnect);
    }
    if (message.historicalDataMaxSize !== undefined) {
      writer.uint32(256).int32(message.historicalDataMaxSize);
    }
    if (message.autoReportNettingEventContractTrades !== undefined) {
      writer.uint32(264).bool(message.autoReportNettingEventContractTrades);
    }
    if (message.optionExerciseRequestType !== undefined) {
      writer.uint32(274).string(message.optionExerciseRequestType);
    }
    if (message.allowLocalhostOnly !== undefined) {
      writer.uint32(280).bool(message.allowLocalhostOnly);
    }
    for (const v of message.trustedIPs) {
      writer.uint32(290).string(v!);
    }
    return writer;
  },

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

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

          message.totalQuantityForMutualFunds = reader.bool();
          continue;
        }
        case 3: {
          if (tag !== 24) {
            break;
          }

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

          message.includeVirtualFxPositions = reader.bool();
          continue;
        }
        case 5: {
          if (tag !== 40) {
            break;
          }

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

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

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

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

          message.useNegativeAutoRange = reader.bool();
          continue;
        }
        case 10: {
          if (tag !== 80) {
            break;
          }

          message.createApiMessageLogFile = reader.bool();
          continue;
        }
        case 11: {
          if (tag !== 88) {
            break;
          }

          message.includeMarketDataInLogFile = reader.bool();
          continue;
        }
        case 12: {
          if (tag !== 96) {
            break;
          }

          message.exposeTradingScheduleToApi = reader.bool();
          continue;
        }
        case 13: {
          if (tag !== 104) {
            break;
          }

          message.splitInsuredDepositFromCashBalance = reader.bool();
          continue;
        }
        case 14: {
          if (tag !== 112) {
            break;
          }

          message.sendZeroPositionsForTodayOnly = reader.bool();
          continue;
        }
        case 15: {
          if (tag !== 120) {
            break;
          }

          message.letApiAccountRequestsSwitchSubscription = reader.bool();
          continue;
        }
        case 16: {
          if (tag !== 128) {
            break;
          }

          message.useAccountGroupsWithAllocationMethods = reader.bool();
          continue;
        }
        case 17: {
          if (tag !== 138) {
            break;
          }

          message.loggingLevel = reader.string();
          continue;
        }
        case 18: {
          if (tag !== 144) {
            break;
          }

          message.masterClientId = reader.int32();
          continue;
        }
        case 19: {
          if (tag !== 152) {
            break;
          }

          message.bulkDataTimeout = reader.int32();
          continue;
        }
        case 20: {
          if (tag !== 162) {
            break;
          }

          message.componentExchSeparator = reader.string();
          continue;
        }
        case 21: {
          if (tag !== 168) {
            break;
          }

          message.showForexDataIn110Pips = reader.bool();
          continue;
        }
        case 22: {
          if (tag !== 176) {
            break;
          }

          message.allowForexTradingIn110Pips = reader.bool();
          continue;
        }
        case 23: {
          if (tag !== 184) {
            break;
          }

          message.roundAccountValuesToNearestWholeNumber = reader.bool();
          continue;
        }
        case 24: {
          if (tag !== 192) {
            break;
          }

          message.sendMarketDataInLotsForUsStocks = reader.bool();
          continue;
        }
        case 25: {
          if (tag !== 200) {
            break;
          }

          message.showAdvancedOrderRejectInUi = reader.bool();
          continue;
        }
        case 26: {
          if (tag !== 208) {
            break;
          }

          message.rejectMessagesAboveMaxRate = reader.bool();
          continue;
        }
        case 27: {
          if (tag !== 216) {
            break;
          }

          message.maintainConnectionOnIncorrectFields = reader.bool();
          continue;
        }
        case 28: {
          if (tag !== 224) {
            break;
          }

          message.compatibilityModeNasdaqStocks = reader.bool();
          continue;
        }
        case 29: {
          if (tag !== 234) {
            break;
          }

          message.sendInstrumentTimezone = reader.string();
          continue;
        }
        case 30: {
          if (tag !== 240) {
            break;
          }

          message.sendForexDataInCompatibilityMode = reader.bool();
          continue;
        }
        case 31: {
          if (tag !== 248) {
            break;
          }

          message.maintainAndResubmitOrdersOnReconnect = reader.bool();
          continue;
        }
        case 32: {
          if (tag !== 256) {
            break;
          }

          message.historicalDataMaxSize = reader.int32();
          continue;
        }
        case 33: {
          if (tag !== 264) {
            break;
          }

          message.autoReportNettingEventContractTrades = reader.bool();
          continue;
        }
        case 34: {
          if (tag !== 274) {
            break;
          }

          message.optionExerciseRequestType = reader.string();
          continue;
        }
        case 35: {
          if (tag !== 280) {
            break;
          }

          message.allowLocalhostOnly = reader.bool();
          continue;
        }
        case 36: {
          if (tag !== 290) {
            break;
          }

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

  fromJSON(object: any): ApiSettingsConfig {
    return {
      readOnlyApi: isSet(object.readOnlyApi) ? globalThis.Boolean(object.readOnlyApi) : undefined,
      totalQuantityForMutualFunds: isSet(object.totalQuantityForMutualFunds)
        ? globalThis.Boolean(object.totalQuantityForMutualFunds)
        : undefined,
      downloadOpenOrdersOnConnection: isSet(object.downloadOpenOrdersOnConnection)
        ? globalThis.Boolean(object.downloadOpenOrdersOnConnection)
        : undefined,
      includeVirtualFxPositions: isSet(object.includeVirtualFxPositions)
        ? globalThis.Boolean(object.includeVirtualFxPositions)
        : undefined,
      prepareDailyPnL: isSet(object.prepareDailyPnL) ? globalThis.Boolean(object.prepareDailyPnL) : undefined,
      sendStatusUpdatesForVolatilityOrders: isSet(object.sendStatusUpdatesForVolatilityOrders)
        ? globalThis.Boolean(object.sendStatusUpdatesForVolatilityOrders)
        : undefined,
      encodeApiMessages: isSet(object.encodeApiMessages) ? globalThis.String(object.encodeApiMessages) : undefined,
      socketPort: isSet(object.socketPort) ? globalThis.Number(object.socketPort) : undefined,
      useNegativeAutoRange: isSet(object.useNegativeAutoRange)
        ? globalThis.Boolean(object.useNegativeAutoRange)
        : undefined,
      createApiMessageLogFile: isSet(object.createApiMessageLogFile)
        ? globalThis.Boolean(object.createApiMessageLogFile)
        : undefined,
      includeMarketDataInLogFile: isSet(object.includeMarketDataInLogFile)
        ? globalThis.Boolean(object.includeMarketDataInLogFile)
        : undefined,
      exposeTradingScheduleToApi: isSet(object.exposeTradingScheduleToApi)
        ? globalThis.Boolean(object.exposeTradingScheduleToApi)
        : undefined,
      splitInsuredDepositFromCashBalance: isSet(object.splitInsuredDepositFromCashBalance)
        ? globalThis.Boolean(object.splitInsuredDepositFromCashBalance)
        : undefined,
      sendZeroPositionsForTodayOnly: isSet(object.sendZeroPositionsForTodayOnly)
        ? globalThis.Boolean(object.sendZeroPositionsForTodayOnly)
        : undefined,
      letApiAccountRequestsSwitchSubscription: isSet(object.letApiAccountRequestsSwitchSubscription)
        ? globalThis.Boolean(object.letApiAccountRequestsSwitchSubscription)
        : undefined,
      useAccountGroupsWithAllocationMethods: isSet(object.useAccountGroupsWithAllocationMethods)
        ? globalThis.Boolean(object.useAccountGroupsWithAllocationMethods)
        : undefined,
      loggingLevel: isSet(object.loggingLevel) ? globalThis.String(object.loggingLevel) : undefined,
      masterClientId: isSet(object.masterClientId) ? globalThis.Number(object.masterClientId) : undefined,
      bulkDataTimeout: isSet(object.bulkDataTimeout) ? globalThis.Number(object.bulkDataTimeout) : undefined,
      componentExchSeparator: isSet(object.componentExchSeparator)
        ? globalThis.String(object.componentExchSeparator)
        : undefined,
      showForexDataIn110Pips: isSet(object.showForexDataIn110Pips)
        ? globalThis.Boolean(object.showForexDataIn110Pips)
        : isSet(object.showForexDataIn1_10Pips)
        ? globalThis.Boolean(object.showForexDataIn1_10Pips)
        : undefined,
      allowForexTradingIn110Pips: isSet(object.allowForexTradingIn110Pips)
        ? globalThis.Boolean(object.allowForexTradingIn110Pips)
        : isSet(object.allowForexTradingIn1_10Pips)
        ? globalThis.Boolean(object.allowForexTradingIn1_10Pips)
        : undefined,
      roundAccountValuesToNearestWholeNumber: isSet(object.roundAccountValuesToNearestWholeNumber)
        ? globalThis.Boolean(object.roundAccountValuesToNearestWholeNumber)
        : undefined,
      sendMarketDataInLotsForUsStocks: isSet(object.sendMarketDataInLotsForUsStocks)
        ? globalThis.Boolean(object.sendMarketDataInLotsForUsStocks)
        : undefined,
      showAdvancedOrderRejectInUi: isSet(object.showAdvancedOrderRejectInUi)
        ? globalThis.Boolean(object.showAdvancedOrderRejectInUi)
        : undefined,
      rejectMessagesAboveMaxRate: isSet(object.rejectMessagesAboveMaxRate)
        ? globalThis.Boolean(object.rejectMessagesAboveMaxRate)
        : undefined,
      maintainConnectionOnIncorrectFields: isSet(object.maintainConnectionOnIncorrectFields)
        ? globalThis.Boolean(object.maintainConnectionOnIncorrectFields)
        : undefined,
      compatibilityModeNasdaqStocks: isSet(object.compatibilityModeNasdaqStocks)
        ? globalThis.Boolean(object.compatibilityModeNasdaqStocks)
        : undefined,
      sendInstrumentTimezone: isSet(object.sendInstrumentTimezone)
        ? globalThis.String(object.sendInstrumentTimezone)
        : undefined,
      sendForexDataInCompatibilityMode: isSet(object.sendForexDataInCompatibilityMode)
        ? globalThis.Boolean(object.sendForexDataInCompatibilityMode)
        : undefined,
      maintainAndResubmitOrdersOnReconnect: isSet(object.maintainAndResubmitOrdersOnReconnect)
        ? globalThis.Boolean(object.maintainAndResubmitOrdersOnReconnect)
        : undefined,
      historicalDataMaxSize: isSet(object.historicalDataMaxSize)
        ? globalThis.Number(object.historicalDataMaxSize)
        : undefined,
      autoReportNettingEventContractTrades: isSet(object.autoReportNettingEventContractTrades)
        ? globalThis.Boolean(object.autoReportNettingEventContractTrades)
        : undefined,
      optionExerciseRequestType: isSet(object.optionExerciseRequestType)
        ? globalThis.String(object.optionExerciseRequestType)
        : undefined,
      allowLocalhostOnly: isSet(object.allowLocalhostOnly) ? globalThis.Boolean(object.allowLocalhostOnly) : undefined,
      trustedIPs: globalThis.Array.isArray(object?.trustedIPs)
        ? object.trustedIPs.map((e: any) => globalThis.String(e))
        : [],
    };
  },

  toJSON(message: ApiSettingsConfig): unknown {
    const obj: any = {};
    if (message.readOnlyApi !== undefined) {
      obj.readOnlyApi = message.readOnlyApi;
    }
    if (message.totalQuantityForMutualFunds !== undefined) {
      obj.totalQuantityForMutualFunds = message.totalQuantityForMutualFunds;
    }
    if (message.downloadOpenOrdersOnConnection !== undefined) {
      obj.downloadOpenOrdersOnConnection = message.downloadOpenOrdersOnConnection;
    }
    if (message.includeVirtualFxPositions !== undefined) {
      obj.includeVirtualFxPositions = message.includeVirtualFxPositions;
    }
    if (message.prepareDailyPnL !== undefined) {
      obj.prepareDailyPnL = message.prepareDailyPnL;
    }
    if (message.sendStatusUpdatesForVolatilityOrders !== undefined) {
      obj.sendStatusUpdatesForVolatilityOrders = message.sendStatusUpdatesForVolatilityOrders;
    }
    if (message.encodeApiMessages !== undefined) {
      obj.encodeApiMessages = message.encodeApiMessages;
    }
    if (message.socketPort !== undefined) {
      obj.socketPort = Math.round(message.socketPort);
    }
    if (message.useNegativeAutoRange !== undefined) {
      obj.useNegativeAutoRange = message.useNegativeAutoRange;
    }
    if (message.createApiMessageLogFile !== undefined) {
      obj.createApiMessageLogFile = message.createApiMessageLogFile;
    }
    if (message.includeMarketDataInLogFile !== undefined) {
      obj.includeMarketDataInLogFile = message.includeMarketDataInLogFile;
    }
    if (message.exposeTradingScheduleToApi !== undefined) {
      obj.exposeTradingScheduleToApi = message.exposeTradingScheduleToApi;
    }
    if (message.splitInsuredDepositFromCashBalance !== undefined) {
      obj.splitInsuredDepositFromCashBalance = message.splitInsuredDepositFromCashBalance;
    }
    if (message.sendZeroPositionsForTodayOnly !== undefined) {
      obj.sendZeroPositionsForTodayOnly = message.sendZeroPositionsForTodayOnly;
    }
    if (message.letApiAccountRequestsSwitchSubscription !== undefined) {
      obj.letApiAccountRequestsSwitchSubscription = message.letApiAccountRequestsSwitchSubscription;
    }
    if (message.useAccountGroupsWithAllocationMethods !== undefined) {
      obj.useAccountGroupsWithAllocationMethods = message.useAccountGroupsWithAllocationMethods;
    }
    if (message.loggingLevel !== undefined) {
      obj.loggingLevel = message.loggingLevel;
    }
    if (message.masterClientId !== undefined) {
      obj.masterClientId = Math.round(message.masterClientId);
    }
    if (message.bulkDataTimeout !== undefined) {
      obj.bulkDataTimeout = Math.round(message.bulkDataTimeout);
    }
    if (message.componentExchSeparator !== undefined) {
      obj.componentExchSeparator = message.componentExchSeparator;
    }
    if (message.showForexDataIn110Pips !== undefined) {
      obj.showForexDataIn110Pips = message.showForexDataIn110Pips;
    }
    if (message.allowForexTradingIn110Pips !== undefined) {
      obj.allowForexTradingIn110Pips = message.allowForexTradingIn110Pips;
    }
    if (message.roundAccountValuesToNearestWholeNumber !== undefined) {
      obj.roundAccountValuesToNearestWholeNumber = message.roundAccountValuesToNearestWholeNumber;
    }
    if (message.sendMarketDataInLotsForUsStocks !== undefined) {
      obj.sendMarketDataInLotsForUsStocks = message.sendMarketDataInLotsForUsStocks;
    }
    if (message.showAdvancedOrderRejectInUi !== undefined) {
      obj.showAdvancedOrderRejectInUi = message.showAdvancedOrderRejectInUi;
    }
    if (message.rejectMessagesAboveMaxRate !== undefined) {
      obj.rejectMessagesAboveMaxRate = message.rejectMessagesAboveMaxRate;
    }
    if (message.maintainConnectionOnIncorrectFields !== undefined) {
      obj.maintainConnectionOnIncorrectFields = message.maintainConnectionOnIncorrectFields;
    }
    if (message.compatibilityModeNasdaqStocks !== undefined) {
      obj.compatibilityModeNasdaqStocks = message.compatibilityModeNasdaqStocks;
    }
    if (message.sendInstrumentTimezone !== undefined) {
      obj.sendInstrumentTimezone = message.sendInstrumentTimezone;
    }
    if (message.sendForexDataInCompatibilityMode !== undefined) {
      obj.sendForexDataInCompatibilityMode = message.sendForexDataInCompatibilityMode;
    }
    if (message.maintainAndResubmitOrdersOnReconnect !== undefined) {
      obj.maintainAndResubmitOrdersOnReconnect = message.maintainAndResubmitOrdersOnReconnect;
    }
    if (message.historicalDataMaxSize !== undefined) {
      obj.historicalDataMaxSize = Math.round(message.historicalDataMaxSize);
    }
    if (message.autoReportNettingEventContractTrades !== undefined) {
      obj.autoReportNettingEventContractTrades = message.autoReportNettingEventContractTrades;
    }
    if (message.optionExerciseRequestType !== undefined) {
      obj.optionExerciseRequestType = message.optionExerciseRequestType;
    }
    if (message.allowLocalhostOnly !== undefined) {
      obj.allowLocalhostOnly = message.allowLocalhostOnly;
    }
    if (message.trustedIPs?.length) {
      obj.trustedIPs = message.trustedIPs;
    }
    return obj;
  },

  create(base?: DeepPartial<ApiSettingsConfig>): ApiSettingsConfig {
    return ApiSettingsConfig.fromPartial(base ?? {});
  },
  fromPartial(object: DeepPartial<ApiSettingsConfig>): ApiSettingsConfig {
    const message = createBaseApiSettingsConfig();
    message.readOnlyApi = object.readOnlyApi ?? undefined;
    message.totalQuantityForMutualFunds = object.totalQuantityForMutualFunds ?? undefined;
    message.downloadOpenOrdersOnConnection = object.downloadOpenOrdersOnConnection ?? undefined;
    message.includeVirtualFxPositions = object.includeVirtualFxPositions ?? undefined;
    message.prepareDailyPnL = object.prepareDailyPnL ?? undefined;
    message.sendStatusUpdatesForVolatilityOrders = object.sendStatusUpdatesForVolatilityOrders ?? undefined;
    message.encodeApiMessages = object.encodeApiMessages ?? undefined;
    message.socketPort = object.socketPort ?? undefined;
    message.useNegativeAutoRange = object.useNegativeAutoRange ?? undefined;
    message.createApiMessageLogFile = object.createApiMessageLogFile ?? undefined;
    message.includeMarketDataInLogFile = object.includeMarketDataInLogFile ?? undefined;
    message.exposeTradingScheduleToApi = object.exposeTradingScheduleToApi ?? undefined;
    message.splitInsuredDepositFromCashBalance = object.splitInsuredDepositFromCashBalance ?? undefined;
    message.sendZeroPositionsForTodayOnly = object.sendZeroPositionsForTodayOnly ?? undefined;
    message.letApiAccountRequestsSwitchSubscription = object.letApiAccountRequestsSwitchSubscription ?? undefined;
    message.useAccountGroupsWithAllocationMethods = object.useAccountGroupsWithAllocationMethods ?? undefined;
    message.loggingLevel = object.loggingLevel ?? undefined;
    message.masterClientId = object.masterClientId ?? undefined;
    message.bulkDataTimeout = object.bulkDataTimeout ?? undefined;
    message.componentExchSeparator = object.componentExchSeparator ?? undefined;
    message.showForexDataIn110Pips = object.showForexDataIn110Pips ?? undefined;
    message.allowForexTradingIn110Pips = object.allowForexTradingIn110Pips ?? undefined;
    message.roundAccountValuesToNearestWholeNumber = object.roundAccountValuesToNearestWholeNumber ?? undefined;
    message.sendMarketDataInLotsForUsStocks = object.sendMarketDataInLotsForUsStocks ?? undefined;
    message.showAdvancedOrderRejectInUi = object.showAdvancedOrderRejectInUi ?? undefined;
    message.rejectMessagesAboveMaxRate = object.rejectMessagesAboveMaxRate ?? undefined;
    message.maintainConnectionOnIncorrectFields = object.maintainConnectionOnIncorrectFields ?? undefined;
    message.compatibilityModeNasdaqStocks = object.compatibilityModeNasdaqStocks ?? undefined;
    message.sendInstrumentTimezone = object.sendInstrumentTimezone ?? undefined;
    message.sendForexDataInCompatibilityMode = object.sendForexDataInCompatibilityMode ?? undefined;
    message.maintainAndResubmitOrdersOnReconnect = object.maintainAndResubmitOrdersOnReconnect ?? undefined;
    message.historicalDataMaxSize = object.historicalDataMaxSize ?? undefined;
    message.autoReportNettingEventContractTrades = object.autoReportNettingEventContractTrades ?? undefined;
    message.optionExerciseRequestType = object.optionExerciseRequestType ?? undefined;
    message.allowLocalhostOnly = object.allowLocalhostOnly ?? undefined;
    message.trustedIPs = object.trustedIPs?.map((e) => e) || [];
    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;
}
