syntax = "proto3";

package receiver;

option go_package = "code.justin.tv/growth/receiver/proto/receiver";

// Receiver is an example protobuf application
service Receiver {
    // PublishNotification publishes the notification to dart processor and returns a unique notification trace id that
    // serves to track the progress of the notification
    // TODO: We need to determine the correct SLO to use
    // SLO@100ms
    rpc PublishNotification (PublishNotificationRequest) returns (PublishNotificationResponse);
}

message PublishNotificationRequest {
    // The user_id of the sender that will be used for fanout (optional)
    string sender_id = 1;
    // The eventual intended recipient for the notification of this event.
    // This will be defined as either an id or email
    oneof recipient {
        // The user_id of the recipient
        string recipient_id = 2;
        // The email of the recipient TODO mark as reserved once below email data adopted
        string recipient_email = 3;
        // The device ID of the recipient, for the case of logged-out push notifications
        string recipient_device_id = 8;
        // The email and locale of the recipient
        RecipientEmailAddressWithLocale recipient_email_address_with_locale = 10;
        // The phone number and locale of the recipient
        RecipientPhoneNumberWithLocale recipient_phone_number_with_locale = 11;
    }
    // The type of the notification for this event defined in the configuration for the notification
    string notification_type = 4;
    // A series of key,value pairs with metadata for this event that can be dynamically used to render the notification (optional)
    map<string, string> metadata = 5;
    reserved 6;
    bool drop_notification_before_delivery = 7;
    bool is_test_send = 9;
}

message PublishNotificationResponse {
    // This is the id that will be used to track the notification throughout the notification system
    string notification_trace_id = 1;
}

message RecipientEmailAddressWithLocale {
    // The email of the recipient
    string email = 1;
    // The locale of the recipient
    string locale = 2;
}

message RecipientPhoneNumberWithLocale {
    // The phone number of the recipient
    string phone_number = 1;
    // The locale of the recipient
    string locale = 2;
}
