/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { contextsCreate } from "../funcs/contextsCreate.js"; import { contextsDelete } from "../funcs/contextsDelete.js"; import { contextsList } from "../funcs/contextsList.js"; import { contextsRetrieve } from "../funcs/contextsRetrieve.js"; import { contextsUpdate } from "../funcs/contextsUpdate.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; import * as operations from "../models/operations/index.js"; import { unwrapAsync } from "../types/fp.js"; export class Contexts extends ClientSDK { /** * Create a context * * @remarks * Create a new context with the specified type, id, and data. Returns 409 if context already exists. * **type** and **id** are required fields, **data** is optional, if the context already exists, it returns the 409 response */ async create( createContextRequestDto: components.CreateContextRequestDto, idempotencyKey?: string | undefined, options?: RequestOptions, ): Promise { return unwrapAsync(contextsCreate( this, createContextRequestDto, idempotencyKey, options, )); } /** * List all contexts * * @remarks * Retrieve a paginated list of all contexts, optionally filtered by type and key pattern. * **type** and **id** are optional fields, if provided, only contexts with the matching type and id will be returned. * **search** is an optional field, if provided, only contexts with the matching key pattern will be returned. * Checkout all possible parameters in the query section below for more details */ async list( request: operations.ContextsControllerListContextsRequest, options?: RequestOptions, ): Promise { return unwrapAsync(contextsList( this, request, options, )); } /** * Update a context * * @remarks * Update the data of an existing context. * **type** and **id** are required fields, **data** is required. Only the data field is updated, the rest of the context is not affected. * If the context does not exist, it returns the 404 response */ async update( request: operations.ContextsControllerUpdateContextRequest, options?: RequestOptions, ): Promise { return unwrapAsync(contextsUpdate( this, request, options, )); } /** * Retrieve a context * * @remarks * Retrieve a specific context by its type and id. * **type** and **id** are required fields, if the context does not exist, it returns the 404 response */ async retrieve( id: string, type: string, idempotencyKey?: string | undefined, options?: RequestOptions, ): Promise { return unwrapAsync(contextsRetrieve( this, id, type, idempotencyKey, options, )); } /** * Delete a context * * @remarks * Delete a context by its type and id. * **type** and **id** are required fields, if the context does not exist, it returns the 404 response */ async delete( id: string, type: string, idempotencyKey?: string | undefined, options?: RequestOptions, ): Promise { return unwrapAsync(contextsDelete( this, id, type, idempotencyKey, options, )); } }