syntax = "proto3";

package sitepage;

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

service SitePageContract
{
    rpc GetSitePage(GetSitePageRequest) returns (GetSitePageResponse){
        option (google.api.http) = { get: "/GetSitePage" };
    };
    rpc GetSitePageByKey(GetSitePageByKeyRequest) returns (GetSitePageResponse){
        option (google.api.http) = { get: "/GetSitePageByKey" };
    };
    rpc CreateSitePage(CreateSitePageRequest) returns (CreateSitePageResponse){
        option (google.api.http) = { post: "/CreateSitePage" body: "*" };
    };
    rpc UpdateSitePage(UpdateSitePageRequest) returns (google.protobuf.Empty){
        option (google.api.http) = { put: "/UpdateSitePage" body: "*" };
    };
    rpc DeleteSitePage(DeleteSitePageRequest) returns (google.protobuf.Empty){
        option (google.api.http) = { delete: "/DeleteSitePage" body: "*" };
    };
    rpc GetAllSitePages(GetAllSitePagesRequest) returns (GetAllSitePagesResponse){
        option (google.api.http) = { get: "/GetAllSitePages" };
    };
    rpc CreateSitePageSection(CreateSitePageSectionRequest) returns (CreateSitePageSectionResponse){
        option (google.api.http) = { post: "/CreateSitePageSection" body: "*" };
    };
    rpc UpdateSitePageSection(UpdateSitePageSectionRequest) returns (google.protobuf.Empty){
        option (google.api.http) = { put: "/UpdateSitePageSection" body: "*" };
    };
    rpc DeleteSitePageSection(DeleteSitePageSectionRequest) returns (google.protobuf.Empty){
        option (google.api.http) = { delete: "/DeleteSitePageSection" body: "*" };
    };
    rpc ReorderSitePageSections(ReorderSitePageSectionsRequest) returns (google.protobuf.Empty){
        option (google.api.http) = { put: "/ReorderSitePageSections" body: "*" };
    };
}

// ── Get Site Page ──
message GetSitePageRequest
{
    int64 id = 1;
}
message GetSitePageByKeyRequest
{
    string page_key = 1;
}
message GetSitePageResponse
{
    int64 id = 1;
    string page_key = 2;
    string title = 3;
    google.protobuf.StringValue meta_description = 4;
    google.protobuf.StringValue hero_title = 5;
    google.protobuf.StringValue hero_subtitle = 6;
    google.protobuf.StringValue hero_image_path = 7;
    bool is_active = 8;
    repeated SitePageSectionItem sections = 9;
}
message SitePageSectionItem
{
    int64 id = 1;
    string section_key = 2;
    string title = 3;
    google.protobuf.StringValue subtitle = 4;
    google.protobuf.StringValue html_content = 5;
    google.protobuf.StringValue icon_name = 6;
    google.protobuf.StringValue image_path = 7;
    google.protobuf.StringValue image_thumbnail_path = 8;
    int32 sort_order = 9;
    bool is_active = 10;
    google.protobuf.StringValue extra_data = 11;
}

// ── Update Site Page ──
message UpdateSitePageRequest
{
    int64 id = 1;
    string title = 2;
    google.protobuf.StringValue meta_description = 3;
    google.protobuf.StringValue hero_title = 4;
    google.protobuf.StringValue hero_subtitle = 5;
    google.protobuf.StringValue hero_image_path = 6;
    bool is_active = 7;
    SitePageImageFileModel image_file = 8;
}

// ── Get All ──
message GetAllSitePagesRequest {}
message GetAllSitePagesResponse
{
    repeated SitePageSummary pages = 1;
}
message SitePageSummary
{
    int64 id = 1;
    string page_key = 2;
    string title = 3;
    bool is_active = 4;
    int32 section_count = 5;
    google.protobuf.Timestamp last_modified = 6;
}

// ── Create Section ──
message CreateSitePageSectionRequest
{
    int64 site_page_id = 1;
    string section_key = 2;
    string title = 3;
    google.protobuf.StringValue subtitle = 4;
    google.protobuf.StringValue html_content = 5;
    google.protobuf.StringValue icon_name = 6;
    google.protobuf.StringValue image_path = 7;
    google.protobuf.StringValue image_thumbnail_path = 8;
    int32 sort_order = 9;
    google.protobuf.StringValue extra_data = 10;
    SitePageImageFileModel image_file = 11;
}
message CreateSitePageSectionResponse
{
    int64 id = 1;
}

// ── Update Section ──
message UpdateSitePageSectionRequest
{
    int64 id = 1;
    string section_key = 2;
    string title = 3;
    google.protobuf.StringValue subtitle = 4;
    google.protobuf.StringValue html_content = 5;
    google.protobuf.StringValue icon_name = 6;
    google.protobuf.StringValue image_path = 7;
    google.protobuf.StringValue image_thumbnail_path = 8;
    int32 sort_order = 9;
    bool is_active = 10;
    google.protobuf.StringValue extra_data = 11;
    SitePageImageFileModel image_file = 12;
}

// ── Delete Section ──
message DeleteSitePageSectionRequest
{
    int64 id = 1;
}

// ── Reorder Sections ──
message ReorderSitePageSectionsRequest
{
    repeated SectionSortItem items = 1;
}
message SectionSortItem
{
    int64 id = 1;
    int32 sort_order = 2;
}

// ── Create Site Page ──
message CreateSitePageRequest
{
    string page_key = 1;
    string title = 2;
    google.protobuf.StringValue meta_description = 3;
    google.protobuf.StringValue hero_title = 4;
    google.protobuf.StringValue hero_subtitle = 5;
    bool is_active = 6;
    SitePageImageFileModel image_file = 7;
}
message CreateSitePageResponse
{
    int64 id = 1;
}

// ── Delete Site Page ──
message DeleteSitePageRequest
{
    int64 id = 1;
}

// ── File upload model for binary image uploads from BackOffice ──
message SitePageImageFileModel
{
    bytes file = 1;
    string mime = 2;
    string file_name = 3;
}
