syntax = "proto3";

package city;

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

service CityContract {
  // Customer Methods - برای مشتریان
  rpc GetCitiesForCustomer(GetCitiesForCustomerRequest) returns (GetCitiesForCustomerResponse) {
    option (google.api.http) = {
      get: "/Customer/Cities/GetCities"
    };
  };

  rpc GetCityByIdForCustomer(GetCityByIdForCustomerRequest) returns (GetCityByIdForCustomerResponse) {
    option (google.api.http) = {
      get: "/Customer/Cities/GetCity/{id}"
    };
  };

  rpc GetCitiesByStateForCustomer(GetCitiesByStateForCustomerRequest) returns (GetCitiesByStateForCustomerResponse) {
    option (google.api.http) = {
      get: "/Customer/Cities/GetCitiesByState/{state_id}"
    };
  };

  // Admin Methods
  rpc GetAllCitiesByFilter(GetAllCitiesByFilterRequest) returns (GetAllCitiesByFilterResponse) {
    option (google.api.http) = {
      get: "/Cities/GetAllCitiesByFilter"
    };
  };

  rpc CreateCity(CreateCityRequest) returns (CreateCityResponse) {
    option (google.api.http) = {
      post: "/Cities/CreateCity"
      body: "*"
    };
  };

  rpc UpdateCity(UpdateCityRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      put: "/Cities/UpdateCity"
      body: "*"
    };
  };

  rpc DeleteCity(DeleteCityRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/Cities/DeleteCity/{id}"
    };
  };
}

// Customer Messages
message GetCitiesForCustomerRequest {
  google.protobuf.Int64Value state_id = 1;
  google.protobuf.StringValue search_term = 2;
  int32 page_number = 3;
  int32 page_size = 4;
}

message GetCitiesForCustomerResponse {
  repeated CityDto cities = 1;
  MetaData meta_data = 2;
}

message GetCityByIdForCustomerRequest {
  int64 id = 1;
}

message GetCityByIdForCustomerResponse {
  CityDto city = 1;
}

message GetCitiesByStateForCustomerRequest {
  int64 state_id = 1;
  int32 page_number = 2;
  int32 page_size = 3;
}

message GetCitiesByStateForCustomerResponse {
  repeated CityDto cities = 1;
  MetaData meta_data = 2;
}

// Admin Messages
message GetAllCitiesByFilterRequest {
  PaginationState pagination_state = 1;
  google.protobuf.StringValue sort_by = 2;
  GetAllCitiesByFilterFilter filter = 3;
}

message GetAllCitiesByFilterFilter {
  google.protobuf.Int64Value id = 1;
  google.protobuf.StringValue name = 2;
  google.protobuf.StringValue native = 3;
  google.protobuf.Int64Value state_id = 4;
}

message GetAllCitiesByFilterResponse {
  MetaData meta_data = 1;
  repeated CityDto cities = 2;
}

message CreateCityRequest {
  int64 external_id = 1;
  string name = 2;
  string native = 3;
  google.protobuf.StringValue latitude = 4;
  google.protobuf.StringValue longitude = 5;
  int64 state_id = 6;
}

message CreateCityResponse {
  int64 id = 1;
  string message = 2;
}

message UpdateCityRequest {
  int64 id = 1;
  int64 external_id = 2;
  string name = 3;
  string native = 4;
  google.protobuf.StringValue latitude = 5;
  google.protobuf.StringValue longitude = 6;
  int64 state_id = 7;
}

message DeleteCityRequest {
  int64 id = 1;
}

// Common DTOs
message CityDto {
  int64 id = 1;
  int64 external_id = 2;
  string name = 3;
  string native = 4;
  google.protobuf.StringValue latitude = 5;
  google.protobuf.StringValue longitude = 6;
  int64 state_id = 7;
  string state_name = 8;
  string state_native = 9;
  google.protobuf.Timestamp created = 10;
  google.protobuf.Timestamp last_modified = 11;
}

// Common Messages
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;
}