// @generated by protobuf-ts 2.9.6
// @generated from protobuf file "orderAction.proto" (package "api", syntax proto3)
// tslint:disable
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
import type { IBinaryWriter } from "@protobuf-ts/runtime";
import { WireType } from "@protobuf-ts/runtime";
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
import type { IBinaryReader } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import type { PartialMessage } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { EntityID } from "./shared";
import { CommandHeader } from "./shared";
import { OrderLine } from "./tradeShared";
import { OrderRequestedMilestones } from "./tradeShared";
import { TradeTier } from "./tradeShared";
import { MetadataElement } from "./shared";
import { ReferencedID } from "./tradeShared";
import { DateTime } from "./shared";
// Action Summary
//   - BuildExecutionflow :  Create Executionflow entity corresponding to Order (OMS stub)           > trade.executionflow.Created

/**
 *
 * Build Executionflow from Order
 *  This is the "OMS light". 1 Execution Flow for 1 Order if ShipFrom is defined
 *
 * @generated from protobuf message api.OrderBuildExecutionflowPayload
 */
export interface OrderBuildExecutionflowPayload {
    /**
     * @generated from protobuf field: api.DateTime CreationDateTime = 1 [json_name = "CreationDateTime"];
     */
    creationDateTime?: DateTime;
    /**
     * @generated from protobuf field: api.ReferencedID ParentOrder = 2 [json_name = "ParentOrder"];
     */
    parentOrder?: ReferencedID;
    /**
     * @generated from protobuf field: string LanguageCodeISO6391 = 3 [json_name = "LanguageCodeISO6391"];
     */
    languageCodeISO6391: string;
    /**
     * Metadata are characteristics specific to the project. They can be of several data form (string, integer, float, boolean or timestamp)
     *
     * @generated from protobuf field: repeated api.MetadataElement MetaData = 4 [json_name = "MetaData"];
     */
    metaData: MetadataElement[];
    /**
     * @generated from protobuf field: api.TradeTier Buyer = 5 [json_name = "Buyer"];
     */
    buyer?: TradeTier;
    /**
     * @generated from protobuf field: api.TradeTier Seller = 6 [json_name = "Seller"];
     */
    seller?: TradeTier;
    /**
     * Where to ship the order from
     *
     * @generated from protobuf field: api.TradeTier ShipFrom = 7 [json_name = "ShipFrom"];
     */
    shipFrom?: TradeTier;
    /**
     * Where to ship the order to
     *
     * @generated from protobuf field: api.TradeTier ShipTo = 8 [json_name = "ShipTo"];
     */
    shipTo?: TradeTier;
    /**
     * Definition of the order carrier
     *
     * @generated from protobuf field: api.TradeTier Carrier = 9 [json_name = "Carrier"];
     */
    carrier?: TradeTier;
    /**
     * Type of carrier service
     *
     * @generated from protobuf field: string CarrierService = 16 [json_name = "CarrierService"];
     */
    carrierService: string;
    /**
     * @generated from protobuf field: api.OrderRequestedMilestones RequestedMilestones = 10 [json_name = "RequestedMilestones"];
     */
    requestedMilestones?: OrderRequestedMilestones;
    /**
     * Lines of the order
     *
     * @generated from protobuf field: repeated api.OrderLine Lines = 11 [json_name = "Lines"];
     */
    lines: OrderLine[];
}
/**
 * @generated from protobuf message api.OrderBuildExecutionflow
 */
