diff --git a/transaction/v1/transaction.proto b/transaction/v1/transaction.proto new file mode 100644 index 0000000..075c46f --- /dev/null +++ b/transaction/v1/transaction.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; + +package proto.transaction.v1; + +import "buf/validate/validate.proto"; +import "google/protobuf/timestamp.proto"; + +message Transaction { + int32 transaction_id = 1; + string description = 2 [(buf.validate.field).string.min_len = 1]; + string amount = 3 [(buf.validate.field).string = {pattern: "^-?\\d+(\\.\\d{1,2})?$"}]; + string category = 4 [(buf.validate.field).string.min_len = 1]; + google.protobuf.Timestamp transaction_date = 5; + google.protobuf.Timestamp created_at = 6; +} + +message CreateTransactionRequest { + string description = 1 [(buf.validate.field).string.min_len = 1]; + string amount = 2 [(buf.validate.field).string = {pattern: "^-?\\d+(\\.\\d{1,2})?$"}]; + string category = 3 [(buf.validate.field).string.min_len = 1]; + google.protobuf.Timestamp transaction_date = 4; +} +message CreateTransactionResponse { + Transaction transaction = 1; +} + +message ListTransactionsRequest {} +message ListTransactionsResponse { + repeated Transaction transactions = 1; +} + +message GetTransactionRequest { + int32 transaction_id = 1 [(buf.validate.field).int32.gt = 0]; +} +message GetTransactionResponse { + Transaction transaction = 1; +} + +message DeleteTransactionRequest { + int32 transaction_id = 1 [(buf.validate.field).int32.gt = 0]; +} +message DeleteTransactionResponse { + bool ok = 1; +} + +service TransactionService { + rpc CreateTransaction(CreateTransactionRequest) returns (CreateTransactionResponse) {} + rpc ListTransactions(ListTransactionsRequest) returns (ListTransactionsResponse) {} + rpc GetTransaction(GetTransactionRequest) returns (GetTransactionResponse) {} + rpc DeleteTransaction(DeleteTransactionRequest) returns (DeleteTransactionResponse) {} +}