syntax = "proto2";

option go_package = "/openapi";

option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option java_package = "com.xtrader.protocol.proto.commons";
option java_outer_classname = "ContainerCommonMessages";

import "OpenApiCommonModelMessages.proto";

/** Base message that is used for all messages that are sent to/from Open API proxy of cTrader platform. */
message ProtoMessage {
    required uint32 payloadType = 1; // Contains id of ProtoPayloadType or other custom PayloadTypes (e.g. ProtoOAPayloadType).
    optional bytes payload = 2; // Serialized protobuf message that corresponds to payloadType.
    optional string clientMsgId = 3; // Request message id, assigned by the client that will be returned in the response.
}

/** Error response that is sent from Open API proxy when error occurs. */
message ProtoErrorRes {
    optional ProtoPayloadType payloadType = 1 [default = ERROR_RES];
    
    required string errorCode = 2; // Contains name of ProtoErrorCode or other custom ErrorCodes (e.g. ProtoCHErrorCode).
    optional string description = 3; // Error description.
    optional uint64 maintenanceEndTimestamp = 4; // The Unix time in milliseconds of the end of the maintenance.
}

/** Event that is sent from Open API proxy and can be used as criteria that connection is healthy when no other messages are sent by cTrader platform. Open API client can send this message when he needs to keep the connection open for a period without other messages longer than 30 seconds. */
message ProtoHeartbeatEvent {
    optional ProtoPayloadType payloadType = 1 [default = HEARTBEAT_EVENT];
}
