// @generated by protobuf-ts 2.9.6
// @generated from protobuf file "partner.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 { AttachmentSummary } from "./shared";
import { PartnerStatusStruct } from "./repositoryShared";
import { Address } from "./repositoryShared";
import { EntityID } from "./shared";
import { EventHeader } from "./shared";
// 
// Aggregation object message

/**
 * @generated from protobuf message api.Partner
 */
export interface Partner {
    /**
     * @generated from protobuf field: api.EventHeader LastEventHeader = 1 [json_name = "LastEventHeader"];
     */
    lastEventHeader?: EventHeader;
    /**
     * @generated from protobuf field: api.EntityID ID = 2 [json_name = "ID"];
     */
    iD?: EntityID;
    /**
     * @generated from protobuf field: api.PartnerPayload Payload = 3 [json_name = "Payload"];
     */
    payload?: PartnerPayload;
}
/**
 * @generated from protobuf message api.PartnerPayload
 */
export interface PartnerPayload {
    /**
     * @generated from protobuf field: string Name = 1 [json_name = "Name"];
     */
    name: string;
    /**
     * @generated from protobuf field: string LegalStructure = 2 [json_name = "LegalStructure"];
     */
    legalStructure: string;
    // repeated MetadataElement MetaData = 3 
    //    [
    //         (metadata) = true, (aggKey) = "Key" 
    //    ];

    /**
     * @generated from protobuf field: api.Address Address = 4 [json_name = "Address"];
     */
    address?: Address;
    /**
     * @generated from protobuf field: api.PartnerStatusStruct Status = 6 [json_name = "Status"];
     */
    status?: PartnerStatusStruct; // Status field is not accessible from APIs
    /**
     * @generated from protobuf field: string PhotoURI = 7 [json_name = "PhotoURI"];
     */
    photoURI: string;
    /**
     * @generated from protobuf field: repeated api.AttachmentSummary Attachments = 8 [json_name = "Attachments"];
     */
    attachments: AttachmentSummary[];
    /**
     * @generated from protobuf field: int32 AttachmentNumber = 9 [json_name = "AttachmentNumber"];
     */
    attachmentNumber: number;
    /**
     * @deprecated
     * @generated from protobuf field: repeated string AllowedRoles = 10 [deprecated = true, json_name = "AllowedRoles"];
     */
    allowedRoles: string[];
}
/**
 * @generated from protobuf message api.PartnerTriplet
 */