export interface OrderBuildExecutionflow {
    /**
     * @generated from protobuf field: api.CommandHeader Header = 1 [json_name = "Header"];
     */
    header?: CommandHeader;
    /**
     * @generated from protobuf field: api.EntityID ID = 2 [json_name = "ID"];
     */
    iD?: EntityID;
    /**
     * @generated from protobuf field: api.OrderBuildExecutionflowPayload Payload = 3 [json_name = "Payload"];
     */
    payload?: OrderBuildExecutionflowPayload;
    /**
     * @generated from protobuf field: api.OrderBuildExecutionflowPayload EventPayload = 4 [json_name = "EventPayload"];
     */
    eventPayload?: OrderBuildExecutionflowPayload;
    /**
     * @generated from protobuf field: api.OrderBuildExecutionflowPayload PreviousPayload = 5 [json_name = "PreviousPayload"];
     */
    previousPayload?: OrderBuildExecutionflowPayload;
}
// @generated message type with reflection information, may provide speed optimized methods
class OrderBuildExecutionflowPayload$Type extends MessageType<OrderBuildExecutionflowPayload> {
    constructor() {
        super("api.OrderBuildExecutionflowPayload", [
            { no: 1, name: "CreationDateTime", kind: "message", jsonName: "CreationDateTime", T: () => DateTime },
            { no: 2, name: "ParentOrder", kind: "message", jsonName: "ParentOrder", T: () => ReferencedID },
            { no: 3, name: "LanguageCodeISO6391", kind: "scalar", jsonName: "LanguageCodeISO6391", T: 9 /*ScalarType.STRING*/, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "<a href='https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes'>ISO 639 code</a> message language", example: "\"en\"" } } },
            { no: 4, name: "MetaData", kind: "message", jsonName: "MetaData", repeat: 1 /*RepeatType.PACKED*/, T: () => MetadataElement, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Metadata are characteristics specific to the project. They can be of several data form (string, integer, float, boolean or timestamp)" }, "api.metadata": true, "api.aggKey": "Key" } },
            { no: 5, name: "Buyer", kind: "message", jsonName: "Buyer", T: () => TradeTier },
            { no: 6, name: "Seller", kind: "message", jsonName: "Seller", T: () => TradeTier },
            { no: 7, name: "ShipFrom", kind: "message", jsonName: "ShipFrom", T: () => TradeTier, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Where to ship the order from" } } },
            { no: 8, name: "ShipTo", kind: "message", jsonName: "ShipTo", T: () => TradeTier, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Where to ship the order to" } } },
            { no: 9, name: "Carrier", kind: "message", jsonName: "Carrier", T: () => TradeTier, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Definition of the order carrier" } } },
            { no: 16, name: "CarrierService", kind: "scalar", jsonName: "CarrierService", T: 9 /*ScalarType.STRING*/, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Type of carrier service" } } },
            { no: 10, name: "RequestedMilestones", kind: "message", jsonName: "RequestedMilestones", T: () => OrderRequestedMilestones },
            { no: 11, name: "Lines", kind: "message", jsonName: "Lines", repeat: 1 /*RepeatType.PACKED*/, T: () => OrderLine, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Lines of the order" }, "api.aggKey": "LineID" } }
        ], { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema": { jsonSchema: { description: "Build Executionflow from Order" } }, "api.messageType": "Command", "api.payload": true, "api.action": "BuildExecutionflow" });
    }
    create(value?: PartialMessage<OrderBuildExecutionflowPayload>): OrderBuildExecutionflowPayload {
        const message = globalThis.Object.create((this.messagePrototype!));
        message.languageCodeISO6391 = "";
        message.metaData = [];
        message.carrierService = "";
        message.lines = [];
        if (value !== undefined)
            reflectionMergePartial<OrderBuildExecutionflowPayload>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: OrderBuildExecutionflowPayload): OrderBuildExecutionflowPayload {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.DateTime CreationDateTime = 1 [json_name = "CreationDateTime"];*/ 1:
                    message.creationDateTime = DateTime.internalBinaryRead(reader, reader.uint32(), options, message.creationDateTime);
                    break;
                case /* api.ReferencedID ParentOrder = 2 [json_name = "ParentOrder"];*/ 2:
                    message.parentOrder = ReferencedID.internalBinaryRead(reader, reader.uint32(), options, message.parentOrder);
                    break;
                case /* string LanguageCodeISO6391 = 3 [json_name = "LanguageCodeISO6391"];*/ 3:
                    message.languageCodeISO6391 = reader.string();
                    break;
                case /* repeated api.MetadataElement MetaData = 4 [json_name = "MetaData"];*/ 4:
                    message.metaData.push(MetadataElement.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                case /* api.TradeTier Buyer = 5 [json_name = "Buyer"];*/ 5:
                    message.buyer = TradeTier.internalBinaryRead(reader, reader.uint32(), options, message.buyer);
                    break;
                case /* api.TradeTier Seller = 6 [json_name = "Seller"];*/ 6:
                    message.seller = TradeTier.internalBinaryRead(reader, reader.uint32(), options, message.seller);
                    break;
                case /* api.TradeTier ShipFrom = 7 [json_name = "ShipFrom"];*/ 7:
                    message.shipFrom = TradeTier.internalBinaryRead(reader, reader.uint32(), options, message.shipFrom);
                    break;
                case /* api.TradeTier ShipTo = 8 [json_name = "ShipTo"];*/ 8:
                    message.shipTo = TradeTier.internalBinaryRead(reader, reader.uint32(), options, message.shipTo);
                    break;
                case /* api.TradeTier Carrier = 9 [json_name = "Carrier"];*/ 9:
                    message.carrier = TradeTier.internalBinaryRead(reader, reader.uint32(), options, message.carrier);
                    break;
                case /* string CarrierService = 16 [json_name = "CarrierService"];*/ 16:
                    message.carrierService = reader.string();
                    break;
                case /* api.OrderRequestedMilestones RequestedMilestones = 10 [json_name = "RequestedMilestones"];*/ 10:
                    message.requestedMilestones = OrderRequestedMilestones.internalBinaryRead(reader, reader.uint32(), options, message.requestedMilestones);
                    break;
                case /* repeated api.OrderLine Lines = 11 [json_name = "Lines"];*/ 11:
                    message.lines.push(OrderLine.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: OrderBuildExecutionflowPayload, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.DateTime CreationDateTime = 1 [json_name = "CreationDateTime"]; */
        if (message.creationDateTime)
            DateTime.internalBinaryWrite(message.creationDateTime, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* api.ReferencedID ParentOrder = 2 [json_name = "ParentOrder"]; */
        if (message.parentOrder)
            ReferencedID.internalBinaryWrite(message.parentOrder, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        /* string LanguageCodeISO6391 = 3 [json_name = "LanguageCodeISO6391"]; */
        if (message.languageCodeISO6391 !== "")
            writer.tag(3, WireType.LengthDelimited).string(message.languageCodeISO6391);
        /* repeated api.MetadataElement MetaData = 4 [json_name = "MetaData"]; */
        for (let i = 0; i < message.metaData.length; i++)
            MetadataElement.internalBinaryWrite(message.metaData[i], writer.tag(4, WireType.LengthDelimited).fork(), options).join();
        /* api.TradeTier Buyer = 5 [json_name = "Buyer"]; */
        if (message.buyer)
            TradeTier.internalBinaryWrite(message.buyer, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
        /* api.TradeTier Seller = 6 [json_name = "Seller"]; */
        if (message.seller)
            TradeTier.internalBinaryWrite(message.seller, writer.tag(6, WireType.LengthDelimited).fork(), options).join();
        /* api.TradeTier ShipFrom = 7 [json_name = "ShipFrom"]; */
        if (message.shipFrom)
            TradeTier.internalBinaryWrite(message.shipFrom, writer.tag(7, WireType.LengthDelimited).fork(), options).join();
        /* api.TradeTier ShipTo = 8 [json_name = "ShipTo"]; */
        if (message.shipTo)
            TradeTier.internalBinaryWrite(message.shipTo, writer.tag(8, WireType.LengthDelimited).fork(), options).join();
        /* api.TradeTier Carrier = 9 [json_name = "Carrier"]; */
        if (message.carrier)
            TradeTier.internalBinaryWrite(message.carrier, writer.tag(9, WireType.LengthDelimited).fork(), options).join();
        /* string CarrierService = 16 [json_name = "CarrierService"]; */
        if (message.carrierService !== "")
            writer.tag(16, WireType.LengthDelimited).string(message.carrierService);
        /* api.OrderRequestedMilestones RequestedMilestones = 10 [json_name = "RequestedMilestones"]; */
        if (message.requestedMilestones)
            OrderRequestedMilestones.internalBinaryWrite(message.requestedMilestones, writer.tag(10, WireType.LengthDelimited).fork(), options).join();
        /* repeated api.OrderLine Lines = 11 [json_name = "Lines"]; */
        for (let i = 0; i < message.lines.length; i++)
            OrderLine.internalBinaryWrite(message.lines[i], writer.tag(11, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.OrderBuildExecutionflowPayload
 */
export const OrderBuildExecutionflowPayload = new OrderBuildExecutionflowPayload$Type();
// @generated message type with reflection information, may provide speed optimized methods
class OrderBuildExecutionflow$Type extends MessageType<OrderBuildExecutionflow> {
    constructor() {
        super("api.OrderBuildExecutionflow", [
            { no: 1, name: "Header", kind: "message", jsonName: "Header", T: () => CommandHeader },
            { no: 2, name: "ID", kind: "message", jsonName: "ID", T: () => EntityID },
            { no: 3, name: "Payload", kind: "message", jsonName: "Payload", T: () => OrderBuildExecutionflowPayload },
            { no: 4, name: "EventPayload", kind: "message", jsonName: "EventPayload", T: () => OrderBuildExecutionflowPayload },
            { no: 5, name: "PreviousPayload", kind: "message", jsonName: "PreviousPayload", T: () => OrderBuildExecutionflowPayload }
        ], { "api.messageType": "Command", "api.action": "BuildExecutionflow", "api.resultingEvent": "executionflow.Created", "api.triggerEventFilters": "Created" });
    }
    create(value?: PartialMessage<OrderBuildExecutionflow>): OrderBuildExecutionflow {
        const message = globalThis.Object.create((this.messagePrototype!));
        if (value !== undefined)
            reflectionMergePartial<OrderBuildExecutionflow>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: OrderBuildExecutionflow): OrderBuildExecutionflow {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.CommandHeader Header = 1 [json_name = "Header"];*/ 1:
                    message.header = CommandHeader.internalBinaryRead(reader, reader.uint32(), options, message.header);
                    break;
                case /* api.EntityID ID = 2 [json_name = "ID"];*/ 2:
                    message.iD = EntityID.internalBinaryRead(reader, reader.uint32(), options, message.iD);
                    break;
                case /* api.OrderBuildExecutionflowPayload Payload = 3 [json_name = "Payload"];*/ 3:
                    message.payload = OrderBuildExecutionflowPayload.internalBinaryRead(reader, reader.uint32(), options, message.payload);
                    break;
                case /* api.OrderBuildExecutionflowPayload EventPayload = 4 [json_name = "EventPayload"];*/ 4:
                    message.eventPayload = OrderBuildExecutionflowPayload.internalBinaryRead(reader, reader.uint32(), options, message.eventPayload);
                    break;
                case /* api.OrderBuildExecutionflowPayload PreviousPayload = 5 [json_name = "PreviousPayload"];*/ 5:
                    message.previousPayload = OrderBuildExecutionflowPayload.internalBinaryRead(reader, reader.uint32(), options, message.previousPayload);
                    break;
                default:
                    let u = options.readUnknownField;
                    if (u === "throw")
                        throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
                    let d = reader.skip(wireType);
                    if (u !== false)
                        (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
            }
        }
        return message;
    }
    internalBinaryWrite(message: OrderBuildExecutionflow, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.CommandHeader Header = 1 [json_name = "Header"]; */
        if (message.header)
            CommandHeader.internalBinaryWrite(message.header, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* api.EntityID ID = 2 [json_name = "ID"]; */
        if (message.iD)
            EntityID.internalBinaryWrite(message.iD, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        /* api.OrderBuildExecutionflowPayload Payload = 3 [json_name = "Payload"]; */
        if (message.payload)
            OrderBuildExecutionflowPayload.internalBinaryWrite(message.payload, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
        /* api.OrderBuildExecutionflowPayload EventPayload = 4 [json_name = "EventPayload"]; */
        if (message.eventPayload)
            OrderBuildExecutionflowPayload.internalBinaryWrite(message.eventPayload, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
        /* api.OrderBuildExecutionflowPayload PreviousPayload = 5 [json_name = "PreviousPayload"]; */
        if (message.previousPayload)
            OrderBuildExecutionflowPayload.internalBinaryWrite(message.previousPayload, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.OrderBuildExecutionflow
 */
export const OrderBuildExecutionflow = new OrderBuildExecutionflow$Type();
