syntax = "proto3";

package discountcategory;

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

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

service DiscountCategoryContract
{
    rpc CreateDiscountCategory(CreateDiscountCategoryRequest) returns (CreateDiscountCategoryResponse){
        option (google.api.http) = {
            post: "/CreateDiscountCategory"
            body: "*"
        };
    };
    rpc UpdateDiscountCategory(UpdateDiscountCategoryRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            put: "/UpdateDiscountCategory"
            body: "*"
        };
    };
    rpc DeleteDiscountCategory(DeleteDiscountCategoryRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            delete: "/DeleteDiscountCategory"
            body: "*"
        };
    };
    rpc GetDiscountCategories(GetDiscountCategoriesRequest) returns (GetDiscountCategoriesResponse){
        option (google.api.http) = {
            get: "/GetDiscountCategories"
        };
    };
}

// Create Category
message CreateDiscountCategoryRequest
{
    string name = 1;
    string title = 2;
    google.protobuf.StringValue description = 3;
    google.protobuf.StringValue image_path = 4;
    google.protobuf.Int64Value parent_category_id = 5;
    int32 sort_order = 6;
    bool is_active = 7;
}

message CreateDiscountCategoryResponse
{
    int64 category_id = 1;
}

// Update Category
message UpdateDiscountCategoryRequest
{
    int64 category_id = 1;
    string name = 2;
    string title = 3;
    google.protobuf.StringValue description = 4;
    google.protobuf.StringValue image_path = 5;
    google.protobuf.Int64Value parent_category_id = 6;
    int32 sort_order = 7;
    bool is_active = 8;
}

// Delete Category
message DeleteDiscountCategoryRequest
{
    int64 category_id = 1;
}

// Get Categories with Tree Structure
message GetDiscountCategoriesRequest
{
    google.protobuf.Int64Value parent_category_id = 1; // null = root categories
    google.protobuf.BoolValue is_active = 2;
}

message GetDiscountCategoriesResponse
{
    repeated DiscountCategoryDto categories = 1;
}

message DiscountCategoryDto
{
    int64 id = 1;
    string name = 2;
    string title = 3;
    google.protobuf.StringValue description = 4;
    google.protobuf.StringValue image_path = 5;
    google.protobuf.Int64Value parent_category_id = 6;
    int32 sort_order = 7;
    bool is_active = 8;
    int32 product_count = 9;
    repeated DiscountCategoryDto children = 10; // Recursive children
}
