syntax = "proto3";

package package;

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.Package";

service PackageContract
{
    rpc CreateNewPackage(CreateNewPackageRequest) returns (CreateNewPackageResponse){
        option (google.api.http) = {
            post: "/CreateNewPackage"
            body: "*"
        };
    };
    rpc UpdatePackage(UpdatePackageRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            put: "/UpdatePackage"
            body: "*"
        };
    };
    rpc DeletePackage(DeletePackageRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            delete: "/DeletePackage"
            body: "*"
        };
    };
    rpc GetPackage(GetPackageRequest) returns (GetPackageResponse){
        option (google.api.http) = {
            get: "/GetPackage"
            
        };
    };
    rpc GetAllPackageByFilter(GetAllPackageByFilterRequest) returns (GetAllPackageByFilterResponse){
        option (google.api.http) = {
            get: "/GetAllPackageByFilter"
            
        };
    };
    
    // Package Purchase System
    rpc PurchaseGoldenPackage(PurchaseGoldenPackageRequest) returns (PurchaseGoldenPackageResponse){
        option (google.api.http) = {
            post: "/PurchaseGoldenPackage"
            body: "*"
        };
    };
    rpc VerifyGoldenPackagePurchase(VerifyGoldenPackagePurchaseRequest) returns (VerifyGoldenPackagePurchaseResponse){
        option (google.api.http) = {
            post: "/VerifyGoldenPackagePurchase"
            body: "*"
        };
    };
    rpc GetUserPackageStatus(GetUserPackageStatusRequest) returns (GetUserPackageStatusResponse){
        option (google.api.http) = {
            get: "/GetUserPackageStatus"
        };
    };
}
message CreateNewPackageRequest
{
    string title = 1;
    string description = 2;
    string image_path = 3;
    int64 price = 4;
}
message CreateNewPackageResponse
{
    int64 id = 1;
}
message UpdatePackageRequest
{
    int64 id = 1;
    string title = 2;
    string description = 3;
    string image_path = 4;
    int64 price = 5;
}
message DeletePackageRequest
{
    int64 id = 1;
}
message GetPackageRequest
{
    int64 id = 1;
}
message GetPackageResponse
{
    int64 id = 1;
    string title = 2;
    string description = 3;
    string image_path = 4;
    int64 price = 5;
}
message GetAllPackageByFilterRequest
{
    messages.PaginationState pagination_state = 1;
    google.protobuf.StringValue sort_by = 2;
    GetAllPackageByFilterFilter filter = 3;
}
message GetAllPackageByFilterFilter
{
    google.protobuf.Int64Value id = 1;
    google.protobuf.StringValue title = 2;
    google.protobuf.StringValue description = 3;
    google.protobuf.StringValue image_path = 4;
    google.protobuf.Int64Value price = 5;
}
message GetAllPackageByFilterResponse
{
    messages.MetaData meta_data = 1;
    repeated GetAllPackageByFilterResponseModel models = 2;
}
message GetAllPackageByFilterResponseModel
{
    int64 id = 1;
    string title = 2;
    string description = 3;
    string image_path = 4;
    int64 price = 5;
}

// Package Purchase Messages
message PurchaseGoldenPackageRequest
{
    int64 user_id = 1;
    int64 package_id = 2;
    string return_url = 3;
}

message PurchaseGoldenPackageResponse
{
    bool success = 1;
    string message = 2;
    int64 order_id = 3;
    string payment_gateway_url = 4;
    string tracking_code = 5;
}

message VerifyGoldenPackagePurchaseRequest
{
    int64 order_id = 1;
    string authority = 2;
    string status = 3;
}

message VerifyGoldenPackagePurchaseResponse
{
    bool success = 1;
    string message = 2;
    int64 order_id = 3;
    int64 transaction_id = 4;
    string reference_code = 5;
    int64 wallet_balance = 6;
}

message GetUserPackageStatusRequest
{
    int64 user_id = 1;
}

message GetUserPackageStatusResponse
{
    int64 user_id = 1;
    string package_purchase_method = 2;
    bool has_purchased_package = 3;
    bool is_club_member_active = 4;
    int64 wallet_balance = 5;
    int64 discount_balance = 6;
    bool can_activate_club_membership = 7;
    google.protobuf.StringValue last_order_number = 8;
    google.protobuf.Timestamp last_purchase_date = 9;
}
