syntax = "proto3";

package rpc;

import "common.proto";

option go_package = "github.com/stripe/stripe-cli/rpc";

message ListenRequest {
  // A list of custom headers to forward for Connect
  repeated string connect_headers = 1;

  // A list of specific events to listen for. For a list of all possible events, see:
  // https://stripe.com/docs/api/events/types (default [*])
  repeated string events = 2;

  // The URL to forward Connect webhook events to (default: same as normal events)
  string forward_connect_to = 3;

  // The URL to forward webhook events to
  string forward_to = 4;

  // A list of custom headers to forward
  repeated string headers = 5;

  // Receive events formatted with the latest API version (default: your account's default API
  // version)
  bool latest = 6;

  // Receive live events (default: test)
  bool live = 7;

  // Skip certificate verification when forwarding to HTTPS endpoints
  bool skip_verify = 8;

  // Load webhook endpoint configuration from the webhooks API/dashboard
  bool use_configured_webhooks = 9;

  // A list of thin-type events to listen for. Defaults to none.
  repeated string thin_events = 10;

  // The URL to forward thin webhook events to
  string forward_thin_to = 11;

  // The URL to forward thin Connect webhook events to (default: same as normal thin events)
  string forward_thin_connect_to = 12;

  // The Stripe API version associated with the provided snapshot payload event types
  string api_version = 13;
}

message ListenResponse {
  enum State {
    STATE_UNSPECIFIED = 0;
    STATE_LOADING = 1;
    STATE_RECONNECTING = 2;
    STATE_READY = 3;
    STATE_DONE = 4;
  }

  message EndpointResponse {
    message Data {
      enum HttpMethod {
        HTTP_METHOD_UNSPECIFIED = 0;
        HTTP_METHOD_GET = 1;
        HTTP_METHOD_POST = 2;
        HTTP_METHOD_DELETE = 3;
      }

      // HTTP status code
      int64 status = 1;

      // HTTP method
      HttpMethod http_method = 2;

      // URL of the webhook endpoint
      string url = 3;

      // ID of the Stripe event that caused this response
      string event_id = 4;
    }

    oneof content {
      Data data = 1;
      string error = 2;
    }
  }

  oneof content {
    // Check if the stream ready
    State state = 1;

    // A Stripe event
    StripeEvent stripe_event = 2;

    // A response from an endpoint
    EndpointResponse endpoint_response = 3;

    // A V2 Stripe event
    V2StripeEvent v2_stripe_event = 4;
  }
}
