syntax = "proto3";

package messages;

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

service PublicMessageContract{
    rpc CreatePublicMessage(CreatePublicMessageRequest) returns (CreatePublicMessageResponse){
        option (google.api.http) = {
            post: "/CreatePublicMessage"
            body: "*"
        };
    };
    rpc UpdatePublicMessage(UpdatePublicMessageRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            put: "/UpdatePublicMessage"
            body: "*"
        };
    };
    rpc DeletePublicMessage(DeletePublicMessageRequest) returns (google.protobuf.Empty){
        option (google.api.http) = {
            delete: "/DeletePublicMessage"
            body: "*"
        };
    };
    rpc PublishMessage(PublishMessageRequest) returns (PublishMessageResponse){
        option (google.api.http) = {
            post: "/PublishMessage"
            body: "*"
        };
    };
    rpc ArchiveMessage(ArchiveMessageRequest) returns (ArchiveMessageResponse){
        option (google.api.http) = {
            post: "/ArchiveMessage"
            body: "*"
        };
    };
    rpc GetAllMessages(GetAllMessagesRequest) returns (GetAllMessagesResponse){
        option (google.api.http) = {
            get: "/GetAllMessages"
        };
    };
    rpc GetActiveMessages(GetActiveMessagesRequest) returns (GetActiveMessagesResponse){
        option (google.api.http) = {
            get: "/GetActiveMessages"
        };
    };
    rpc GetPublicMessage(GetPublicMessageRequest) returns (GetPublicMessageResponse){
        option (google.api.http) = {
            get: "/GetPublicMessage"
        };
    };
}
message PaginationState
{
  int32 page_number = 1;

  int32 page_size = 2;
}
message MetaData
{
  int64 current_page = 1;

  int64 total_page = 2;

  int64 page_size = 3;

  int64 total_count = 4;

  bool has_previous = 5;

  bool has_next = 6;
}
message DecimalValue 
{

    int64 units = 1;

    sfixed32 nanos = 2;
}
enum PaymentStatus
{
  Success = 0;
  Reject = 1;
  Pending = 2;
}
// وضعیت ارسال سفارش
enum DeliveryStatus
{
  // نامشخص / نیاز به ارسال ندارد (مثلا سفارش پکیج)
  DeliveryStatus_None = 0;
  // ثبت شده و در انتظار آماده‌سازی/ارسال
  DeliveryStatus_Pending = 1;
  // تحویل پست/حمل‌ونقل شده است
  DeliveryStatus_InTransit = 2;
  // توسط مشتری دریافت شده است
  DeliveryStatus_Delivered = 3;
  // مرجوع شده
  DeliveryStatus_Returned = 4;
  // لغو شده
  DeliveryStatus_Cancelled = 5;
  // آماده تحویل حضوری در دفتر
  DeliveryStatus_ReadyForOfficePickup = 6;
}
enum TransactionType
{
  Buy = 0;
  DepositIpg = 1;
  DepositExternal1 = 2;
  Withdraw = 3;
  NetworkCommission = 10;
  ClubActivation = 11;
  DiscountWalletCharge = 12;
  DiscountShopPurchase = 13;
  MagicWalletDeposit = 14;
  MagicWalletBonus = 15;
  CreditWalletCharge = 16;
  ManualCreditWalletCharge = 17;
}
enum ContractType
{
  Main = 0;
  CMS = 1;
}
enum PaymentMethod
{
  IPG = 0;
  Wallet = 1;
}

// Public Message Types
message CreatePublicMessageRequest
{
    string title = 1;
    string content = 2;
    int32 type = 3;
    int32 priority = 4;
    google.protobuf.Timestamp start_date = 5;
    google.protobuf.Timestamp end_date = 6;
    google.protobuf.StringValue link_url = 7;
    google.protobuf.StringValue link_text = 8;
}

message CreatePublicMessageResponse
{
    int64 id = 1;
}

message UpdatePublicMessageRequest
{
    int64 id = 1;
    string title = 2;
    string content = 3;
    int32 type = 4;
    int32 priority = 5;
    google.protobuf.Timestamp start_date = 6;
    google.protobuf.Timestamp end_date = 7;
    google.protobuf.StringValue link_url = 8;
    google.protobuf.StringValue link_text = 9;
}

message DeletePublicMessageRequest
{
    int64 message_id = 1;
}

message PublishMessageRequest
{
    int64 message_id = 1;
}

message PublishMessageResponse
{
    bool success = 1;
    string message = 2;
    google.protobuf.Timestamp published_at = 3;
}

message ArchiveMessageRequest
{
    int64 message_id = 1;
}

message ArchiveMessageResponse
{
    bool success = 1;
    string message = 2;
    google.protobuf.Timestamp archived_at = 3;
}

message GetAllMessagesRequest
{
    int32 page_number = 1;
    int32 page_size = 2;
    google.protobuf.BoolValue is_active = 3;
    google.protobuf.Int32Value type = 4;
    google.protobuf.Int32Value priority = 5;
}

message GetAllMessagesResponse
{
    MetaData meta_data = 1;
    repeated AdminPublicMessageDto messages = 2;
}

message AdminPublicMessageDto
{
    int64 id = 1;
    string title = 2;
    string content = 3;
    int32 type = 4;
    string type_name = 5;
    int32 priority = 6;
    string priority_name = 7;
    bool is_active = 8;
    google.protobuf.Timestamp starts_at = 9;
    google.protobuf.Timestamp expires_at = 10;
    int64 created_by_user_id = 11;
    int32 view_count = 12;
    google.protobuf.StringValue link_url = 13;
    google.protobuf.StringValue link_text = 14;
    google.protobuf.Timestamp created = 15;
    google.protobuf.Timestamp last_modified = 16;
    bool is_expired = 17;
}

message GetActiveMessagesRequest
{
}

message GetActiveMessagesResponse
{
    repeated PublicMessageDto messages = 1;
}

message PublicMessageDto
{
    int64 id = 1;
    string title = 2;
    string content = 3;
    int32 type = 4;
    string type_name = 5;
    int32 priority = 6;
    string priority_name = 7;
    google.protobuf.Timestamp starts_at = 8;
    google.protobuf.Timestamp expires_at = 9;
    google.protobuf.StringValue link_url = 10;
    google.protobuf.StringValue link_text = 11;
    google.protobuf.Timestamp created = 12;
}

message GetPublicMessageRequest
{
    int64 message_id = 1;
}

message GetPublicMessageResponse
{
    int64 id = 1;
    string title = 2;
    string content = 3;
    int32 type = 4;
    int32 priority = 5;
    bool is_active = 6;
    bool is_archived = 7;
    google.protobuf.Timestamp start_date = 8;
    google.protobuf.Timestamp end_date = 9;
    google.protobuf.Timestamp published_at = 10;
    google.protobuf.Timestamp archived_at = 11;
    int64 created_by_user_id = 12;
    int32 view_count = 13;
    google.protobuf.StringValue link_url = 14;
    google.protobuf.StringValue link_text = 15;
    google.protobuf.Timestamp created_at = 16;
    google.protobuf.Timestamp last_modified_at = 17;
}

