syntax = "proto3";

package slash.api.v1;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/timestamp.proto";

option go_package = "gen/api/v1";

service SubscriptionService {
  // GetSubscription gets the current subscription of Slash instance.
  rpc GetSubscription(GetSubscriptionRequest) returns (Subscription) {
    option (google.api.http) = {get: "/v1/subscription"};
  }
  // UpdateSubscription updates the subscription.
  rpc UpdateSubscription(UpdateSubscriptionRequest) returns (Subscription) {
    option (google.api.http) = {
      patch: "/v1/subscription"
      body: "*"
    };
  }
  // DeleteSubscription deletes the subscription.
  rpc DeleteSubscription(DeleteSubscriptionRequest) returns (Subscription) {
    option (google.api.http) = {delete: "/v1/subscription"};
  }
}

message Subscription {
  PlanType plan = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  google.protobuf.Timestamp started_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  google.protobuf.Timestamp expires_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  repeated string features = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  int32 seats = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  int32 shortcuts_limit = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  int32 collections_limit = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
}

enum PlanType {
  PLAN_TYPE_UNSPECIFIED = 0;
  FREE = 1;
  PRO = 2;
  ENTERPRISE = 3;
}

message GetSubscriptionRequest {}

message UpdateSubscriptionRequest {
  string license_key = 1 [(google.api.field_behavior) = REQUIRED];
}

message DeleteSubscriptionRequest {}
