syntax = "proto3";

package documents;

service DocumentsService {
  rpc CreateDocument (CreateDocumentRequest) returns (UserDocument);
  rpc ListDocuments (ListDocumentsRequest) returns (ListDocumentsResponse);
  rpc GetDocument (DocumentIdRequest) returns (UserDocument);
  rpc UpdateDocument (UpdateDocumentRequest) returns (UserDocument);
  rpc DeleteDocument (DocumentIdRequest) returns (MutationResponse);
}

message CreateDocumentRequest {
  string userId = 1;
  string type = 2;
  string number = 3;
  optional string issuedAt = 4;
  optional string expiresAt = 5;
  optional string metadataJson = 6;
}

message UpdateDocumentRequest {
  string documentId = 1;
  string userId = 2;
  optional string number = 3;
  optional string issuedAt = 4;
  optional string expiresAt = 5;
  optional string metadataJson = 6;
}

message ListDocumentsRequest {
  string userId = 1;
}

message DocumentIdRequest {
  string documentId = 1;
  string userId = 2;
}

message UserDocument {
  string id = 1;
  string userId = 2;
  string type = 3;
  string number = 4;
  optional string issuedAt = 5;
  optional string expiresAt = 6;
  optional string metadataJson = 7;
  string createdAt = 8;
  string updatedAt = 9;
}

message ListDocumentsResponse {
  repeated UserDocument documents = 1;
}

message MutationResponse {
  int32 count = 1;
}
