UNPKG

@visionfi/server-sdk

Version:

Server-side SDK for VisionFI API access using Google Service Account authentication

128 lines (127 loc) 4.92 kB
import { AxiosInstance } from 'axios'; import { DocuSignConnectWebhook, DocuSignConnectWebhooksResponse, DocuSignConnectWebhookResponse, DocuSignConnectWebhookDeleteResponse } from './types.js'; /** * Class for managing DocuSign Connect webhook configurations. * Provides methods to get, create, update, and delete webhook configurations. */ export declare class DocuSignConnectManager { private apiClient; /** * Creates a new DocuSignConnectManager instance. * * @param apiClient - The Axios instance used for API requests */ constructor(apiClient: AxiosInstance); /** * Retrieves all webhook configurations for the client's DocuSign integration. * * @returns A promise that resolves to the list of webhook configurations * * @example * ```typescript * const webhooksResponse = await connectManager.getWebhooks(); * * if (webhooksResponse.success) { * console.log('DocuSign webhooks:', webhooksResponse.data); * } else { * console.error('Failed to get webhooks:', webhooksResponse.message); * } * ``` */ getWebhooks(): Promise<DocuSignConnectWebhooksResponse>; /** * Retrieves a specific webhook configuration by its GUID. * * @param webhookGuid - The unique identifier for the webhook configuration * @returns A promise that resolves to the specific webhook configuration * * @example * ```typescript * const webhookGuid = 'd0381ee4-5b83-4d6b-9f37-177c2a6a79f2'; * const webhookResponse = await connectManager.getWebhook(webhookGuid); * * if (webhookResponse.success) { * console.log('DocuSign webhook:', webhookResponse.data); * } else { * console.error('Failed to get webhook:', webhookResponse.message); * } * ``` */ getWebhook(webhookGuid: string): Promise<DocuSignConnectWebhookResponse>; /** * Creates a new DocuSign Connect webhook configuration. * * @param webhook - The webhook configuration to create * @returns A promise that resolves to the created webhook configuration * * @example * ```typescript * const newWebhook = { * webhookGuid: 'd0381ee4-5b83-4d6b-9f37-177c2a6a79f2', * hmacSecret: '89c3444a-f4c2-4fda-98b8-59dc2fe3ea29', * workflowId: 'electronic-signatures-workflow' * }; * * const webhookResponse = await connectManager.addWebhook(newWebhook); * * if (webhookResponse.success) { * console.log('DocuSign webhook created:', webhookResponse.data); * } else { * console.error('Failed to create webhook:', webhookResponse.message); * } * ``` */ addWebhook(webhook: DocuSignConnectWebhook): Promise<DocuSignConnectWebhookResponse>; /** * Updates an existing DocuSign Connect webhook configuration. * * @param webhookGuid - The unique identifier for the webhook configuration * @param webhook - The partial webhook configuration to update * @returns A promise that resolves to the updated webhook configuration * * @example * ```typescript * const webhookGuid = 'd0381ee4-5b83-4d6b-9f37-177c2a6a79f2'; * const webhookUpdate = { * hmacSecret: 'updated-hmac-secret-value', * workflowId: 'updated-workflow-id' * }; * * const webhookResponse = await connectManager.updateWebhook(webhookGuid, webhookUpdate); * * if (webhookResponse.success) { * console.log('DocuSign webhook updated:', webhookResponse.data); * } else { * console.error('Failed to update webhook:', webhookResponse.message); * } * ``` */ updateWebhook(webhookGuid: string, webhook: Partial<Omit<DocuSignConnectWebhook, 'webhookGuid'>>): Promise<DocuSignConnectWebhookResponse>; /** * Deletes a DocuSign Connect webhook configuration. * * @param webhookGuid - The unique identifier for the webhook configuration * @returns A promise that resolves to the deletion response * * @example * ```typescript * const webhookGuid = 'd0381ee4-5b83-4d6b-9f37-177c2a6a79f2'; * const deleteResponse = await connectManager.deleteWebhook(webhookGuid); * * if (deleteResponse.success) { * console.log('DocuSign webhook deleted:', deleteResponse.message); * } else { * console.error('Failed to delete webhook:', deleteResponse.message); * } * ``` */ deleteWebhook(webhookGuid: string): Promise<DocuSignConnectWebhookDeleteResponse>; /** * Handles errors from API calls and formats them for the client. * * @param error - The error object from the failed API call * @param defaultMessage - A default message to use if no specific message is available * @returns A VisionFiError with the appropriate message and status code */ private handleError; }