export interface PartnerTriplet {
    /**
     * @generated from protobuf field: api.Partner Current = 1 [json_name = "Current"];
     */
    current?: Partner;
    /**
     * @generated from protobuf field: api.Partner Previous = 2 [json_name = "Previous"];
     */
    previous?: Partner;
    /**
     * @generated from protobuf field: api.Partner LastEvent = 3 [json_name = "LastEvent"];
     */
    lastEvent?: Partner;
}
// @generated message type with reflection information, may provide speed optimized methods
class Partner$Type extends MessageType<Partner> {
    constructor() {
        super("api.Partner", [
            { no: 1, name: "LastEventHeader", kind: "message", jsonName: "LastEventHeader", T: () => EventHeader },
            { no: 2, name: "ID", kind: "message", jsonName: "ID", T: () => EntityID },
            { no: 3, name: "Payload", kind: "message", jsonName: "Payload", T: () => PartnerPayload }
        ]);
    }
    create(value?: PartialMessage<Partner>): Partner {
        const message = globalThis.Object.create((this.messagePrototype!));
        if (value !== undefined)
            reflectionMergePartial<Partner>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Partner): Partner {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.EventHeader LastEventHeader = 1 [json_name = "LastEventHeader"];*/ 1:
                    message.lastEventHeader = EventHeader.internalBinaryRead(reader, reader.uint32(), options, message.lastEventHeader);
                    break;
                case /* api.EntityID ID = 2 [json_name = "ID"];*/ 2:
                    message.iD = EntityID.internalBinaryRead(reader, reader.uint32(), options, message.iD);
                    break;
                case /* api.PartnerPayload Payload = 3 [json_name = "Payload"];*/ 3:
                    message.payload = PartnerPayload.internalBinaryRead(reader, reader.uint32(), options, message.payload);
                    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: Partner, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.EventHeader LastEventHeader = 1 [json_name = "LastEventHeader"]; */
        if (message.lastEventHeader)
            EventHeader.internalBinaryWrite(message.lastEventHeader, 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.PartnerPayload Payload = 3 [json_name = "Payload"]; */
        if (message.payload)
            PartnerPayload.internalBinaryWrite(message.payload, writer.tag(3, 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.Partner
 */
export const Partner = new Partner$Type();
// @generated message type with reflection information, may provide speed optimized methods
class PartnerPayload$Type extends MessageType<PartnerPayload> {
    constructor() {
        super("api.PartnerPayload", [
            { no: 1, name: "Name", kind: "scalar", jsonName: "Name", T: 9 /*ScalarType.STRING*/, options: { "api.dataRestrictionKey": "Movement,Executionflow,Handlingunit,Order,Item,Actor,Partner,Tracking", "api.kpiItems": { Items: [{ Context: "Actor", Group: "actor", Queryable: true }, { Context: "Stock", Group: "stock_extended", Queryable: true, CustomType: "SimpleAggregateFunction(anyLast,String)" }, { Context: "Executionflow", Group: "executionflow", Queryable: true }, { Context: "Handlingunit", Group: "handlingunit", Queryable: true }, { Context: "Order", Group: "order", Queryable: true }, { Context: "Partner", Group: "partner", Queryable: true }, { Context: "Tracking", Group: "tracking", Queryable: true }] } } },
            { no: 2, name: "LegalStructure", kind: "scalar", jsonName: "LegalStructure", T: 9 /*ScalarType.STRING*/ },
            { no: 4, name: "Address", kind: "message", jsonName: "Address", T: () => Address },
            { no: 6, name: "Status", kind: "message", jsonName: "Status", T: () => PartnerStatusStruct, options: { "validate.rules": { message: { unauthorized: true } }, "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { readOnly: true }, "api.enrichmentClear": "Tracking,Order,Executionflow" } },
            { no: 7, name: "PhotoURI", kind: "scalar", jsonName: "PhotoURI", T: 9 /*ScalarType.STRING*/, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { example: "\"https://reflex-visibility-forever.jpg\"" }, "api.viewType": { Types: [{ Context: "*", Type: "image" }] } } },
            { no: 8, name: "Attachments", kind: "message", jsonName: "Attachments", repeat: 1 /*RepeatType.PACKED*/, T: () => AttachmentSummary, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Number of attachments per type" }, "api.aggSkip": "AttachmentAdded,AttachmentRemoved", "api.enrichmentClear": "Tracking,Order,Executionflow" } },
            { no: 9, name: "AttachmentNumber", kind: "scalar", jsonName: "AttachmentNumber", T: 5 /*ScalarType.INT32*/, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Total number of attachments" }, "api.enrichmentClear": "Tracking,Order,Executionflow" } },
            { no: 10, name: "AllowedRoles", kind: "scalar", jsonName: "AllowedRoles", repeat: 2 /*RepeatType.UNPACKED*/, T: 9 /*ScalarType.STRING*/, options: { "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field": { description: "Deprecated since release 1.7. Roles allowed for these partner's users" }, "api.enrichmentClear": "Tracking,Order,Executionflow" } }
        ]);
    }
    create(value?: PartialMessage<PartnerPayload>): PartnerPayload {
        const message = globalThis.Object.create((this.messagePrototype!));
        message.name = "";
        message.legalStructure = "";
        message.photoURI = "";
        message.attachments = [];
        message.attachmentNumber = 0;
        message.allowedRoles = [];
        if (value !== undefined)
            reflectionMergePartial<PartnerPayload>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: PartnerPayload): PartnerPayload {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* string Name = 1 [json_name = "Name"];*/ 1:
                    message.name = reader.string();
                    break;
                case /* string LegalStructure = 2 [json_name = "LegalStructure"];*/ 2:
                    message.legalStructure = reader.string();
                    break;
                case /* api.Address Address = 4 [json_name = "Address"];*/ 4:
                    message.address = Address.internalBinaryRead(reader, reader.uint32(), options, message.address);
                    break;
                case /* api.PartnerStatusStruct Status = 6 [json_name = "Status"];*/ 6:
                    message.status = PartnerStatusStruct.internalBinaryRead(reader, reader.uint32(), options, message.status);
                    break;
                case /* string PhotoURI = 7 [json_name = "PhotoURI"];*/ 7:
                    message.photoURI = reader.string();
                    break;
                case /* repeated api.AttachmentSummary Attachments = 8 [json_name = "Attachments"];*/ 8:
                    message.attachments.push(AttachmentSummary.internalBinaryRead(reader, reader.uint32(), options));
                    break;
                case /* int32 AttachmentNumber = 9 [json_name = "AttachmentNumber"];*/ 9:
                    message.attachmentNumber = reader.int32();
                    break;
                case /* repeated string AllowedRoles = 10 [deprecated = true, json_name = "AllowedRoles"];*/ 10:
                    message.allowedRoles.push(reader.string());
                    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: PartnerPayload, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* string Name = 1 [json_name = "Name"]; */
        if (message.name !== "")
            writer.tag(1, WireType.LengthDelimited).string(message.name);
        /* string LegalStructure = 2 [json_name = "LegalStructure"]; */
        if (message.legalStructure !== "")
            writer.tag(2, WireType.LengthDelimited).string(message.legalStructure);
        /* api.Address Address = 4 [json_name = "Address"]; */
        if (message.address)
            Address.internalBinaryWrite(message.address, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
        /* api.PartnerStatusStruct Status = 6 [json_name = "Status"]; */
        if (message.status)
            PartnerStatusStruct.internalBinaryWrite(message.status, writer.tag(6, WireType.LengthDelimited).fork(), options).join();
        /* string PhotoURI = 7 [json_name = "PhotoURI"]; */
        if (message.photoURI !== "")
            writer.tag(7, WireType.LengthDelimited).string(message.photoURI);
        /* repeated api.AttachmentSummary Attachments = 8 [json_name = "Attachments"]; */
        for (let i = 0; i < message.attachments.length; i++)
            AttachmentSummary.internalBinaryWrite(message.attachments[i], writer.tag(8, WireType.LengthDelimited).fork(), options).join();
        /* int32 AttachmentNumber = 9 [json_name = "AttachmentNumber"]; */
        if (message.attachmentNumber !== 0)
            writer.tag(9, WireType.Varint).int32(message.attachmentNumber);
        /* repeated string AllowedRoles = 10 [deprecated = true, json_name = "AllowedRoles"]; */
        for (let i = 0; i < message.allowedRoles.length; i++)
            writer.tag(10, WireType.LengthDelimited).string(message.allowedRoles[i]);
        let u = options.writeUnknownFields;
        if (u !== false)
            (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
        return writer;
    }
}
/**
 * @generated MessageType for protobuf message api.PartnerPayload
 */
export const PartnerPayload = new PartnerPayload$Type();
// @generated message type with reflection information, may provide speed optimized methods
class PartnerTriplet$Type extends MessageType<PartnerTriplet> {
    constructor() {
        super("api.PartnerTriplet", [
            { no: 1, name: "Current", kind: "message", jsonName: "Current", T: () => Partner },
            { no: 2, name: "Previous", kind: "message", jsonName: "Previous", T: () => Partner },
            { no: 3, name: "LastEvent", kind: "message", jsonName: "LastEvent", T: () => Partner }
        ]);
    }
    create(value?: PartialMessage<PartnerTriplet>): PartnerTriplet {
        const message = globalThis.Object.create((this.messagePrototype!));
        if (value !== undefined)
            reflectionMergePartial<PartnerTriplet>(this, message, value);
        return message;
    }
    internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: PartnerTriplet): PartnerTriplet {
        let message = target ?? this.create(), end = reader.pos + length;
        while (reader.pos < end) {
            let [fieldNo, wireType] = reader.tag();
            switch (fieldNo) {
                case /* api.Partner Current = 1 [json_name = "Current"];*/ 1:
                    message.current = Partner.internalBinaryRead(reader, reader.uint32(), options, message.current);
                    break;
                case /* api.Partner Previous = 2 [json_name = "Previous"];*/ 2:
                    message.previous = Partner.internalBinaryRead(reader, reader.uint32(), options, message.previous);
                    break;
                case /* api.Partner LastEvent = 3 [json_name = "LastEvent"];*/ 3:
                    message.lastEvent = Partner.internalBinaryRead(reader, reader.uint32(), options, message.lastEvent);
                    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: PartnerTriplet, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
        /* api.Partner Current = 1 [json_name = "Current"]; */
        if (message.current)
            Partner.internalBinaryWrite(message.current, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
        /* api.Partner Previous = 2 [json_name = "Previous"]; */
        if (message.previous)
            Partner.internalBinaryWrite(message.previous, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
        /* api.Partner LastEvent = 3 [json_name = "LastEvent"]; */
        if (message.lastEvent)
            Partner.internalBinaryWrite(message.lastEvent, writer.tag(3, 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.PartnerTriplet
 */
export const PartnerTriplet = new PartnerTriplet$Type();
