import { BlockUserResponse, GeneralFriendResponse, JsonStatus, Listing, UserAboutResponse, UserDataByAccountIdsResponse, UserTrophiesResponse, } from '@devvit/protos';
import { Empty } from '@devvit/protos/types/google/protobuf/empty.js';
import { BoolValue } from '@devvit/protos/types/google/protobuf/wrappers.js';
import { RedditAPI } from './RedditAPI.js';
export class Users extends RedditAPI {
    async BlockUser(request, metadata) {
        const response = await this._fetch('BlockUser', request, metadata);
        return BlockUserResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async Friend(request, metadata) {
        const response = await this._fetch('Friend', request, metadata);
        return JsonStatus.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async ReportUser(request, metadata) {
        await this._fetch('ReportUser', request, metadata);
        return Empty.fromJSON({});
    }
    async SetPermissions(request, metadata) {
        const response = await this._fetch('SetPermissions', request, metadata);
        return JsonStatus.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async Unfriend(request, metadata) {
        await this._fetch('Unfriend', request, metadata);
        return Empty.fromJSON({});
    }
    async UserDataByAccountIds(request, metadata) {
        const response = await this._fetch('UserDataByAccountIds', request, metadata);
        if (response.status === 404)
            // user is unknown.
            return { users: {} };
        return UserDataByAccountIdsResponse.fromJSON({
            users: this._decodeAndValidateResponseJSON(response),
        });
    }
    async UsernameAvailable(request, metadata) {
        const response = await this._fetch('UsernameAvailable', request, metadata);
        return BoolValue.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UnfriendUser(request, metadata) {
        await this._fetch('UnfriendUser', request, metadata);
        return Empty.fromJSON({});
    }
    async GetFriendInformation(request, metadata) {
        const response = await this._fetch('GetFriendInformation', request, metadata);
        return GeneralFriendResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UpdateFriendRelationship(request, metadata) {
        const response = await this._fetch('UpdateFriendRelationship', request, metadata);
        return GeneralFriendResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UserTrophies(request, metadata) {
        const response = await this._fetch('UserTrophies', request, metadata);
        return UserTrophiesResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UserAbout(request, metadata) {
        const response = await this._fetch('UserAbout', request, metadata);
        return UserAboutResponse.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
    async UserWhere(request, metadata) {
        const response = await this._fetch('UserWhere', request, metadata);
        return Listing.fromJSON(this._decodeAndValidateResponseJSON(response));
    }
}
