syntax = "proto3";

package wix.dealerOfferEvents.api.v1;

import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/struct.proto";
import "wix/api/entity.proto";
import "wix/api/annotations.proto";
import "wix/api/validations.proto";

option java_package = "com.wix.dealerOfferEvents.api.v1";

message OfferEvent {
    option (wix.api.entity).fqdn = "wix.dealer.v1.offer_event";

    // unique guid
    string offer_id = 1 [(wix.api.format) = GUID];

    // the direct user recieved the offer - returned only for AGENT_MARK summary/query
    // OPTIONAL - NOT RECOMMENDED to pass in report event.
    google.protobuf.StringValue user_id = 2 [(wix.api.format) = GUID];

    // the target account context recieved the offer
    // OPTIONAL - NOT RECOMMENDED to pass in report event.
    google.protobuf.StringValue target_account_id = 3 [(wix.api.format) = GUID];

    // returned only for AGENT_MARK summary/query
    // OPTIONAL - NOT RECOMMENDED to pass in report event.
    google.protobuf.StringValue logged_in_account_id = 4 [(wix.api.format) = GUID];

    // the site context recieved the offer
    // OPTIONAL - NOT RECOMMENDED to pass in report event.
    google.protobuf.StringValue site_id = 5 [(wix.api.format) = GUID];

    // returned only for AGENT_MARK summary/query
    google.protobuf.StringValue event_id = 6 [(wix.api.format) = GUID, (wix.api.readOnly) = true];

    // creation timestamp
    google.protobuf.Timestamp created_at = 7 [(wix.api.readOnly) = true];

    // for some of the event types a payload should be passed
    // for example if u pass MAIN_CTA_CLICK then main_cta_click payload should also be passed with target_url
    EventType type = 8;

    oneof payload {
        // a payload when event type is AGENT_MARK
        AgentMarkedPayload agent_mark = 9;

        // a payload when event type is MAIN_CTA_CLICK
        // currently will not be returned as part of summary response
        CTAClickPayload main_cta_click = 17;

        // a payload when event type is SECONDARY_CTA_CLICK
        // currently will not be returned as part of summary response
        CTAClickPayload secondary_cta_click = 18;

    }

    // currently will not be returned as part of summary/query response
    google.protobuf.StringValue real_estate_id = 11;

    reserved 10, 12, 20;

    // URL of a web page which is initial cause/source of the event (if available)
    // if left blank and grpc endpoint is exposed over http rest - taken from HTTP referrer header
    // currently will not be returned as part of summary response - not supported for AGENT_MARK
    google.protobuf.StringValue http_referrer = 13;

    // Some external asset guid. Can be the banner/LB campaign creative guid, but isn't specific to LB/banner assets.
    // currently will not be returned as part of summary response - not supported for AGENT_MARK
    google.protobuf.StringValue asset_id = 14 [(wix.api.format) = GUID];

    // For placements that are used in multiple platforms simultaneously, pass the information of where this interaction happened.
    // standard platforms for bi: BUSINESS_MANAGER, EDITORX, EDITORX, ADI, OWNER_APP
    PlatformEnum platform = 15;

    enum PlatformEnum {
        UNKNOWN = 0;
        BUSINESS_MANAGER = 1;
        EDITORX = 2;
        EDITOR = 3;
        ADI = 4;
        OWNER_APP = 5;
        BRANDED_APP = 6;
        DEV_CENTER = 7;
    }

}

message CTAClickPayload {
    // destination url of the cta if available (i.e. CTA href etc.)
    // in some cases Cta is not url - therfore a simple string can be passed
    google.protobuf.StringValue target_url = 1;
}

message AgentMarkedPayload {
    // id of related agent
    google.protobuf.StringValue agent_id = 1 [(wix.api.format) = GUID];

    // Offer status
    AgentOfferStatusEnum status = 2;

    enum AgentOfferStatusEnum {
        NOT_STARTED = 0;
        SUGGESTED = 1;
        REJECTED = 2;
        REQUESTED = 3;
        ALREADY_COMPLETED = 4;
        NOT_RELEVANT = 5;
        PAUSED = 6;
    }
}

enum EventType {
    UNKNOWN = 0;
    VIEW = 1;

    MAIN_CTA_CLICK = 3;
    SECONDARY_CTA_CLICK = 4;
    AGENT_MARK = 5;

    reserved 6, 2;

    SKIP = 7;
    UNSKIP = 8;
    CLOSE = 9;
    SHOW_LATER = 10;
}
