"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeedbackFunctions = void 0;
const gql_1 = require("../gql");
const BaseFunctions_1 = require("./BaseFunctions");
class FeedbackFunctions extends BaseFunctions_1.BaseFunctions {
    constructor(client) {
        super(client);
    }
    async listFeedback(options) {
        const query = (0, gql_1.graphql)(`
      query ListFeedback(
        $where: FeedbackWhereInput
        $cursor: FeedbackWhereUniqueInput
        $orderBy: [FeedbackOrderByWithRelationInput!]
        $take: Int
        $skip: Int
        $distinct: [FeedbackScalarFieldEnum!]
      ) {
        feedbacks(
          where: $where
          cursor: $cursor
          orderBy: $orderBy
          take: $take
          skip: $skip
          distinct: $distinct
        ) {
          content
          createdAt
          id
          labelId
          updatedAt
          upvote
          userId
        }
      }
    `);
        return this.client.request(query, options);
    }
    async getFeedback(where) {
        const query = (0, gql_1.graphql)(`
      query GetFeedback($where: FeedbackWhereUniqueInput!) {
        feedback(where: $where) {
          id
          userId
          upvote
          content
          labelId
        }
      }
    `);
        return this.client.request(query, { where });
    }
    async createFeedback(feedbackData) {
        const mutation = (0, gql_1.graphql)(`
      mutation CreateFeedback($data: FeedbackCreateInput!) {
        createOneFeedback(data: $data) {
          id
          userId
          upvote
          content
          labelId
        }
      }
    `);
        return this.client.request(mutation, { data: feedbackData });
    }
    async createManyFeedbacks(feedbackVariables) {
        const mutation = (0, gql_1.graphql)(`
      mutation CreateManyFeedbacks($data: [FeedbackCreateManyInput!]!) {
        createManyFeedback(data: $data) {
          count
        }
      }
    `);
        return this.client.request(mutation, { data: feedbackVariables });
    }
    async updateFeedback(feedbackId, feedbackData) {
        const mutation = (0, gql_1.graphql)(`
      mutation UpdateFeedback($where: FeedbackWhereUniqueInput!, $data: FeedbackUpdateInput!) {
        updateOneFeedback(where: $where, data: $data) {
          id
          userId
          upvote
          content
          labelId
        }
      }
    `);
        const variables = {
            where: { id: feedbackId },
            data: feedbackData,
        };
        return this.request(mutation, variables);
    }
    async deleteFeedback(feedbackId) {
        const mutation = (0, gql_1.graphql)(`
      mutation DeleteFeedback($where: FeedbackWhereUniqueInput!) {
        deleteOneFeedback(where: $where) {
          id
        }
      }
    `);
        const variables = { where: { id: feedbackId } };
        return this.request(mutation, variables);
    }
}
exports.FeedbackFunctions = FeedbackFunctions;
