syntax = "proto3";

package notifications;

service NotificationsService {
  rpc ListNotifications (ListNotificationsRequest) returns (ListNotificationsResponse);
  rpc GetUnreadCount (UserIdRequest) returns (UnreadCountResponse);
  rpc DeleteNotification (MarkNotificationReadRequest) returns (MutationResponse);
  rpc DeleteAllNotifications (UserIdRequest) returns (MutationResponse);
  rpc MarkNotificationRead (MarkNotificationReadRequest) returns (MutationResponse);
  rpc MarkAllNotificationsRead (UserIdRequest) returns (MutationResponse);
}

message UserIdRequest {
  string userId = 1;
}

message ListNotificationsRequest {
  string userId = 1;
  int32 limit = 2;
  optional bool unreadOnly = 3;
}

message NotificationResponse {
  string id = 1;
  string userId = 2;
  string type = 3;
  string title = 4;
  string message = 5;
  string payloadJson = 6;
  bool isRead = 7;
  string createdAt = 8;
}

message ListNotificationsResponse {
  repeated NotificationResponse notifications = 1;
}

message UnreadCountResponse {
  int32 count = 1;
}

message MarkNotificationReadRequest {
  string userId = 1;
  string notificationId = 2;
}

message MutationResponse {
  int32 count = 1;
}
