import { ApproveConversationResponse, ArchiveConversationResponse, BulkReadConversationsResponse, ConversationUserData, CreateConversationMessageResponse, CreateConversationResponse, GetConversationResponse, GetConversationsResponse, HighlightConversationResponse, MuteConversationResponse, SubredditsResponse, TempBanResponse, UnreadCountResponse, } from '@devvit/protos';
import { Empty } from '@devvit/protos/types/google/protobuf/empty.js';
import { RedditAPI } from './RedditAPI.js';
export class NewModmail extends RedditAPI {
    async BulkReadConversations(request, metadata) {
        const response = await this._fetch('BulkReadConversations', request, metadata);
        return BulkReadConversationsResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async GetConversations(request, metadata) {
        const response = await this._fetch('GetConversations', request, metadata);
        return GetConversationsResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async CreateConversation(request, metadata) {
        // If no value was passed the `to` field then the protos will map it to undefined which will end up as "to=undefined"
        // in the API call to r2 which will result in the user with username "undefined" being included in the modmail
        // discussion. So check to see if a value was provided for `to` and if not remove it from the request object
        if (!request.to) {
            delete request.to;
        }
        const response = await this._fetch('CreateConversation', request, metadata);
        return CreateConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async GetConversation(request, metadata) {
        const response = await this._fetch('GetConversation', request, metadata);
        return GetConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async CreateConversationMessage(request, metadata) {
        const response = await this._fetch('CreateConversationMessage', request, metadata);
        return CreateConversationMessageResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async ApproveConversation(request, metadata) {
        const response = await this._fetch('ApproveConversation', request, metadata);
        return ApproveConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async ArchiveConversation(request, metadata) {
        const response = await this._fetch('ArchiveConversation', request, metadata);
        return ArchiveConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async DisapproveConversation(request, metadata) {
        const response = await this._fetch('DisapproveConversation', request, metadata);
        return ApproveConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UnhighlightConversation(request, metadata) {
        const response = await this._fetch('UnhighlightConversation', request, metadata);
        return HighlightConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async HighlightConversation(request, metadata) {
        const response = await this._fetch('HighlightConversation', request, metadata);
        return HighlightConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async MuteConversation(request, metadata) {
        const response = await this._fetch('MuteConversation', request, metadata);
        return MuteConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async TempBan(request, metadata) {
        const response = await this._fetch('TempBan', request, metadata);
        return TempBanResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UnarchiveConversation(request, metadata) {
        const response = await this._fetch('UnarchiveConversation', request, metadata);
        return ArchiveConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async Unban(request, metadata) {
        const response = await this._fetch('Unban', request, metadata);
        return TempBanResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UnmuteConversation(request, metadata) {
        const response = await this._fetch('UnmuteConversation', request, metadata);
        return MuteConversationResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UserConversations(request, metadata) {
        const response = await this._fetch('UserConversations', request, metadata);
        return ConversationUserData.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async Read(request, metadata) {
        await this._fetch('Read', request, metadata);
        return Empty.fromPartial({});
    }
    async Subreddits(request, metadata) {
        const response = await this._fetch('Subreddits', request, metadata);
        return SubredditsResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async Unread(request, metadata) {
        await this._fetch('Unread', request, metadata);
        return Empty.fromPartial({});
    }
    async UnreadCount(request, metadata) {
        const response = await this._fetch('UnreadCount', request, metadata);
        return UnreadCountResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
}
