syntax = "proto2";

package maps_adv.geosmb.telegraphist.proto.notifications_for_business;

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


message Notification {
    required Recipient recipient = 1;
    repeated common.Transport transports = 2;

    oneof notification_details {
        // new order created
        OrderCreated order_created = 10;
        // order was rescheduled
        OrderChanged order_changed = 12;
        // order was cancelled
        OrderCancelled order_cancelled = 13;
        // certificate will expire in 7 days
        CertificateExpiring certificate_expiring = 14;
        // certificate expired
        CertificateExpired certificate_expired = 15;
        // certificate almost ready, need to connect to Яндекс.Оплата
        CertificateConnectPayment certificate_connect_payment = 16;
        // certificate was rejected by moderation
        CertificateRejected certificate_rejected = 17;
        // first certificate created for business was approved
        FirstCertificateApproved first_certificate_approved = 18;
        // second and other certificate created for business was approved
        SubsequentCertificateApproved subsequent_certificate_approved = 19;
        // certificate was purchased
        CertificatePurchased certificate_purchased = 20;
        // certificate created and sent to moderation
        CertificateCreated certificate_created = 21;
        // new request created
        RequestCreated request_created = 22;
    }
}

message Recipient {
    required uint64 biz_id = 1;
    required string cabinet_link = 2; // personal cabinet button
    required string company_link = 3; // url for link on logo
}

message CertificateCreated {
    required CertificateBaseDetails certificate = 1;
}

message CertificatePurchased {
    required CertificateFullDetails certificate = 1;
    required string cashier_link = 2;
}

message CertificateConnectPayment {
    required string payment_setup_link = 1;
}

message CertificateExpiring {
    required CertificateForExpirationNotification certificate = 1;
    required string create_new_link = 2;
}

message CertificateExpired {
    required CertificateForExpirationNotification certificate = 1;
    required string create_new_link = 2;
}

message CertificateRejected {
    required CertificateBaseDetails certificate = 1;
}

message FirstCertificateApproved {
    required CertificateBaseDetails certificate = 1;
}

message SubsequentCertificateApproved {
    required CertificateBaseDetails certificate = 1;
}

message CertificateBaseDetails {
    required string name = 1;
    required string link = 2;
}

message CertificateForExpirationNotification {
    required CertificateBaseDetails base_details = 1;

    // if certificate was sold at least once
    optional string sales = 2; // like 123.45
}

message CertificateFullDetails {
    required CertificateBaseDetails base_details = 1;
    // what price certificate was bought for
    required string price = 2; // like 123.45
    // what discount certificate provides in percents
    required string discount = 3; // like 15.5
    required ValidityPeriod validity_period = 4;
}

message ValidityPeriod {
    required google.protobuf.Timestamp valid_from = 1;
    required google.protobuf.Timestamp valid_to = 2;
}

message OrderCreated {
    required Client client = 1;
    required Order order = 2;
    optional string details_link = 3;
}

message OrderChanged {
    required Client client = 1;
    required Order order = 2;
    optional string details_link = 3;
}

message OrderCancelled {
    required Client client = 1;
    required Order order = 2;
    optional string details_link = 3;
}

message Order {
    required string booking_code = 1;
    repeated common.OrderItem items = 2;
    required common.Cost total_cost = 3;
    required string source = 4;
    optional string comment = 5;
}

message Client {
    required uint64 client_id = 1;
}

message RequestCreated {
    required string details_link = 1;
}
