@docusign/iam-sdk
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@docusign/iam-sdk* API.
121 lines • 7.23 kB
JavaScript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import { encodeSimple } from "../lib/encodings.js";
import * as M from "../lib/matchers.js";
import { compactMap } from "../lib/primitives.js";
import { safeParse } from "../lib/schemas.js";
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
import { pathToFunc } from "../lib/url.js";
import * as components from "../models/components/index.js";
import * as errors from "../models/errors/index.js";
import * as operations from "../models/operations/index.js";
import { APIPromise } from "../types/async.js";
/**
* Retrieve detailed information about a specific agreement
*
* @remarks
* This operation retrieves detailed information about a specific agreement, identified by its unique `id`. The response provides a comprehensive view of the agreement, including its title, type, status, summary, and the full list of involved parties.
*
* In addition to general details, the operation returns provisions that define the agreement's legal, financial, lifecycle, and custom conditions. It also provides key metadata, such as creation and modification timestamps, related agreements, and user-defined or custom attributes, which help represent the structure and context of the agreement.
*
* The operation is essential for retrieving the full context of an agreement, enabling users to understand the contract's scope, key provisions, and the legal or financial obligations that have been agreed upon.
*
* ### Use Cases:
* - **Integrating agreement data into external systems**: Sync detailed agreement information, such as legal and financial provisions, into external systems like ERP, CRM, or contract management tools to streamline workflows.
* - **Providing detailed data for RAG (Retrieval-Augmented Generation) applications or Copilots**: Retrieve detailed agreement data for use in LLM-based applications that answer specific user queries about their agreements, such as the status of a contract, its provisions, or involved parties.
* - **Retrieving the complete details of a specific agreement**: Use the full details of the agreement, including legal and financial provisions, for auditing, compliance, or review purposes.
* - **Accessing agreement provisions for verification**: Verify compliance with specific legal or financial terms of the agreement, ensuring that all parties are following the agreed-upon conditions.
* - **Tracking agreement changes and history**: Fetch metadata and related agreements to understand the evolution of an agreement, including modifications, associated agreements, and additional context provided by custom fields.
* - **Reviewing user-defined or custom attributes**: Examine custom fields or attributes to get more context about the agreement, particularly where the business has defined custom provisions or attributes.
*
* ### Key Features:
* - **Detailed Agreement Overview**: Provides a comprehensive view of a specific agreement, including its title, type, status, summary, and more.
* - **Provisions for Legal, Financial, and Lifecycle Conditions**: Includes the full set of provisions that define the terms and conditions of the agreement, making it ideal for compliance and auditing purposes.
* - **Metadata and History**: Tracks the agreement’s history through metadata such as creation and modification dates and user-defined fields.
* - **Data Source for AI Applications**: Enables LLM-based applications to access granular agreement data, providing AI/ML-based solutions (such as Copilots) with the necessary context to answer detailed queries about an agreement.
* - **Involved Parties and Related Agreements**: Lists all parties involved and related agreements, allowing users to see all associated legal documents and relationships between agreements.
*/
export function navigatorAgreementsGetAgreement(client, request, options) {
return new APIPromise($do(client, request, options));
}
async function $do(client, request, options) {
const parsed = safeParse(request, (value) => operations.GetAgreementRequest$outboundSchema.parse(value), "Input validation failed");
if (!parsed.ok) {
return [parsed, { status: "invalid" }];
}
const payload = parsed.value;
const body = null;
const pathParams = {
accountId: encodeSimple("accountId", payload.accountId, {
explode: false,
charEncoding: "percent",
}),
agreementId: encodeSimple("agreementId", payload.agreementId, {
explode: false,
charEncoding: "percent",
}),
};
const path = pathToFunc("/v1/accounts/{accountId}/agreements/{agreementId}")(pathParams);
const headers = new Headers(compactMap({
Accept: "application/json",
}));
const secConfig = await extractSecurity(client._options.accessToken);
const securityInput = secConfig == null ? {} : { accessToken: secConfig };
const requestSecurity = resolveGlobalSecurity(securityInput);
const context = {
options: client._options,
baseURL: options?.serverURL ?? client._baseURL ?? "",
operationID: "GetAgreement",
oAuth2Scopes: [],
resolvedSecurity: requestSecurity,
securitySource: client._options.accessToken,
retryConfig: options?.retries
|| client._options.retryConfig
|| {
strategy: "backoff",
backoff: {
initialInterval: 500,
maxInterval: 5000,
exponent: 1.5,
maxElapsedTime: 30000,
},
retryConnectionErrors: true,
}
|| { strategy: "none" },
retryCodes: options?.retryCodes || ["5XX", "429"],
};
const requestRes = client._createRequest(context, {
security: requestSecurity,
method: "GET",
baseURL: options?.serverURL,
path: path,
headers: headers,
body: body,
userAgent: client._options.userAgent,
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
}, options);
if (!requestRes.ok) {
return [requestRes, { status: "invalid" }];
}
const req = requestRes.value;
const doResult = await client._do(req, {
context,
errorCodes: ["400", "401", "403", "404", "4XX", "500", "5XX"],
retryConfig: context.retryConfig,
retryCodes: context.retryCodes,
});
if (!doResult.ok) {
return [doResult, { status: "request-error", request: req }];
}
const response = doResult.value;
const responseFields = {
HttpMeta: { Response: response, Request: req },
};
const [result] = await M.match(M.json(200, components.Agreement$inboundSchema), M.jsonErr([400, 403, 404], errors.ErrorT$inboundSchema), M.jsonErr(500, errors.ErrorT$inboundSchema), M.fail([401, "4XX"]), M.fail("5XX"))(response, req, { extraFields: responseFields });
if (!result.ok) {
return [result, { status: "complete", request: req, response }];
}
return [result, { status: "complete", request: req, response }];
}
//# sourceMappingURL=navigatorAgreementsGetAgreement.js.map