syntax = "proto2";

package maps_adv.geosmb.scenarist.proto.scenarios;

import "google/protobuf/timestamp.proto";

enum ScenarioName {
    DISCOUNT_FOR_LOST = 1;
    ENGAGE_PROSPECTIVE = 2;
    THANK_THE_LOYAL = 3;
    DISCOUNT_FOR_DISLOYAL = 4;
}

enum SubscriptionStatus {
    ACTIVE = 1;
    PAUSED = 2;
    COMPLETED = 3;
}

message CouponStatisticsLine {
    required uint32 sent = 1;
    required uint32 opened = 2;
    required uint32 clicked = 3;
}

message CouponStatistics {
    required CouponStatisticsLine total = 1;
}

message Coupon {
    required google.protobuf.Timestamp created_at = 1;
    optional uint64 coupon_id = 2;
    required CouponStatistics statistics = 3;
}

message Subscription {
    required uint64 subscription_id = 1;
    required uint64 biz_id = 2;
    required ScenarioName scenario_name = 3;
    required SubscriptionStatus status = 4;
    optional uint64 coupon_id = 5;
}

message Scenario {
    enum SegmentType {
        PROSPECTIVE = 1;
        ACTIVE = 2;
        LOST = 3;
        LOYAL = 4;
        DISLOYAL = 5;
        REGULAR = 6;
        NO_ORDERS = 7;
        UNPROCESSED_ORDERS = 8;
    }

    required ScenarioName name = 1;
    repeated SegmentType segments = 2;
    optional Subscription subscription = 3;
}

message ListScenariosInput {
    required uint64 biz_id = 1;
}

message ListScenariosOutput {
    repeated Scenario scenarios = 1;
}

message CreateSubscriptionInput {
    required uint64 biz_id = 1;
    required ScenarioName scenario_name = 2;
    optional uint64 coupon_id = 3;
}

message RetrieveSubscriptionInput {
    required uint64 subscription_id = 1;
    required uint64 biz_id = 2;
}

message RetrieveSubscriptionOutput {
    required Subscription subscription = 1;
    repeated Coupon coupons_history = 2;
}

message UpdateSubscriptionStatusInput {
    enum StatusForUpdate {
        ACTIVE = 1;
        PAUSED = 2;
    }
    required uint64 subscription_id = 1;
    required uint64 biz_id = 2;
    required StatusForUpdate status = 3;
}

message ReplaceCouponInput {
    required uint64 subscription_id = 1;
    required uint64 biz_id = 2;
    optional uint64 coupon_id = 3;
}

message ReplaceCouponOutput {
    required SubscriptionStatus status = 1;
}
