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

import { attributesCreate } from "../funcs/attributesCreate.js";
import { attributesCreateSelectOption } from "../funcs/attributesCreateSelectOption.js";
import { attributesGet } from "../funcs/attributesGet.js";
import { attributesList } from "../funcs/attributesList.js";
import { attributesListSelectOptions } from "../funcs/attributesListSelectOptions.js";
import { attributesListStatuses } from "../funcs/attributesListStatuses.js";
import { attributesUpdate } from "../funcs/attributesUpdate.js";
import { attributesUpdateOption } from "../funcs/attributesUpdateOption.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import {
  GetV2TargetIdentifierAttributesRequest,
  GetV2TargetIdentifierAttributesResponse,
} from "../models/operations/getv2targetidentifierattributes.js";
import {
  GetV2TargetIdentifierAttributesAttributeRequest,
  GetV2TargetIdentifierAttributesAttributeResponse,
} from "../models/operations/getv2targetidentifierattributesattribute.js";
import {
  GetV2TargetIdentifierAttributesAttributeOptionsRequest,
  GetV2TargetIdentifierAttributesAttributeOptionsResponse,
} from "../models/operations/getv2targetidentifierattributesattributeoptions.js";
import {
  GetV2TargetIdentifierAttributesAttributeStatusesRequest,
  GetV2TargetIdentifierAttributesAttributeStatusesResponse,
} from "../models/operations/getv2targetidentifierattributesattributestatuses.js";
import {
  PatchV2TargetIdentifierAttributesAttributeRequest,
  PatchV2TargetIdentifierAttributesAttributeResponse,
} from "../models/operations/patchv2targetidentifierattributesattribute.js";
import {
  PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest,
  PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse,
} from "../models/operations/patchv2targetidentifierattributesattributeoptionsoption.js";
import {
  PostV2TargetIdentifierAttributesRequest,
  PostV2TargetIdentifierAttributesResponse,
} from "../models/operations/postv2targetidentifierattributes.js";
import {
  PostV2TargetIdentifierAttributesAttributeOptionsRequest,
  PostV2TargetIdentifierAttributesAttributeOptionsResponse,
} from "../models/operations/postv2targetidentifierattributesattributeoptions.js";
import { unwrapAsync } from "../types/fp.js";
import { Statuses } from "./statuses.js";

export class Attributes extends ClientSDK {
  private _statuses?: Statuses;
  get statuses(): Statuses {
    return (this._statuses ??= new Statuses(this._options));
  }

  /**
   * List attributes
   *
   * @remarks
   * Lists all attributes defined on a specific object or list. Attributes are returned in the order that they are sorted by in the UI.
   *
   * Required scopes: `object_configuration:read`.
   */
  async list(
    request: GetV2TargetIdentifierAttributesRequest,
    options?: RequestOptions,
  ): Promise<GetV2TargetIdentifierAttributesResponse> {
    return unwrapAsync(attributesList(
      this,
      request,
      options,
    ));
  }

  /**
   * Create an attribute
   *
   * @remarks
   * Creates a new attribute on either an object or a list.
   *
   * To create an attribute on an object, you must also have the `object_configuration:read-write` scope.
   *
   * To create an attribute on a list, you must also have the `list_configuration:read-write` scope.
   */
  async create(
    request: PostV2TargetIdentifierAttributesRequest,
    options?: RequestOptions,
  ): Promise<PostV2TargetIdentifierAttributesResponse> {
    return unwrapAsync(attributesCreate(
      this,
      request,
      options,
    ));
  }

  /**
   * Get an attribute
   *
   * @remarks
   * Gets information about a single attribute on either an object or a list.
   *
   * Required scopes: `object_configuration:read`.
   */
  async get(
    request: GetV2TargetIdentifierAttributesAttributeRequest,
    options?: RequestOptions,
  ): Promise<GetV2TargetIdentifierAttributesAttributeResponse> {
    return unwrapAsync(attributesGet(
      this,
      request,
      options,
    ));
  }

  /**
   * Update an attribute
   *
   * @remarks
   * Updates a single attribute on a given object or list.
   *
   * Required scopes: `object_configuration:read-write`.
   */
  async update(
    request: PatchV2TargetIdentifierAttributesAttributeRequest,
    options?: RequestOptions,
  ): Promise<PatchV2TargetIdentifierAttributesAttributeResponse> {
    return unwrapAsync(attributesUpdate(
      this,
      request,
      options,
    ));
  }

  /**
   * List select options
   *
   * @remarks
   * Lists all select options for a particular attribute on either an object or a list.
   *
   * Required scopes: `object_configuration:read`.
   */
  async listSelectOptions(
    request: GetV2TargetIdentifierAttributesAttributeOptionsRequest,
    options?: RequestOptions,
  ): Promise<GetV2TargetIdentifierAttributesAttributeOptionsResponse> {
    return unwrapAsync(attributesListSelectOptions(
      this,
      request,
      options,
    ));
  }

  /**
   * Create a select option
   *
   * @remarks
   * Adds a select option to a select attribute on an object or a list.
   *
   * Required scopes: `object_configuration:read-write`.
   */
  async createSelectOption(
    request: PostV2TargetIdentifierAttributesAttributeOptionsRequest,
    options?: RequestOptions,
  ): Promise<PostV2TargetIdentifierAttributesAttributeOptionsResponse> {
    return unwrapAsync(attributesCreateSelectOption(
      this,
      request,
      options,
    ));
  }

  /**
   * Update a select option
   *
   * @remarks
   * Updates a select option on an attribute on either an object or a list.
   *
   * Required scopes: `object_configuration:read-write`.
   */
  async updateOption(
    request: PatchV2TargetIdentifierAttributesAttributeOptionsOptionRequest,
    options?: RequestOptions,
  ): Promise<PatchV2TargetIdentifierAttributesAttributeOptionsOptionResponse> {
    return unwrapAsync(attributesUpdateOption(
      this,
      request,
      options,
    ));
  }

  /**
   * List statuses
   *
   * @remarks
   * Lists all statuses for a particular status attribute on either an object or a list.
   *
   * Required scopes: `object_configuration:read`.
   */
  async listStatuses(
    request: GetV2TargetIdentifierAttributesAttributeStatusesRequest,
    options?: RequestOptions,
  ): Promise<GetV2TargetIdentifierAttributesAttributeStatusesResponse> {
    return unwrapAsync(attributesListStatuses(
      this,
      request,
      options,
    ));
  }
}
