syntax = "proto2";

package maps_adv.geosmb.promoter.proto.leads;


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

enum Source {
    UNKNOWN = 0;
    EXTERNAL_ADVERT = 1;
    STRAIGHT = 2;
    DISCOVERY_ADVERT = 3;
    DISCOVERY_NO_ADVERT = 4;
}

message ListLeadsInput {
    required uint64 biz_id = 1;
    required maps_adv.geosmb.proto.common.Pagination pagination = 2;
    optional OrderBy order_by = 3;
    optional segments.SegmentType filter_by_segment = 4;
}

message RetrieveLeadInput {
    required uint64 biz_id = 1;
    required uint64 lead_id = 2;
}


message ListLeadsOutput {
    required uint32 total_count = 1;
    repeated Lead leads = 2;
}

message Lead {
    required uint64 lead_id = 1;
    required uint64 biz_id = 2;
    required string name = 3;
    required Statistics statistics = 4;
    repeated segments.SegmentType segments = 5;
    optional Source source = 6;
}

message OrderBy {
    enum OrderField {
        NAME = 1;
        MAKE_ROUTES = 2;
        REVIEW_RATING = 3;
        CLICKS_ON_PHONE = 4;
        SITE_OPENS = 5;
        LAST_ACTIVITY_TIMESTAMP = 6;
        VIEW_WORKING_HOURS = 7;
        VIEW_ENTRANCES = 8;
        CTA_BUTTON_CLICK = 9;
        FAVOURITE_CLICK = 10;
        LOCATION_SHARING = 11;
        BOOKING_SECTION_INTERACTION = 12;
        SHOWCASE_PRODUCT_CLICK = 13;
        PROMO_TO_SITE = 14;
        GEOPRODUCT_BUTTON_CLICK = 15;
    }
    enum OrderDirection {
        ASC = 1;
        DESC = 2;
    }
    required OrderField field = 1;
    required OrderDirection direction = 2;
}

message Statistics {
    required uint32 make_routes = 1;
    optional string review_rating = 2;
    required uint32 clicks_on_phone = 3;
    required uint32 site_opens = 4;

    required google.protobuf.Timestamp last_activity_timestamp = 5;

    required uint32 view_working_hours = 6;
    required uint32 view_entrances = 7;
    required uint32 cta_button_click = 8;
    required uint32 favourite_click = 9;
    required uint32 location_sharing = 10;
    required uint32 booking_section_interaction = 11;
    required uint32 showcase_product_click = 12;
    required uint32 promo_to_site = 13;
    required uint32 geoproduct_button_click = 14;
}

message ListLeadEventsInput {
    required uint64 biz_id = 1;
    required uint64 lead_id = 2;
    required maps_adv.geosmb.proto.common.Pagination pagination = 3;
}

message ListLeadEventsOutput {
    required uint32 total_events = 1;
    repeated Event events = 2;
}

message Event {
    enum EventType {
        MAKE_ROUTE = 1;
        REVIEW = 2;
        CLICK_ON_PHONE = 3;
        OPEN_SITE = 4;
        VIEW_WORKING_HOURS = 5;
        VIEW_ENTRANCES = 6;
        CTA_BUTTON_CLICK = 7;
        FAVOURITE_CLICK = 8;
        LOCATION_SHARING = 9;
        BOOKING_SECTION_INTERACTION = 10;
        SHOWCASE_PRODUCT_CLICK = 11;
        PROMO_TO_SITE = 12;
        GEOPRODUCT_BUTTON_CLICK = 13;
    }
    optional EventType type = 1;
    required string type_str = 4;  // NB: replace type fields when client ready
    required google.protobuf.Timestamp timestamp = 2;
    optional string value = 3;
    optional Source source = 5;
}

message SearchLeadsForGdprInput {
    required uint64 passport_uid = 1;
}

message SearchLeadsForGdprOutput {
    required bool leads_exist = 1;
}

message RemoveLeadsForGdprInput {
    required uint64 passport_uid = 1;
}

message RemoveLeadsForGdprOutput {
    message RemovedLead {
        required uint64 biz_id = 1;
        required uint64 lead_id = 2;
    }

    repeated RemovedLead removed_leads = 1;
}
