"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserFunctions = void 0;
const gql_1 = require("../gql");
const BaseFunctions_1 = require("./BaseFunctions");
class UserFunctions extends BaseFunctions_1.BaseFunctions {
    constructor(client) {
        super(client);
    }
    async getUser(where) {
        const query = (0, gql_1.graphql)(`
      query GetUser($where: UserWhereUniqueInput!) {
        user(where: $where) {
          id
          name
          role
          apiKey
          email
        }
      }
    `);
        return this.request(query, { where });
    }
    async createUser(userData) {
        const mutation = (0, gql_1.graphql)(`
      mutation CreateUser($data: UserCreateInput!) {
        createOneUser(data: $data) {
          id
          name
          role
          apiKey
          email
        }
      }
    `);
        return this.request(mutation, { data: userData });
    }
    async updateUser(userId, userData) {
        const mutation = (0, gql_1.graphql)(`
      mutation UpdateUser($where: UserWhereUniqueInput!, $data: UserUpdateInput!) {
        updateOneUser(where: $where, data: $data) {
          id
          name
          role
          apiKey
          email
        }
      }
    `);
        const variables = {
            where: { id: userId },
            data: userData,
        };
        return this.request(mutation, variables);
    }
    async deleteUser(userId) {
        const mutation = (0, gql_1.graphql)(`
      mutation DeleteUser($where: UserWhereUniqueInput!) {
        deleteOneUser(where: $where) {
          id
        }
      }
    `);
        const variables = { where: { id: userId } };
        return this.request(mutation, variables);
    }
}
exports.UserFunctions = UserFunctions;
