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

import { objectsCreate } from "../funcs/objectsCreate.js";
import { objectsGet } from "../funcs/objectsGet.js";
import { objectsList } from "../funcs/objectsList.js";
import { objectsPartialUpdate } from "../funcs/objectsPartialUpdate.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import { GetV2ObjectsResponse } from "../models/operations/getv2objects.js";
import {
  GetV2ObjectsObjectRequest,
  GetV2ObjectsObjectResponse,
} from "../models/operations/getv2objectsobject.js";
import {
  PatchV2ObjectsObjectRequest,
  PatchV2ObjectsObjectResponse,
} from "../models/operations/patchv2objectsobject.js";
import {
  PostV2ObjectsRequest,
  PostV2ObjectsResponse,
} from "../models/operations/postv2objects.js";
import { unwrapAsync } from "../types/fp.js";

export class Objects extends ClientSDK {
  /**
   * List objects
   *
   * @remarks
   * Lists all system-defined and user-defined objects in your workspace.
   *
   * Required scopes: `object_configuration:read`.
   */
  async list(
    options?: RequestOptions,
  ): Promise<GetV2ObjectsResponse> {
    return unwrapAsync(objectsList(
      this,
      options,
    ));
  }

  /**
   * Create an object
   *
   * @remarks
   * Creates a new custom object in your workspace.
   *
   * Required scopes: `object_configuration:read-write`.
   */
  async create(
    request: PostV2ObjectsRequest,
    options?: RequestOptions,
  ): Promise<PostV2ObjectsResponse> {
    return unwrapAsync(objectsCreate(
      this,
      request,
      options,
    ));
  }

  /**
   * Get an object
   *
   * @remarks
   * Gets a single object by its `object_id` or slug.
   *
   * Required scopes: `object_configuration:read`.
   */
  async get(
    request: GetV2ObjectsObjectRequest,
    options?: RequestOptions,
  ): Promise<GetV2ObjectsObjectResponse> {
    return unwrapAsync(objectsGet(
      this,
      request,
      options,
    ));
  }

  /**
   * Update an object
   *
   * @remarks
   * Updates a single object. The object to be updated is identified by its `object_id`.
   *
   * Required scopes: `object_configuration:read-write`.
   */
  async partialUpdate(
    request: PatchV2ObjectsObjectRequest,
    options?: RequestOptions,
  ): Promise<PatchV2ObjectsObjectResponse> {
    return unwrapAsync(objectsPartialUpdate(
      this,
      request,
      options,
    ));
  }
}
