syntax = "proto3";

package active_subscription;

option go_package = "active_subscription";

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

// ActiveSubscriptionCreate is a downstream event of EntitlementSubscriptionCreate and EntitlementSubscriptionUpdate.
// It is scheduled to trigger when a user's entitled subscription becomes active, as defined by the starts_at value.
// A subscription entitlement can be canceled before it starts, meaning that the subscription entitlement will never
// become active, thus not emitting an ActiveSubscriptionCreate event.
// Despite the Create verb, this event does not represent the creation or mutation of any data, just that a previously
// created subscription entitlement has become active. EntitlementSubscriptionCreate represents the creation event, and
// is triggered when a user subscribes or commits to subscribe.
message ActiveSubscriptionCreate {
  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;
}

// Platform represents the platform on which the entitlement was created.
enum Platform {
  PLATFORM_INVALID = 0;
  PLATFORM_ANDROID = 1;
  PLATFORM_IOS = 2;
  PLATFORM_WEB = 3;
}

// A `SubscriptionType` identifies the method by which a subscription entitlement was created.
enum SubscriptionType {
  SUBSCRIPTION_TYPE_INVALID = 0;
  SUBSCRIPTION_TYPE_GIFT = 1;
  SUBSCRIPTION_TYPE_PAID = 2;
  SUBSCRIPTION_TYPE_PRIME = 3;
  // Signifies the user initiated the creation of this entitlement by linking their prime and twitch account.
  // A primelink subscription entitlement is always to the primelink product(s), and not to products owned by real Twitch channels.
  SUBSCRIPTION_TYPE_PRIMELINK = 4;
  // Can be a channel's own subscription to themself granted upon reaching Affiliate status, or a subscription created by Twitch internally.
  SUBSCRIPTION_TYPE_ADMIN = 5;
  SUBSCRIPTION_TYPE_SUB_TOKEN = 6;
  SUBSCRIPTION_TYPE_CODE_REDEMPTION = 7;
}

// SubscriptionTier represents the tier of the subscription product.
enum SubscriptionTier {
  SUBSCRIPTION_TIER_INVALID = 0;
  SUBSCRIPTION_TIER_ONE = 1;
  SUBSCRIPTION_TIER_TWO = 2;
  SUBSCRIPTION_TIER_THREE = 3;
  SUBSCRIPTION_TIER_CUSTOM = 4;
}
