/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import { webhooksCreate } from "../funcs/webhooksCreate.js";
import { webhooksDelete } from "../funcs/webhooksDelete.js";
import { webhooksGet } from "../funcs/webhooksGet.js";
import { webhooksList } from "../funcs/webhooksList.js";
import { webhooksPartialUpdate } from "../funcs/webhooksPartialUpdate.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import {
  DeleteV2WebhooksWebhookIdRequest,
  DeleteV2WebhooksWebhookIdResponse,
} from "../models/operations/deletev2webhookswebhookid.js";
import {
  GetV2WebhooksRequest,
  GetV2WebhooksResponse,
} from "../models/operations/getv2webhooks.js";
import {
  GetV2WebhooksWebhookIdRequest,
  GetV2WebhooksWebhookIdResponse,
} from "../models/operations/getv2webhookswebhookid.js";
import {
  PatchV2WebhooksWebhookIdRequest,
  PatchV2WebhooksWebhookIdResponse,
} from "../models/operations/patchv2webhookswebhookid.js";
import {
  PostV2WebhooksRequest,
  PostV2WebhooksResponse,
} from "../models/operations/postv2webhooks.js";
import { unwrapAsync } from "../types/fp.js";

export class Webhooks extends ClientSDK {
  /**
   * List webhooks
   *
   * @remarks
   * Get all of the webhooks in your workspace.
   *
   * Required scopes: `webhook:read`.
   */
  async list(
    request: GetV2WebhooksRequest,
    options?: RequestOptions,
  ): Promise<GetV2WebhooksResponse> {
    return unwrapAsync(webhooksList(
      this,
      request,
      options,
    ));
  }

  /**
   * Create a webhook
   *
   * @remarks
   * Create a webhook and associated subscriptions.
   *
   * Required scopes: `webhook:read-write`.
   */
  async create(
    request: PostV2WebhooksRequest,
    options?: RequestOptions,
  ): Promise<PostV2WebhooksResponse> {
    return unwrapAsync(webhooksCreate(
      this,
      request,
      options,
    ));
  }

  /**
   * Get a webhook
   *
   * @remarks
   * Get a single webhook.
   *
   * Required scopes: `webhook:read`.
   */
  async get(
    request: GetV2WebhooksWebhookIdRequest,
    options?: RequestOptions,
  ): Promise<GetV2WebhooksWebhookIdResponse> {
    return unwrapAsync(webhooksGet(
      this,
      request,
      options,
    ));
  }

  /**
   * Update a webhook
   *
   * @remarks
   * Update a webhook and associated subscriptions.
   *
   * Required scopes: `webhook:read-write`.
   */
  async partialUpdate(
    request: PatchV2WebhooksWebhookIdRequest,
    options?: RequestOptions,
  ): Promise<PatchV2WebhooksWebhookIdResponse> {
    return unwrapAsync(webhooksPartialUpdate(
      this,
      request,
      options,
    ));
  }

  /**
   * Delete a webhook
   *
   * @remarks
   * Delete a webhook by ID.
   *
   * Required scopes: `webhook:read-write`.
   */
  async delete(
    request: DeleteV2WebhooksWebhookIdRequest,
    options?: RequestOptions,
  ): Promise<DeleteV2WebhooksWebhookIdResponse> {
    return unwrapAsync(webhooksDelete(
      this,
      request,
      options,
    ));
  }
}
