syntax = "proto3";
package idm.api2.proto;

import "idm/api2/proto/location.proto";

message ChatData {
    int64 id = 1;
    string username = 2;
    string language = 3;
    bool is_system_messaging_enabled = 4;
    bool is_discovery_enabled = 5;
    int32 ban_until = 6;
    string ban_message = 7;
    bool is_admin = 8;
    string tzinfo = 9;
    bool is_subscribed = 10;
    int64 created_at = 11;
}

message ChatsData {
    repeated ChatData chats = 1;
}

message CreateChatRequest {
    int64 chat_id = 1;
    string username = 2;
    string language = 3;
}

message GetChatRequest {
    int64 chat_id = 1;
}

message ListChatsRequest {
    oneof banned_at_moment_oneof {
        int32 banned_at_moment = 1;
    }
}

message UpdateChatRequest {
    int64 chat_id = 1;
    oneof language_oneof {
        string language = 2;
    }
    oneof is_system_messaging_enabled_oneof {
        bool is_system_messaging_enabled = 3;
    }
    oneof is_discovery_enabled_oneof {
        bool is_discovery_enabled = 4;
    }
    oneof ban_until_oneof {
        int32 ban_until = 5;
    }
    oneof ban_message_oneof {
        string ban_message = 6;
    }
    oneof is_admin_oneof {
        bool is_admin = 7;
    }
    oneof last_location_oneof {
        idm.api2.proto.Location last_location = 8;
    }
}

service Chats {
    rpc create_chat(CreateChatRequest) returns (ChatData) {};
    rpc get_chat(GetChatRequest) returns (ChatData) {};
    rpc list_chats(ListChatsRequest) returns (ChatsData) {};
    rpc update_chat(UpdateChatRequest) returns (ChatData) {};
}
