syntax = "proto2";

package maps_adv.geosmb.doorman.proto.events;

import "google/protobuf/timestamp.proto";
import "maps_adv/geosmb/doorman/proto/common.proto";


message AddEventInput {
    required uint64 biz_id = 1;
    required uint64 client_id = 2;
    required common.Source source = 3;
    required google.protobuf.Timestamp timestamp = 4;

    oneof event {
        OrderEvent order_event = 5;
        CallEvent call_event = 6;
    }
}

enum OrderEventType {
    CREATED = 1;
    REJECTED = 2;
    ACCEPTED = 3;
}

message OrderEvent {
    required OrderEventType type = 1;
    required uint64 order_id = 2;
}

message CallEvent {
    enum EventType {
        INITIATED = 1;
        FINISHED = 2;
    }
    required EventType type = 1;
    required uint64 session_id = 2;
    optional string value = 3;
}

message RetrieveClientCalls {
    required uint64 client_id = 1;
    required uint64 biz_id = 2;
    optional google.protobuf.Timestamp datetime_from = 3;
    optional google.protobuf.Timestamp datetime_to = 4;
}

message ClientHistory {
    repeated HistoryCallEvent calls = 1;
    required uint32 events_before = 2;
    required uint32 events_after = 3;
}

message HistoryCallEvent {
    enum EventType {
        INITIATED = 1;
        ACCEPTED = 2;
        MISSED = 3;
    }
    message AcceptedDetails {
        required uint32 talk_duration = 1;
    }
    message MissedDetails {
        required uint32 await_duration = 1;
    }

    required google.protobuf.Timestamp timestamp = 1;
    required common.Source source = 2;
    required EventType type = 3;
    oneof details {
        AcceptedDetails accepted_details = 4;
        MissedDetails missed_details = 5;
    }
}
