syntax = "proto3";

package transactions;

import "public_messages.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/duration.proto";  
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";

option csharp_namespace = "CMSMicroservice.Protobuf.Protos.Transactions";

service TransactionsContract
{
    rpc CreateNewTransactions(CreateNewTransactionsRequest) returns (CreateNewTransactionsResponse){
        option (google.api.http) = {
            post: "/CreateNewTransactions"
            body: "*"
        };
    };
    rpc UpdateTransactions(UpdateTransactionsRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            put: "/UpdateTransactions"
            body: "*"
        };
    };
    rpc DeleteTransactions(DeleteTransactionsRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            delete: "/DeleteTransactions"
            body: "*"
        };
    };
    rpc GetTransactions(GetTransactionsRequest) returns (GetTransactionsResponse){
        option (google.api.http) = {
            get: "/GetTransactions"
            
        };
    };
    rpc GetAllTransactionsByFilter(GetAllTransactionsByFilterRequest) returns (GetAllTransactionsByFilterResponse){
        option (google.api.http) = {
            get: "/GetAllTransactionsByFilter"
            
        };
    };
    rpc VerifyTransaction(VerifyTransactionRequest) returns (VerifyTransactionResponse){
        option (google.api.http) = {
            post: "/VerifyTransaction"
            body: "*"
        };
    };
    rpc RefundTransaction(RefundTransactionRequest) returns (RefundTransactionResponse){
        option (google.api.http) = {
            post: "/RefundTransaction"
            body: "*"
        };
    };
}
message CreateNewTransactionsRequest
{
    int64 amount = 1;
    string description = 2;
    oneof PaymentStatus_item 
    {
        messages.PaymentStatus payment_status = 3;
    }
    google.protobuf.Timestamp payment_date = 4;
    google.protobuf.StringValue ref_id = 5;
    oneof Type_item 
    {
        messages.TransactionType type = 6;
    }
}
message CreateNewTransactionsResponse
{
    int64 id = 1;
}
message UpdateTransactionsRequest
{
    int64 id = 1;
    int64 amount = 2;
    string description = 3;
    oneof PaymentStatus_item 
    {
        messages.PaymentStatus payment_status = 4;
    }
    google.protobuf.Timestamp payment_date = 5;
    google.protobuf.StringValue ref_id = 6;
    oneof Type_item 
    {
        messages.TransactionType type = 7;
    }
}
message DeleteTransactionsRequest
{
    int64 id = 1;
}
message GetTransactionsRequest
{
    int64 id = 1;
}
message GetTransactionsResponse
{
    int64 id = 1;
    int64 amount = 2;
    string description = 3;
    oneof PaymentStatus_item 
    {
        messages.PaymentStatus payment_status = 4;
    }
    google.protobuf.Timestamp payment_date = 5;
    google.protobuf.StringValue ref_id = 6;
    oneof Type_item 
    {
        messages.TransactionType type = 7;
    }
}
message GetAllTransactionsByFilterRequest
{
    messages.PaginationState pagination_state = 1;
    google.protobuf.StringValue sort_by = 2;
    GetAllTransactionsByFilterFilter filter = 3;
}
message GetAllTransactionsByFilterFilter
{
    google.protobuf.Int64Value id = 1;
    google.protobuf.Int64Value amount = 2;
    google.protobuf.StringValue description = 3;
    oneof PaymentStatus_item 
    {
        messages.PaymentStatus payment_status = 4;
    }
    google.protobuf.Timestamp payment_date = 5;
    google.protobuf.StringValue ref_id = 6;
    oneof Type_item 
    {
        messages.TransactionType type = 7;
    }
}
message GetAllTransactionsByFilterResponse
{
    messages.MetaData meta_data = 1;
    repeated GetAllTransactionsByFilterResponseModel models = 2;
}
message GetAllTransactionsByFilterResponseModel
{
    int64 id = 1;
    int64 amount = 2;
    string description = 3;
    oneof PaymentStatus_item 
    {
        messages.PaymentStatus payment_status = 4;
    }
    google.protobuf.Timestamp payment_date = 5;
    google.protobuf.StringValue ref_id = 6;
    oneof Type_item 
    {
        messages.TransactionType type = 7;
    }
}

// VerifyTransaction Messages
message VerifyTransactionRequest
{
    int64 transaction_id = 1;
    string ref_id = 2;
    messages.PaymentStatus status = 3;
    google.protobuf.Timestamp payment_date = 4;
}

message VerifyTransactionResponse
{
    int64 transaction_id = 1;
    messages.PaymentStatus status = 2;
    string ref_id = 3;
    string message = 4;
}

// RefundTransaction Messages
message RefundTransactionRequest
{
    int64 transaction_id = 1;
    string refund_reason = 2;
    google.protobuf.Int64Value refund_amount = 3;
}

message RefundTransactionResponse
{
    int64 original_transaction_id = 1;
    int64 refund_transaction_id = 2;
    int64 refund_amount = 3;
    string message = 4;
}
