syntax = "proto3";

package active_subscription;

option go_package = "active_subscription";

import "active_subscription/create.proto";
import "eventbus/owner.proto";
import "google/protobuf/timestamp.proto";

// ActiveSubscriptionDelete is a downstream of EntitlementSubscriptionCreate and EntitlementSubscriptionUpdate that is
// scheduled to trigger when an *active* subscription entitlement ends.
// A subscription entitlement is considered active when `starts_at <= time.Now() < ends_at`. Similarly, an active
// subscription ends (or "expires") when `starts_at < ends_at <= time.Now()`. This means that a future subscription
// entitlement (`time.Now() < starts_at`) that is canceled before it starts will not emit a ActiveSubscriptionDelete
// event since it was never active.
message ActiveSubscriptionDelete {
  option (eventbus.owner.ldap_group) = "team-subs";
  // Entitlement ID
  string id = 1;
  // Twitch User ID of the user who owns this entitlement.
  string owner_user_id = 2;
  // The Platform from which the entitlement came from.
  Platform platform = 3;
  // ID for the product the user is entitled to.
  string product_id = 4;
  // Twitch User ID of the broadcaster who owns the product.
  string product_owner_user_id = 5;
  // Identifier for the origin object that caused this entitlement.
  string origin_id = 6;
  // When the entitlement starts.
  google.protobuf.Timestamp starts_at = 7;
  // When the entitlement expires.
  google.protobuf.Timestamp ends_at = 8;
  // The subscription type of this entitlement.
  SubscriptionType type = 9;
  // The subscription tier represents the tier of the product associated with this subscription.
  SubscriptionTier tier = 10;
}
