syntax = "proto3";

package devvit.dev_portal.fetch_domain_request;

import "devvit/dev_portal/reddit/redditor.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.snooguts.net/reddit/reddit-devplatform-monorepo/go-common/generated/protos/types/devvit/devportal/fetchdomainrequest";

// The status of the domain request, eg 'PENDING', 'APPROVED', 'DENIED'
enum FetchDomainRequestStatus {
  PENDING = 0;
  APPROVED = 1;
  DENIED = 2;
}

enum GlobalListType {
  ALLOWLIST = 0;
  DENYLIST = 1;
}

// Represents information about a domain request.
message FetchDomainRequestInfo {
  // The UUID of the request, eg '19ecb14b-db3c-4757-9793-4d58893ba449'
  string id = 1;
  // The timestamp when the request was created, eg '2025-06-04T17:14:38.029Z'
  google.protobuf.Timestamp created_at = 2;
  // The timestamp when the request was last updated, eg '2025-06-04T17:14:38.029Z'
  google.protobuf.Timestamp updated_at = 3;
  // The domain that is being requesting, eg 'hello-world.org'
  string domain = 4;
  // The status of the request, eg 'PENDING', 'APPROVED', 'DENIED'
  FetchDomainRequestStatus status = 5;
  // The t2_ id of the user who reviewed the request, eg 't2_1a2b'
  optional string reviewer_id = 6;
  // The slug of the app that the request is for, eg 'wsb-app'.
  optional string app_slug = 7;
  // The account of the app owner who requested the domain, eg 't2_3c4d'
  devvit.dev_portal.reddit.Redditor app_owner_account = 8;
  // The account of the reviewer who reviewed the request, eg 't2_1a2b'
  devvit.dev_portal.reddit.Redditor reviewer_account = 9;
  // The formatted time representing how long a request has been pending, eg '2 days', '5 hours', '23 seconds'.
  optional string time_in_queue = 10;
}

message GetPendingRequest {
  // How many pending requests to return in a single page.
  int32 page_size = 1;
  // The page number of pending requests to return. The page number should start at 1.
  int32 page_number = 2;
}

message GetResponse {
  // The list of fetch domain request information.
  repeated FetchDomainRequestInfo fetch_domain_requests = 1;
  // Indicates whether or not there is a next page of fetch domain requests.
  optional bool has_next_page = 2;
}

message UpdateStatusForAppRequest {
  // The ID of the FetchDomainRequest to be updated.
  string id = 1;
  // The slug of the app that the request is for, eg 'wsb-app'.
  string app_slug = 2;
  // The domain on the request, eg 'api.hello-world.net'.
  string domain = 3;
  // The new status of the FetchDomainRequest. Can be one of PENDING, APPROVED, or DENIED.
  FetchDomainRequestStatus status = 4;
}

message GetFetchDomainRequestsWithGlobalListTypeRequest {
  // The global list type to retrieve fetch domain requests for.
  GlobalListType global_list_type = 1;
  // The page number to retrieve. The page number should start at 1.
  int32 page_number = 2;
  // The number of fetch domain requests to retrieve per page.
  int32 page_size = 3;
}
