syntax = "proto3";

package task;

option go_package = "github.com/echofi-ai/schema/v2/types/task";

import "task/task.proto";

// TaskService defines the gRPC service for task operations
service TaskService {
  // ListTasks retrieves all available tasks for the authenticated user
  // Shows completion status and progress for each task
  rpc ListTasks(ListTasksRequest) returns (ListTasksResponse) {}

  // GetTaskStatus retrieves specific task status/progress for the authenticated user
  rpc GetTaskStatus(GetTaskStatusRequest) returns (GetTaskStatusResponse) {}

  // ClaimTask claims/completes a task for the authenticated user
  rpc ClaimTask(ClaimTaskRequest) returns (ClaimTaskResponse) {}
}

// ListTasksRequest is the request message for listing tasks
message ListTasksRequest {
  // Optional filter by task type
  optional TaskType task_type = 1;

  // Optional filter by completion status
  optional bool completed_only = 2;

  // Optional filter by claim status
  optional bool unclaimed_only = 3;

  // Pagination offset
  int32 offset = 4;

  // Pagination limit (max 100)
  int32 limit = 5;
}

// ListTasksResponse is the response message for listing tasks
message ListTasksResponse {
  // List of tasks with user progress
  repeated TaskWithUserProgress tasks = 1;

  // Total count of tasks (before pagination)
  int64 total = 2;

  // Current offset
  int32 offset = 3;

  // Current limit
  int32 limit = 4;
}

// GetTaskStatusRequest is the request message for getting task status
message GetTaskStatusRequest {
  // Task ID to get status for
  string task_id = 1;
}

// GetTaskStatusResponse is the response message for getting task status
message GetTaskStatusResponse {
  // Task with user progress
  TaskWithUserProgress task = 1;
}

// ClaimTaskRequest is the request message for claiming a task
message ClaimTaskRequest {
  // Task ID to claim
  string task_id = 1;
}

// ClaimTaskResponse is the response message for claiming a task
message ClaimTaskResponse {
  // Success message
  string message = 1;

  // Points awarded
  int32 points_awarded = 2;

  // Updated user task status
  UserTask user_task = 3;

  // Whether this was the first time claiming this task
  bool first_time_claim = 4;
}
