"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MeGraphqlClient = exports.UserNotFoundError = void 0;
const shared_1 = require("../../shared");
const ui_1 = require("../../ui");
class UserNotFoundError extends shared_1.UserError {
}
exports.UserNotFoundError = UserNotFoundError;
class MeGraphqlClient {
    graphqlClient;
    logger;
    constructor(graphqlClient, logger) {
        this.graphqlClient = graphqlClient;
        this.logger = logger;
    }
    async getUser() {
        try {
            const query = `
        query forge_cli_getUserDetails {
          me {
            user {
              name
              accountStatus
              accountId
            }
          }
        }`;
            const result = await this.graphqlClient.query(query, {});
            if (result.me.user && result.me.user.accountStatus === 'active') {
                return result.me.user;
            }
        }
        catch (error) {
            this.logger.debug((0, ui_1.errorMessage)(error));
        }
        throw new UserNotFoundError();
    }
}
exports.MeGraphqlClient = MeGraphqlClient;
