Files
Swarm/DysonNetwork.Shared/Proto/poll.proto

134 lines
3.0 KiB
Protocol Buffer

syntax = "proto3";
package proto;
option csharp_namespace = "DysonNetwork.Shared.Proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "publisher.proto";
// Enums
enum PollQuestionType {
POLL_QUESTION_TYPE_UNSPECIFIED = 0;
SINGLE_CHOICE = 1;
MULTIPLE_CHOICE = 2;
YES_NO = 3;
RATING = 4;
FREE_TEXT = 5;
}
// Messages
message PollOption {
string id = 1;
string label = 2;
google.protobuf.StringValue description = 3;
int32 order = 4;
}
message PollQuestion {
string id = 1;
PollQuestionType type = 2;
repeated PollOption options = 3;
string title = 4;
google.protobuf.StringValue description = 5;
int32 order = 6;
bool is_required = 7;
}
message Poll {
string id = 1;
google.protobuf.StringValue title = 2;
google.protobuf.StringValue description = 3;
optional google.protobuf.Timestamp ended_at = 4;
bool is_anonymous = 5;
string publisher_id = 6;
optional Publisher publisher = 7;
repeated PollQuestion questions = 8;
google.protobuf.Timestamp created_at = 9;
google.protobuf.Timestamp updated_at = 10;
optional google.protobuf.Timestamp deleted_at = 11;
}
message PollAnswer {
string id = 1;
bytes answer = 2; // Dictionary<string, JsonElement>
string account_id = 3;
string poll_id = 4;
google.protobuf.Timestamp created_at = 5;
google.protobuf.Timestamp updated_at = 6;
optional google.protobuf.Timestamp deleted_at = 7;
}
// ====================================
// Request/Response Messages
// ====================================
message GetPollRequest {
oneof identifier {
string id = 1;
}
}
message GetPollBatchRequest {
repeated string ids = 1;
}
message GetPollBatchResponse {
repeated Poll polls = 1;
}
message ListPollsRequest {
google.protobuf.StringValue publisher_id = 1;
int32 page_size = 2;
string page_token = 3;
google.protobuf.StringValue order_by = 4;
bool order_desc = 5;
}
message ListPollsResponse {
repeated Poll polls = 1;
string next_page_token = 2;
int32 total_size = 3;
}
message GetPollAnswerRequest {
string poll_id = 1;
string account_id = 2;
}
message GetPollStatsRequest {
string poll_id = 1;
}
message GetPollStatsResponse {
map<string, string> stats = 1; // Question ID -> JSON string of stats (option_id -> count)
}
message GetPollQuestionStatsRequest {
string question_id = 1;
}
message GetPollQuestionStatsResponse {
map<string, int32> stats = 1; // Option ID -> count
}
// ====================================
// Service Definitions
// ====================================
service PollService {
rpc GetPoll(GetPollRequest) returns (Poll);
rpc GetPollBatch(GetPollBatchRequest) returns (GetPollBatchResponse);
rpc ListPolls(ListPollsRequest) returns (ListPollsResponse);
rpc GetPollAnswer(GetPollAnswerRequest) returns (PollAnswer);
rpc GetPollStats(GetPollStatsRequest) returns (GetPollStatsResponse);
rpc GetPollQuestionStats(GetPollQuestionStatsRequest) returns (GetPollQuestionStatsResponse);
}