From fbf31016ac45c13ce4902241cd4ac9689807d5a3 Mon Sep 17 00:00:00 2001 From: Serhii Kashuba Date: Tue, 24 Feb 2026 12:18:15 +0100 Subject: [PATCH 1/2] Implemented SDK with direct parameter injection into constructor --- .env.example | 15 ---- .env.test.dist | 5 +- README.md | 68 ++++++++++--------- examples/document/documentDownloadGet.ts | 2 +- examples/document/documentFields.ts | 2 +- examples/document/documentGet.ts | 2 +- examples/document/documentPost.ts | 2 +- examples/documentGroup/delete.ts | 2 +- examples/documentGroup/downloadPost.ts | 2 +- .../documentGroupInvitePost.ts | 2 +- .../documentGroupTemplatePost.ts | 2 +- examples/documentInvite/cancelFreeFormPut.ts | 2 +- examples/documentInvite/fieldInvitePost.ts | 4 +- examples/documentInvite/freeFormPost.ts | 2 +- examples/documentInvite/signingLinkPost.ts | 2 +- examples/embeddedEditor/documentEditorPost.ts | 2 +- .../embeddedEditor/documentGroupEditorPost.ts | 2 +- .../embeddedDocumentGroupInvite.ts | 2 +- .../embeddedInvite/embeddedDocumentInvite.ts | 2 +- .../embeddedSending/documentGroupSending.ts | 2 +- examples/embeddedSending/documentSending.ts | 2 +- examples/template/bulkInvitePost.ts | 2 +- examples/template/cloneTemplatePost.ts | 2 +- examples/template/routingDetailsGet.ts | 2 +- examples/template/routingDetailsPost.ts | 2 +- examples/template/routingDetailsPut.ts | 2 +- examples/template/templatePost.ts | 2 +- examples/user/userGet.ts | 2 +- examples/webhook/subscriptionGet.ts | 2 +- examples/webhook/subscriptionPost.ts | 2 +- npm/README.md | 68 ------------------- package.json | 2 +- src/core/apiClient.ts | 8 +-- src/core/config/config.ts | 67 +++++++++++++----- src/core/sdk.ts | 28 ++++++-- src/types/configParameters.ts | 8 +++ src/types/sdkParameters.ts | 6 ++ tests/api/auth/refreshToken.test.ts | 2 +- tests/api/auth/token.test.ts | 4 +- tests/api/document/document.test.ts | 6 +- tests/api/document/documentDownload.test.ts | 2 +- .../api/document/documentDownloadLink.test.ts | 2 +- tests/api/document/documentMerge.test.ts | 2 +- tests/api/document/documentMove.test.ts | 2 +- tests/api/document/fieldExtract.test.ts | 2 +- tests/api/document/fields.test.ts | 2 +- .../api/documentField/documentPrefill.test.ts | 2 +- tests/api/documentGroup/documentGroup.test.ts | 6 +- .../documentGroupRecipients.test.ts | 2 +- .../downloadDocumentGroup.test.ts | 2 +- .../cancelGroupInvite.test.ts | 2 +- .../documentGroupInvite/groupInvite.test.ts | 4 +- .../documentGroupInvite/pendingInvite.test.ts | 2 +- .../reassignSigner.test.ts | 2 +- .../resendGroupInvite.test.ts | 2 +- .../documentGroupTemplate.test.ts | 2 +- .../cancelFreeFormInvite.test.ts | 2 +- tests/api/documentInvite/cancelInvite.test.ts | 2 +- .../api/documentInvite/freeFormInvite.test.ts | 4 +- tests/api/documentInvite/sendInvite.test.ts | 2 +- tests/api/documentInvite/signingLink.test.ts | 2 +- .../documentEmbeddedEditorLink.test.ts | 2 +- .../documentGroupEmbeddedEditorLink.test.ts | 2 +- .../embeddedGroupInvite/groupInvite.test.ts | 4 +- .../groupInviteLink.test.ts | 2 +- .../api/embeddedInvite/documentInvite.test.ts | 4 +- .../embeddedInvite/documentInviteLink.test.ts | 2 +- .../documentEmbeddedSendingLink.test.ts | 2 +- .../documentGroupEmbeddedSendingLink.test.ts | 2 +- tests/api/folder/folder.test.ts | 2 +- tests/api/folder/folderDocuments.test.ts | 2 +- .../documentPrefillSmartField.test.ts | 2 +- tests/api/template/bulkInvite.test.ts | 2 +- tests/api/template/cloneTemplate.test.ts | 2 +- tests/api/template/groupTemplate.test.ts | 4 +- tests/api/template/routingDetails.test.ts | 6 +- tests/api/template/template.test.ts | 2 +- tests/api/user/emailVerify.test.ts | 2 +- tests/api/user/initial.test.ts | 4 +- tests/api/user/resetPassword.test.ts | 2 +- tests/api/user/user.test.ts | 6 +- tests/api/webhook/subscription.test.ts | 8 +-- tests/api/webhookV2/callback.test.ts | 2 +- tests/api/webhookV2/callbacksAll.test.ts | 2 +- tests/api/webhookV2/eventSubscription.test.ts | 6 +- .../webhookV2/eventSubscriptionAll.test.ts | 2 +- .../eventSubscriptionsCallbacksAll.test.ts | 2 +- 87 files changed, 224 insertions(+), 247 deletions(-) delete mode 100644 .env.example delete mode 100644 npm/README.md create mode 100644 src/types/configParameters.ts create mode 100644 src/types/sdkParameters.ts diff --git a/.env.example b/.env.example deleted file mode 100644 index 6d79497..0000000 --- a/.env.example +++ /dev/null @@ -1,15 +0,0 @@ -## -## signNow API SDK configuration -## - -## Replace these dummy values with your actual credentials except API_HOST -SIGNNOW_API_HOST=https://api.signnow.com -SIGNNOW_API_BASIC_TOKEN=c2lnbk5vdyBBUEkgc2FtcGxlIEFwcCB2MS4wCg== -SIGNNOW_API_USERNAME=user@signnow.com -SIGNNOW_API_PASSWORD=coolest_pazzw0rd - -# Absolute or relative (starts with .) path to the directory -# where the downloaded files will be stored (make sure you have write permissions to this directory) -# -# Default: ./storage/downloads -SIGNNOW_DOWNLOADS_DIR=./storage/downloads diff --git a/.env.test.dist b/.env.test.dist index b15ed96..4261a22 100644 --- a/.env.test.dist +++ b/.env.test.dist @@ -1,9 +1,6 @@ ## -## signNow API SDK configuration for tests running +## SignNow API SDK configuration for tests running ## SIGNNOW_API_HOST=http://0.0.0.0:8086 -SIGNNOW_API_BASIC_TOKEN=c2lnbk5vdyBBUEkgc2FtcGxlIEFwcCB2MS4wCg== -SIGNNOW_API_USERNAME=user@signnow.com -SIGNNOW_API_PASSWORD=coolest_pazzw0rd SIGNNOW_DOWNLOADS_DIR=./storage/downloads diff --git a/README.md b/README.md index 563324b..ffbbec0 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,52 @@ -# signNow API NODE.JS SDK -## v3.0.0 +# SignNow API Node.js SDK -[![Node.js Version](https://img.shields.io/badge/supported->=20-blue?logo=node.js)](https://nodejs.org/) +## v3.2.0 + +[![Node.js Version](https://img.shields.io/badge/supported->=17-blue?logo=node.js)](https://nodejs.org/) + +**Requirements** -### Requirements - Node.js 17 or higher -### Installation -Get SDK code -```bash -git clone git@github.com:signnow/SignNowNodeSDK.git -``` -Install dependencies -```bash -npm install -``` +**Installation** -### Configuration -Copy `.env.example` to `.env` and fill your credentials in the required values -```bash -cp .env.example .env -``` +Install the SDK from [`npm`](https://www.npmjs.com/package/@signnow/api-client): -### Run tests -To run tests you need to have a valid `.env.test` file with credentials for testing. -If you don't have it, you can create it by copying the `.env.test.dist` file and renaming it to `.env.test`. -However, the file will be created automatically if you just run test execution with the following commands: ```bash -npm run test +npm install @signnow/api-client ``` -### Usage -To start using the SDK, you need to create a new instance of the SDK API client and authenticate it using the credentials from the `.env` file. -Example of sending a request to get a document by id: +**Usage** + +To start using the SDK, initialize the client with your credentials. +You can authenticate using either an API key: +```typescript +const sdk = new Sdk({ apiKey: '{{API_KEY}}' }); +``` +or by exchanging your Basic authorization token, username, and password for an access token: ```typescript +const sdk = await new Sdk({ basicToken: '{{BASIC_TOKEN}}' }).authenticate(username, password); +``` +**Note:** While the Basic authorization token is optional for requests authenticated via API key, it is required for: +* Generating OAuth 2.0 access tokens. +* Accessing specific endpoints, such as [/api/v2/events](https://docs.signnow.com/docs/signnow/basic-auth). -import { Sdk, DocumentGet } from '@signnow/api-sdk'; -import type { Document } from '@signnow/api-sdk'; +For details on generating tokens and endpoint requirements, refer to the [SignNow Authentication Guide](https://docs.signnow.com/docs/signnow/authentication). -const sdk = await new Sdk().authenticate(); +Example of retrieving the document information by ID: + +```typescript +import { Sdk } from '@signnow/api-client/core/sdk'; +import { DocumentGetRequest, DocumentGetResponse } from '@signnow/api-client/api/document'; + +const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); -const documentGet = new DocumentGet('29db9956636d481f9c532ef64951ae78209f7483'); -const responseDocumentGet = await client.send(documentGet); +const documentGet = new DocumentGetRequest('1b23ed1a6aaf4d3392ed0e88bc2bfafb2a3cf414'); +const responseDocumentGet = await client.send(documentGet); console.log('response document get', responseDocumentGet); ``` -### Examples -You can find more examples of API usage in the [`examples`](./examples) directory. \ No newline at end of file +**Examples** + +Find more API usage examples in the [`examples`](https://github.com/signnow/SignNowNodeSDK/tree/master/examples) directory. \ No newline at end of file diff --git a/examples/document/documentDownloadGet.ts b/examples/document/documentDownloadGet.ts index 844c2b2..1b6b72a 100644 --- a/examples/document/documentDownloadGet.ts +++ b/examples/document/documentDownloadGet.ts @@ -2,7 +2,7 @@ import { DocumentDownloadGetRequest, DocumentDownloadGetResponse } from '@signno import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function documentDownloadGet(documentId: string): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const documentDownloadGet = new DocumentDownloadGetRequest(documentId); diff --git a/examples/document/documentFields.ts b/examples/document/documentFields.ts index 58cb3f9..deebdd1 100644 --- a/examples/document/documentFields.ts +++ b/examples/document/documentFields.ts @@ -2,7 +2,7 @@ import { FieldsGetRequest, FieldsGetResponse } from '@signnow/api-client/api/doc import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function getDocumentFields(documentId: string): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const fieldsGetRequest = new FieldsGetRequest(documentId); diff --git a/examples/document/documentGet.ts b/examples/document/documentGet.ts index d9653d3..d68ea68 100644 --- a/examples/document/documentGet.ts +++ b/examples/document/documentGet.ts @@ -2,7 +2,7 @@ import { DocumentGetRequest, DocumentGetResponse } from '@signnow/api-client/api import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function getDocument(documentId: string): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const documentGet = new DocumentGetRequest(documentId); diff --git a/examples/document/documentPost.ts b/examples/document/documentPost.ts index 3e12cbc..47b2179 100644 --- a/examples/document/documentPost.ts +++ b/examples/document/documentPost.ts @@ -2,7 +2,7 @@ import { DocumentPostRequest, DocumentPostResponse } from '@signnow/api-client/a import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function postDocument(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const documentPost = new DocumentPostRequest('./examples/_data/demo.pdf', 'test.pdf'); diff --git a/examples/documentGroup/delete.ts b/examples/documentGroup/delete.ts index 4d9486a..7a67195 100644 --- a/examples/documentGroup/delete.ts +++ b/examples/documentGroup/delete.ts @@ -2,7 +2,7 @@ import { DocumentGroupDeleteRequest, DocumentGroupDeleteResponse } from '@signno import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function deleteDocumentGroup(documentGroupId: string): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const documentGroupDelete = new DocumentGroupDeleteRequest(documentGroupId); diff --git a/examples/documentGroup/downloadPost.ts b/examples/documentGroup/downloadPost.ts index c765fa8..e36cdc8 100644 --- a/examples/documentGroup/downloadPost.ts +++ b/examples/documentGroup/downloadPost.ts @@ -2,7 +2,7 @@ import { DownloadDocumentGroupPostRequest } from '@signnow/api-client/api/docume import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function downloadDocumentGroup(documentGroupId: string): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const downloadDocumentGroup = new DownloadDocumentGroupPostRequest( diff --git a/examples/documentGroupInvite/documentGroupInvitePost.ts b/examples/documentGroupInvite/documentGroupInvitePost.ts index fd07c99..f70f938 100644 --- a/examples/documentGroupInvite/documentGroupInvitePost.ts +++ b/examples/documentGroupInvite/documentGroupInvitePost.ts @@ -4,7 +4,7 @@ import { GroupInvitePostRequest, GroupInvitePostResponse, InviteStepInviteAction import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function sendDocumentGroupInvite(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data diff --git a/examples/documentGroupTemplate/documentGroupTemplatePost.ts b/examples/documentGroupTemplate/documentGroupTemplatePost.ts index ce00ad3..504ebf5 100644 --- a/examples/documentGroupTemplate/documentGroupTemplatePost.ts +++ b/examples/documentGroupTemplate/documentGroupTemplatePost.ts @@ -9,7 +9,7 @@ import { DocumentGroupTemplatePost as DocumentGroupTemplatePostResponse } from ' import { Sdk } from '../../src/core/sdk'; export async function postDocumentGroupTemplate(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); /** diff --git a/examples/documentInvite/cancelFreeFormPut.ts b/examples/documentInvite/cancelFreeFormPut.ts index 597a4ad..5861591 100644 --- a/examples/documentInvite/cancelFreeFormPut.ts +++ b/examples/documentInvite/cancelFreeFormPut.ts @@ -2,7 +2,7 @@ import { CancelFreeFormInvitePutRequest, CancelFreeFormInvitePutResponse } from import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function cancelFreeFormInvite(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data: diff --git a/examples/documentInvite/fieldInvitePost.ts b/examples/documentInvite/fieldInvitePost.ts index c4956e9..08e3f50 100644 --- a/examples/documentInvite/fieldInvitePost.ts +++ b/examples/documentInvite/fieldInvitePost.ts @@ -3,14 +3,14 @@ import { SendInvitePostRequest, SendInvitePostResponse, ToRequestAttribute } fro import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function sendFieldInvite(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data const senderEmail = 'sender@example.com'; const signerEmail = 'signer@signnow.com'; const signerRole = 'HR Manager'; - const emailSubject = 'You have got an invitation to sign the contact'; + const emailSubject = 'You have got an invitation to sign the contract'; const emailMessage = 'Please review and sign the attached document'; // 1. Upload the document diff --git a/examples/documentInvite/freeFormPost.ts b/examples/documentInvite/freeFormPost.ts index fa3ff0d..d343974 100644 --- a/examples/documentInvite/freeFormPost.ts +++ b/examples/documentInvite/freeFormPost.ts @@ -3,7 +3,7 @@ import { FreeFormInvitePostRequest, FreeFormInvitePostResponse } from '@signnow/ import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function sendFreeFormInvite(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const senderEmail = 'sender@signnow.com'; diff --git a/examples/documentInvite/signingLinkPost.ts b/examples/documentInvite/signingLinkPost.ts index 8abcab6..2e2ef98 100644 --- a/examples/documentInvite/signingLinkPost.ts +++ b/examples/documentInvite/signingLinkPost.ts @@ -3,7 +3,7 @@ import { SigningLinkPostRequest, SigningLinkPostResponse } from '@signnow/api-cl import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function createSigningLink(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data diff --git a/examples/embeddedEditor/documentEditorPost.ts b/examples/embeddedEditor/documentEditorPost.ts index e5f5204..aeff396 100644 --- a/examples/embeddedEditor/documentEditorPost.ts +++ b/examples/embeddedEditor/documentEditorPost.ts @@ -3,7 +3,7 @@ import { DocumentEmbeddedEditorLinkPostRequest, DocumentEmbeddedEditorLinkPostRe import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function createEmbeddedEditorLink(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data diff --git a/examples/embeddedEditor/documentGroupEditorPost.ts b/examples/embeddedEditor/documentGroupEditorPost.ts index 6d88e3a..0e5a24e 100644 --- a/examples/embeddedEditor/documentGroupEditorPost.ts +++ b/examples/embeddedEditor/documentGroupEditorPost.ts @@ -4,7 +4,7 @@ import { DocumentGroupEmbeddedEditorLinkPostRequest, DocumentGroupEmbeddedEditor import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function createDocumentGroupEmbeddedEditorLink(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data diff --git a/examples/embeddedInvite/embeddedDocumentGroupInvite.ts b/examples/embeddedInvite/embeddedDocumentGroupInvite.ts index a8c70f9..a3d9e58 100644 --- a/examples/embeddedInvite/embeddedDocumentGroupInvite.ts +++ b/examples/embeddedInvite/embeddedDocumentGroupInvite.ts @@ -4,7 +4,7 @@ import { GroupInvitePostRequest, GroupInvitePostResponse, InviteRequestAttribute import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function createEmbeddedDocumentGroupInvite(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data diff --git a/examples/embeddedInvite/embeddedDocumentInvite.ts b/examples/embeddedInvite/embeddedDocumentInvite.ts index c18ec39..609d687 100644 --- a/examples/embeddedInvite/embeddedDocumentInvite.ts +++ b/examples/embeddedInvite/embeddedDocumentInvite.ts @@ -3,7 +3,7 @@ import { DocumentInvitePostRequest, DocumentInvitePostResponse, InviteRequestAtt import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function createEmbeddedInvite(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data diff --git a/examples/embeddedSending/documentGroupSending.ts b/examples/embeddedSending/documentGroupSending.ts index 3d552ea..b218b51 100644 --- a/examples/embeddedSending/documentGroupSending.ts +++ b/examples/embeddedSending/documentGroupSending.ts @@ -4,7 +4,7 @@ import { DocumentGroupEmbeddedSendingLinkPostRequest, DocumentGroupEmbeddedSendi import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function createEmbeddedDocumentGroupSending(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data diff --git a/examples/embeddedSending/documentSending.ts b/examples/embeddedSending/documentSending.ts index c32de0e..da8b305 100644 --- a/examples/embeddedSending/documentSending.ts +++ b/examples/embeddedSending/documentSending.ts @@ -3,7 +3,7 @@ import { DocumentEmbeddedSendingLinkPostRequest, DocumentEmbeddedSendingLinkPost import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function createEmbeddedDocumentSending(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data diff --git a/examples/template/bulkInvitePost.ts b/examples/template/bulkInvitePost.ts index 55a6cde..a55c71b 100644 --- a/examples/template/bulkInvitePost.ts +++ b/examples/template/bulkInvitePost.ts @@ -3,7 +3,7 @@ import { BulkInvitePostRequest, TemplatePostRequest, BulkInvitePostResponse, Tem import { Sdk } from '@signnow/api-client/core'; export async function postBulkInvite(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); /** diff --git a/examples/template/cloneTemplatePost.ts b/examples/template/cloneTemplatePost.ts index d02a9f1..03bb8db 100644 --- a/examples/template/cloneTemplatePost.ts +++ b/examples/template/cloneTemplatePost.ts @@ -3,7 +3,7 @@ import { CloneTemplatePostRequest, TemplatePostRequest, CloneTemplatePostRespons import { Sdk } from '@signnow/api-client/core'; export async function postTemplateCopy(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); /** diff --git a/examples/template/routingDetailsGet.ts b/examples/template/routingDetailsGet.ts index 28806f4..60269cf 100644 --- a/examples/template/routingDetailsGet.ts +++ b/examples/template/routingDetailsGet.ts @@ -3,7 +3,7 @@ import { RoutingDetailsGetRequest, RoutingDetailsPostRequest, RoutingDetailsGetR import { Sdk } from '@signnow/api-client/core'; export async function getRoutingDetails(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); /** diff --git a/examples/template/routingDetailsPost.ts b/examples/template/routingDetailsPost.ts index 7d5073d..3817d11 100644 --- a/examples/template/routingDetailsPost.ts +++ b/examples/template/routingDetailsPost.ts @@ -3,7 +3,7 @@ import { RoutingDetailsPostRequest, RoutingDetailsPostResponse } from '@signnow/ import { Sdk } from '@signnow/api-client/core'; export async function postRoutingDetails(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); /** diff --git a/examples/template/routingDetailsPut.ts b/examples/template/routingDetailsPut.ts index f2768f3..31bd948 100644 --- a/examples/template/routingDetailsPut.ts +++ b/examples/template/routingDetailsPut.ts @@ -3,7 +3,7 @@ import { RoutingDetailsPutRequest, RoutingDetailsPutResponse } from '@signnow/ap import { Sdk } from '@signnow/api-client/core'; export async function putRoutingDetails(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); /** diff --git a/examples/template/templatePost.ts b/examples/template/templatePost.ts index 87ffb56..4122cb6 100644 --- a/examples/template/templatePost.ts +++ b/examples/template/templatePost.ts @@ -3,7 +3,7 @@ import { TemplatePostRequest, TemplatePostResponse } from '@signnow/api-client/a import { Sdk } from '@signnow/api-client/core'; export async function postTemplate(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); /** diff --git a/examples/user/userGet.ts b/examples/user/userGet.ts index c74dd80..7b991aa 100644 --- a/examples/user/userGet.ts +++ b/examples/user/userGet.ts @@ -2,7 +2,7 @@ import { UserGetRequest, UserGetResponse } from '@signnow/api-client/api/user'; import { Sdk } from '@signnow/api-client/core'; export async function getUser(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const userGetRequest = new UserGetRequest(); diff --git a/examples/webhook/subscriptionGet.ts b/examples/webhook/subscriptionGet.ts index 2fd41a1..aedea34 100644 --- a/examples/webhook/subscriptionGet.ts +++ b/examples/webhook/subscriptionGet.ts @@ -2,7 +2,7 @@ import { SubscriptionGetRequest, SubscriptionGetResponse } from '@signnow/api-cl import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function getWebhookSubscriptions(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const subscriptionRequest = new SubscriptionGetRequest(); diff --git a/examples/webhook/subscriptionPost.ts b/examples/webhook/subscriptionPost.ts index eea1662..1b89cfa 100644 --- a/examples/webhook/subscriptionPost.ts +++ b/examples/webhook/subscriptionPost.ts @@ -2,7 +2,7 @@ import { SubscriptionPostRequest, SubscriptionPostResponse } from '@signnow/api- import { displayResultError, Sdk } from '@signnow/api-client/core'; export async function createWebhookSubscription(): Promise { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); // Source data diff --git a/npm/README.md b/npm/README.md deleted file mode 100644 index 07a248f..0000000 --- a/npm/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# SignNow API Node.js SDK - -## v3.0.0 - -[![Node.js Version](https://img.shields.io/badge/supported->=17-blue?logo=node.js)](https://nodejs.org/) - -**Requirements** - -- Node.js 17 or higher - -**Installation** - -Install the SDK from [`npm`](https://www.npmjs.com/package/@signnow/api-client): - -```bash -npm install @signnow/api-client -``` - -**Configuration** - -To authenticate and use the SDK, you need to set up environment variables with your API credentials. - -- Create a `.env` file in the root of your project. -- Add the required API credentials to the file. - -Example `.env` file: - -```ini -## -## SignNow API SDK configuration -## - -## Replace these dummy values with your actual credentials (except API_HOST) -SIGNNOW_API_HOST=https://api.signnow.com -SIGNNOW_API_BASIC_TOKEN=c2lnbk5vdyBBUEkgc2FtcGxlIEFwcCB2MS4wCg== -SIGNNOW_API_USERNAME=user@signnow.com -SIGNNOW_API_PASSWORD=coolest_pazzw0rd - -# Absolute or relative (starts with .) path to the directory -# where the downloaded files will be stored (ensure you have write permissions to this directory) -## Default: ./storage/downloads -SIGNNOW_DOWNLOADS_DIR=./storage/downloads -``` - -> ⚠️ Do not commit `.env` files to version control. -> - -**Usage** - -To start using the SDK, create a new instance of the SDK API client and authenticate using the credentials from the `.env` file. - -Example of retrieving the document information by ID: - -```typescript -import { Sdk } from '@signnow/api-client/core/sdk'; -import { DocumentGetRequest, DocumentGetResponse } from '@signnow/api-client/api/document'; - -const sdk = await new Sdk().authenticate(); -const client = sdk.getClient(); - -const documentGet = new DocumentGetRequest('1b23ed1a6aaf4d3392ed0e88bc2bfafb2a3cf414'); -const responseDocumentGet = await client.send(documentGet); -console.log('response document get', responseDocumentGet); -``` - -**Examples** - -Find more API usage examples in the [`examples`](https://github.com/signnow/SignNowNodeSDK/tree/master/examples) directory. \ No newline at end of file diff --git a/package.json b/package.json index e927e48..2a9b820 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@signnow/api-client", "description": "SignNow REST Service Wrapper", - "version": "3.0.0", + "version": "3.2.0", "author": { "name": "SignNow Team", "email": "api@signnow.com" diff --git a/src/core/apiClient.ts b/src/core/apiClient.ts index d3cc0d8..b1da708 100644 --- a/src/core/apiClient.ts +++ b/src/core/apiClient.ts @@ -21,15 +21,13 @@ import { SignNowApiException } from './error/signNowApiException'; * Client for making API requests to SignNow */ export class ApiClient { - private readonly config: Config; - private readonly fileDownloader: FileDownloader; constructor( + private readonly config: Config, private bearerToken?: string, - private headers?: Record, + private readonly headers?: Record, ) { - this.config = new Config(); this.fileDownloader = new FileDownloader(this.config); } @@ -147,7 +145,7 @@ export class ApiClient { const isBasicAuth = request.getAuthMethod() === 'basic'; const contentType = request.getContentType(); const authValue = isBasicAuth - ? `Basic ${this.config.getApiBasicToken()}` + ? `Basic ${this.config.getBasicToken()}` : `Bearer ${this.bearerToken}`; const headers: Record = { diff --git a/src/core/config/config.ts b/src/core/config/config.ts index 859ce1c..13d071c 100644 --- a/src/core/config/config.ts +++ b/src/core/config/config.ts @@ -9,41 +9,76 @@ import * as dotenv from 'dotenv'; +import { ConfigParameters } from '../../types/configParameters'; + const DEFAULT_DOWNLOADS_DIR = './storage/downloads'; -const CLIENT_NAME = 'SignNowApiClient/v3.0.0 (JS)'; +const DEFAULT_API_HOST = 'https://api.signnow.com'; +const CLIENT_NAME = 'SignNowApiClient/v3.2.0 (JS)'; dotenv.config(); export class Config { - constructor( - private SIGNNOW_API_HOST = process.env.SIGNNOW_API_HOST || '', - private SIGNNOW_API_BASIC_TOKEN = process.env.SIGNNOW_API_BASIC_TOKEN || '', - private SIGNNOW_API_USERNAME = process.env.SIGNNOW_API_USERNAME || '', - private SIGNNOW_API_PASSWORD = process.env.SIGNNOW_API_PASSWORD || '', - private SIGNNOW_DOWNLOADS_DIR = process.env.SIGNNOW_DOWNLOADS_DIR || '', - ) {} + private readonly apiHost: string; + + private readonly basicToken: string; + + private username: string; + + private password: string; + + private readonly downloadDirectory: string; + + private readonly apiKey: string; + + constructor({ + apiHost = process.env.SIGNNOW_API_HOST || DEFAULT_API_HOST, + basicToken = process.env.SIGNNOW_API_BASIC_TOKEN || '', + username = process.env.SIGNNOW_API_USERNAME || '', + password = process.env.SIGNNOW_API_PASSWORD || '', + downloadDirectory = process.env.SIGNNOW_DOWNLOADS_DIR || DEFAULT_DOWNLOADS_DIR, + apiKey = process.env.SIGNNOW_API_KEY || '', + }: ConfigParameters = {}) { + this.apiHost = apiHost; + this.basicToken = basicToken; + this.username = username; + this.password = password; + this.downloadDirectory = downloadDirectory; + this.apiKey = apiKey; + } public getApiHost(): string { - return this.SIGNNOW_API_HOST; + return this.apiHost; } - public getApiBasicToken(): string { - return this.SIGNNOW_API_BASIC_TOKEN; + public getBasicToken(): string { + return this.basicToken; } - public getApiUsername(): string { - return this.SIGNNOW_API_USERNAME; + public getUsername(): string { + return this.username; } - public getApiPassword(): string { - return this.SIGNNOW_API_PASSWORD; + public getPassword(): string { + return this.password; } public getDownloadDirectory(): string { - return this.SIGNNOW_DOWNLOADS_DIR || DEFAULT_DOWNLOADS_DIR; + return this.downloadDirectory; } public getClientName(): string { return CLIENT_NAME; } + + public getApiKey(): string { + return this.apiKey; + } + + public setUsername(username: string): void { + this.username = username; + } + + public setPassword(password: string): void { + this.password = password; + } } diff --git a/src/core/sdk.ts b/src/core/sdk.ts index a44f21d..76e5c11 100644 --- a/src/core/sdk.ts +++ b/src/core/sdk.ts @@ -11,23 +11,37 @@ import { ApiClient } from './apiClient'; import { Config } from './config/config'; import { TokenPost } from '../api/auth/request/tokenPost'; import { TokenPost as TokenResponse } from '../api/auth/response/tokenPost'; +import { SdkParameters } from '../types/sdkParameters'; export class Sdk { - private API_VERSION = '2024-11-27'; + private readonly API_VERSION = '2026-01-19'; - private GRANT_TYPE_PASSWORD = 'password'; + private readonly GRANT_TYPE_PASSWORD = 'password'; private apiClient: ApiClient; private config: Config; - constructor() { - this.apiClient = new ApiClient(); - this.config = new Config(); + constructor({ apiHost, basicToken, apiKey, downloadDirectory }: SdkParameters = {}) { + this.config = new Config({ + apiHost, + basicToken, + downloadDirectory, + apiKey, + }); + this.apiClient = new ApiClient(this.config, this.config.getApiKey()); } - public async authenticate(username = this.config.getApiUsername(), password = this.config.getApiPassword()): Promise { - const request = new TokenPost(username, password, this.GRANT_TYPE_PASSWORD); + public async authenticate(username = this.config.getUsername(), password = this.config.getPassword()): Promise { + if (username) { + this.config.setUsername(username); + } + + if (password) { + this.config.setPassword(password); + } + + const request = new TokenPost(this.config.getUsername(), this.config.getPassword(), this.GRANT_TYPE_PASSWORD); const response = await this.apiClient.send(request); this.apiClient.setBearerToken(response.access_token); diff --git a/src/types/configParameters.ts b/src/types/configParameters.ts new file mode 100644 index 0000000..8edb513 --- /dev/null +++ b/src/types/configParameters.ts @@ -0,0 +1,8 @@ +export interface ConfigParameters { + apiHost?: string; + basicToken?: string; + username?: string; + password?: string; + downloadDirectory?: string; + apiKey?: string; +} diff --git a/src/types/sdkParameters.ts b/src/types/sdkParameters.ts new file mode 100644 index 0000000..2838c84 --- /dev/null +++ b/src/types/sdkParameters.ts @@ -0,0 +1,6 @@ +export interface SdkParameters { + apiHost?: string; + basicToken?: string; + apiKey?: string; + downloadDirectory?: string; +} diff --git a/tests/api/auth/refreshToken.test.ts b/tests/api/auth/refreshToken.test.ts index 7fa2c10..d322752 100644 --- a/tests/api/auth/refreshToken.test.ts +++ b/tests/api/auth/refreshToken.test.ts @@ -16,7 +16,7 @@ import { RefreshTokenPost as RefreshTokenPostResponse } from '../../../src/api/a describe('refreshTokenPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/auth/token.test.ts b/tests/api/auth/token.test.ts index 8a503fe..582a41f 100644 --- a/tests/api/auth/token.test.ts +++ b/tests/api/auth/token.test.ts @@ -18,7 +18,7 @@ import { TokenGet as TokenGetResponse } from '../../../src/api/auth/response/tok describe('tokenPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -40,7 +40,7 @@ describe('tokenPost', () => { describe('tokenGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const tokenGet = new TokenGet(); diff --git a/tests/api/document/document.test.ts b/tests/api/document/document.test.ts index 7a9e748..96fce59 100644 --- a/tests/api/document/document.test.ts +++ b/tests/api/document/document.test.ts @@ -20,7 +20,7 @@ import { DocumentPut as DocumentPutResponse } from '../../../src/api/document/re describe('documentPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -46,7 +46,7 @@ describe('documentPost', () => { describe('documentGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -64,7 +64,7 @@ describe('documentGet', () => { describe('documentPut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/document/documentDownload.test.ts b/tests/api/document/documentDownload.test.ts index 762e642..7abad49 100644 --- a/tests/api/document/documentDownload.test.ts +++ b/tests/api/document/documentDownload.test.ts @@ -15,7 +15,7 @@ import { DocumentDownloadGet as DocumentDownloadGetResponse } from '../../../src describe('documentDownloadGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const client = sdk.getClient(); const faker = new Faker(); const documentDownloadGet = new DocumentDownloadGet( diff --git a/tests/api/document/documentDownloadLink.test.ts b/tests/api/document/documentDownloadLink.test.ts index f905f39..c7957c1 100644 --- a/tests/api/document/documentDownloadLink.test.ts +++ b/tests/api/document/documentDownloadLink.test.ts @@ -16,7 +16,7 @@ import { DocumentDownloadLinkPost as DocumentDownloadLinkPostResponse } from '.. describe('documentDownloadLinkPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/document/documentMerge.test.ts b/tests/api/document/documentMerge.test.ts index d30d076..325e7ba 100644 --- a/tests/api/document/documentMerge.test.ts +++ b/tests/api/document/documentMerge.test.ts @@ -16,7 +16,7 @@ import { DocumentMergePost as DocumentMergePostResponse } from '../../../src/api describe('documentMergePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/document/documentMove.test.ts b/tests/api/document/documentMove.test.ts index a2cc975..5e90afe 100644 --- a/tests/api/document/documentMove.test.ts +++ b/tests/api/document/documentMove.test.ts @@ -16,7 +16,7 @@ import { DocumentMovePost as DocumentMovePostResponse } from '../../../src/api/d describe('documentMovePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/document/fieldExtract.test.ts b/tests/api/document/fieldExtract.test.ts index 6118bcf..dd7129e 100644 --- a/tests/api/document/fieldExtract.test.ts +++ b/tests/api/document/fieldExtract.test.ts @@ -16,7 +16,7 @@ import { FieldExtractPost as FieldExtractPostResponse } from '../../../src/api/d describe('fieldExtractPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/document/fields.test.ts b/tests/api/document/fields.test.ts index 3567f13..c931ff9 100644 --- a/tests/api/document/fields.test.ts +++ b/tests/api/document/fields.test.ts @@ -16,7 +16,7 @@ import { FieldsGet as FieldsGetResponse } from '../../../src/api/document/respon describe('fieldsGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentField/documentPrefill.test.ts b/tests/api/documentField/documentPrefill.test.ts index d4342c7..8230a4f 100644 --- a/tests/api/documentField/documentPrefill.test.ts +++ b/tests/api/documentField/documentPrefill.test.ts @@ -16,7 +16,7 @@ import { DocumentPrefillPut as DocumentPrefillPutResponse } from '../../../src/a describe('documentPrefillPut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentGroup/documentGroup.test.ts b/tests/api/documentGroup/documentGroup.test.ts index ad75658..cd71598 100644 --- a/tests/api/documentGroup/documentGroup.test.ts +++ b/tests/api/documentGroup/documentGroup.test.ts @@ -20,7 +20,7 @@ import { DocumentGroupDelete as DocumentGroupDeleteResponse } from '../../../src describe('documentGroupPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -39,7 +39,7 @@ describe('documentGroupPost', () => { describe('documentGroupGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -57,7 +57,7 @@ describe('documentGroupGet', () => { describe('documentGroupDelete', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentGroup/documentGroupRecipients.test.ts b/tests/api/documentGroup/documentGroupRecipients.test.ts index 58ba253..0095309 100644 --- a/tests/api/documentGroup/documentGroupRecipients.test.ts +++ b/tests/api/documentGroup/documentGroupRecipients.test.ts @@ -16,7 +16,7 @@ import { DocumentGroupRecipientsGet as DocumentGroupRecipientsGetResponse } from describe('documentGroupRecipientsGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentGroup/downloadDocumentGroup.test.ts b/tests/api/documentGroup/downloadDocumentGroup.test.ts index 0014877..3b1a778 100644 --- a/tests/api/documentGroup/downloadDocumentGroup.test.ts +++ b/tests/api/documentGroup/downloadDocumentGroup.test.ts @@ -16,7 +16,7 @@ import { DownloadDocumentGroupPost as DownloadDocumentGroupPostResponse } from ' describe('downloadDocumentGroupPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentGroupInvite/cancelGroupInvite.test.ts b/tests/api/documentGroupInvite/cancelGroupInvite.test.ts index cfcee68..fef2b96 100644 --- a/tests/api/documentGroupInvite/cancelGroupInvite.test.ts +++ b/tests/api/documentGroupInvite/cancelGroupInvite.test.ts @@ -16,7 +16,7 @@ import { CancelGroupInvitePost as CancelGroupInvitePostResponse } from '../../.. describe('cancelGroupInvitePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentGroupInvite/groupInvite.test.ts b/tests/api/documentGroupInvite/groupInvite.test.ts index a6a0c8f..9c7ae6e 100644 --- a/tests/api/documentGroupInvite/groupInvite.test.ts +++ b/tests/api/documentGroupInvite/groupInvite.test.ts @@ -18,7 +18,7 @@ import { GroupInviteGet as GroupInviteGetResponse } from '../../../src/api/docum describe('groupInvitePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -44,7 +44,7 @@ describe('groupInvitePost', () => { describe('groupInviteGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentGroupInvite/pendingInvite.test.ts b/tests/api/documentGroupInvite/pendingInvite.test.ts index d08628c..a294d41 100644 --- a/tests/api/documentGroupInvite/pendingInvite.test.ts +++ b/tests/api/documentGroupInvite/pendingInvite.test.ts @@ -16,7 +16,7 @@ import { PendingInviteGet as PendingInviteGetResponse } from '../../../src/api/d describe('pendingInviteGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentGroupInvite/reassignSigner.test.ts b/tests/api/documentGroupInvite/reassignSigner.test.ts index e3d30f8..f5daaf0 100644 --- a/tests/api/documentGroupInvite/reassignSigner.test.ts +++ b/tests/api/documentGroupInvite/reassignSigner.test.ts @@ -16,7 +16,7 @@ import { ReassignSignerPost as ReassignSignerPostResponse } from '../../../src/a describe('reassignSignerPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentGroupInvite/resendGroupInvite.test.ts b/tests/api/documentGroupInvite/resendGroupInvite.test.ts index 6ec8e44..469d2f9 100644 --- a/tests/api/documentGroupInvite/resendGroupInvite.test.ts +++ b/tests/api/documentGroupInvite/resendGroupInvite.test.ts @@ -16,7 +16,7 @@ import { ResendGroupInvitePost as ResendGroupInvitePostResponse } from '../../.. describe('resendGroupInvitePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentGroupTemplate/documentGroupTemplate.test.ts b/tests/api/documentGroupTemplate/documentGroupTemplate.test.ts index f8ecc43..64348c0 100644 --- a/tests/api/documentGroupTemplate/documentGroupTemplate.test.ts +++ b/tests/api/documentGroupTemplate/documentGroupTemplate.test.ts @@ -16,7 +16,7 @@ import { DocumentGroupTemplatePost as DocumentGroupTemplatePostResponse } from ' describe('documentGroupTemplatePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentInvite/cancelFreeFormInvite.test.ts b/tests/api/documentInvite/cancelFreeFormInvite.test.ts index 477b1e0..9863e40 100644 --- a/tests/api/documentInvite/cancelFreeFormInvite.test.ts +++ b/tests/api/documentInvite/cancelFreeFormInvite.test.ts @@ -16,7 +16,7 @@ import { CancelFreeFormInvitePut as CancelFreeFormInvitePutResponse } from '../. describe('cancelFreeFormInvitePut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentInvite/cancelInvite.test.ts b/tests/api/documentInvite/cancelInvite.test.ts index 1b04f00..81a664e 100644 --- a/tests/api/documentInvite/cancelInvite.test.ts +++ b/tests/api/documentInvite/cancelInvite.test.ts @@ -16,7 +16,7 @@ import { CancelInvitePut as CancelInvitePutResponse } from '../../../src/api/doc describe('cancelInvitePut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentInvite/freeFormInvite.test.ts b/tests/api/documentInvite/freeFormInvite.test.ts index f898e64..27c1db4 100644 --- a/tests/api/documentInvite/freeFormInvite.test.ts +++ b/tests/api/documentInvite/freeFormInvite.test.ts @@ -18,7 +18,7 @@ import { FreeFormInviteGet as FreeFormInviteGetResponse } from '../../../src/api describe('freeFormInvitePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -50,7 +50,7 @@ describe('freeFormInvitePost', () => { describe('freeFormInviteGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentInvite/sendInvite.test.ts b/tests/api/documentInvite/sendInvite.test.ts index 6ca9c9d..85f0d0c 100644 --- a/tests/api/documentInvite/sendInvite.test.ts +++ b/tests/api/documentInvite/sendInvite.test.ts @@ -16,7 +16,7 @@ import { SendInvitePost as SendInvitePostResponse } from '../../../src/api/docum describe('sendInvitePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/documentInvite/signingLink.test.ts b/tests/api/documentInvite/signingLink.test.ts index bedc5fb..a14002f 100644 --- a/tests/api/documentInvite/signingLink.test.ts +++ b/tests/api/documentInvite/signingLink.test.ts @@ -16,7 +16,7 @@ import { SigningLinkPost as SigningLinkPostResponse } from '../../../src/api/doc describe('signingLinkPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/embeddedEditor/documentEmbeddedEditorLink.test.ts b/tests/api/embeddedEditor/documentEmbeddedEditorLink.test.ts index eaa8177..c9c6f62 100644 --- a/tests/api/embeddedEditor/documentEmbeddedEditorLink.test.ts +++ b/tests/api/embeddedEditor/documentEmbeddedEditorLink.test.ts @@ -16,7 +16,7 @@ import { DocumentEmbeddedEditorLinkPost as DocumentEmbeddedEditorLinkPostRespons describe('documentEmbeddedEditorLinkPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/embeddedEditor/documentGroupEmbeddedEditorLink.test.ts b/tests/api/embeddedEditor/documentGroupEmbeddedEditorLink.test.ts index 7786628..381f10a 100644 --- a/tests/api/embeddedEditor/documentGroupEmbeddedEditorLink.test.ts +++ b/tests/api/embeddedEditor/documentGroupEmbeddedEditorLink.test.ts @@ -16,7 +16,7 @@ import { DocumentGroupEmbeddedEditorLinkPost as DocumentGroupEmbeddedEditorLinkP describe('documentGroupEmbeddedEditorLinkPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/embeddedGroupInvite/groupInvite.test.ts b/tests/api/embeddedGroupInvite/groupInvite.test.ts index dfbe4c7..b5aaabd 100644 --- a/tests/api/embeddedGroupInvite/groupInvite.test.ts +++ b/tests/api/embeddedGroupInvite/groupInvite.test.ts @@ -18,7 +18,7 @@ import { GroupInviteDelete as GroupInviteDeleteResponse } from '../../../src/api describe('groupInvitePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -38,7 +38,7 @@ describe('groupInvitePost', () => { describe('groupInviteDelete', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/embeddedGroupInvite/groupInviteLink.test.ts b/tests/api/embeddedGroupInvite/groupInviteLink.test.ts index 5e170e7..cfcfa4a 100644 --- a/tests/api/embeddedGroupInvite/groupInviteLink.test.ts +++ b/tests/api/embeddedGroupInvite/groupInviteLink.test.ts @@ -16,7 +16,7 @@ import { GroupInviteLinkPost as GroupInviteLinkPostResponse } from '../../../src describe('groupInviteLinkPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/embeddedInvite/documentInvite.test.ts b/tests/api/embeddedInvite/documentInvite.test.ts index 6efba3b..250d0fd 100644 --- a/tests/api/embeddedInvite/documentInvite.test.ts +++ b/tests/api/embeddedInvite/documentInvite.test.ts @@ -18,7 +18,7 @@ import { DocumentInviteDelete as DocumentInviteDeleteResponse } from '../../../s describe('documentInvitePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -38,7 +38,7 @@ describe('documentInvitePost', () => { describe('documentInviteDelete', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/embeddedInvite/documentInviteLink.test.ts b/tests/api/embeddedInvite/documentInviteLink.test.ts index e49b8b1..d5f8a04 100644 --- a/tests/api/embeddedInvite/documentInviteLink.test.ts +++ b/tests/api/embeddedInvite/documentInviteLink.test.ts @@ -16,7 +16,7 @@ import { DocumentInviteLinkPost as DocumentInviteLinkPostResponse } from '../../ describe('documentInviteLinkPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/embeddedSending/documentEmbeddedSendingLink.test.ts b/tests/api/embeddedSending/documentEmbeddedSendingLink.test.ts index d1d7dd8..4767c8f 100644 --- a/tests/api/embeddedSending/documentEmbeddedSendingLink.test.ts +++ b/tests/api/embeddedSending/documentEmbeddedSendingLink.test.ts @@ -16,7 +16,7 @@ import { DocumentEmbeddedSendingLinkPost as DocumentEmbeddedSendingLinkPostRespo describe('documentEmbeddedSendingLinkPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/embeddedSending/documentGroupEmbeddedSendingLink.test.ts b/tests/api/embeddedSending/documentGroupEmbeddedSendingLink.test.ts index b55c106..971aa20 100644 --- a/tests/api/embeddedSending/documentGroupEmbeddedSendingLink.test.ts +++ b/tests/api/embeddedSending/documentGroupEmbeddedSendingLink.test.ts @@ -16,7 +16,7 @@ import { DocumentGroupEmbeddedSendingLinkPost as DocumentGroupEmbeddedSendingLin describe('documentGroupEmbeddedSendingLinkPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/folder/folder.test.ts b/tests/api/folder/folder.test.ts index 92a5cbf..c49f4e3 100644 --- a/tests/api/folder/folder.test.ts +++ b/tests/api/folder/folder.test.ts @@ -15,7 +15,7 @@ import { FolderGet as FolderGetResponse } from '../../../src/api/folder/response describe('folderGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const folderGet = new FolderGet(); diff --git a/tests/api/folder/folderDocuments.test.ts b/tests/api/folder/folderDocuments.test.ts index e315e64..e8a3ff3 100644 --- a/tests/api/folder/folderDocuments.test.ts +++ b/tests/api/folder/folderDocuments.test.ts @@ -16,7 +16,7 @@ import { FolderDocumentsGet as FolderDocumentsGetResponse } from '../../../src/a describe('folderDocumentsGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/smartFields/documentPrefillSmartField.test.ts b/tests/api/smartFields/documentPrefillSmartField.test.ts index 8be85c8..8a68e0e 100644 --- a/tests/api/smartFields/documentPrefillSmartField.test.ts +++ b/tests/api/smartFields/documentPrefillSmartField.test.ts @@ -16,7 +16,7 @@ import { DocumentPrefillSmartFieldPost as DocumentPrefillSmartFieldPostResponse describe('documentPrefillSmartFieldPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/template/bulkInvite.test.ts b/tests/api/template/bulkInvite.test.ts index 5ecb181..ed2ae9c 100644 --- a/tests/api/template/bulkInvite.test.ts +++ b/tests/api/template/bulkInvite.test.ts @@ -16,7 +16,7 @@ import { BulkInvitePost as BulkInvitePostResponse } from '../../../src/api/templ describe('bulkInvitePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/template/cloneTemplate.test.ts b/tests/api/template/cloneTemplate.test.ts index 3a7e4b1..0c9cc5c 100644 --- a/tests/api/template/cloneTemplate.test.ts +++ b/tests/api/template/cloneTemplate.test.ts @@ -16,7 +16,7 @@ import { CloneTemplatePost as CloneTemplatePostResponse } from '../../../src/api describe('cloneTemplatePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/template/groupTemplate.test.ts b/tests/api/template/groupTemplate.test.ts index 7f10233..f49727f 100644 --- a/tests/api/template/groupTemplate.test.ts +++ b/tests/api/template/groupTemplate.test.ts @@ -18,7 +18,7 @@ import { GroupTemplatePut as GroupTemplatePutResponse } from '../../../src/api/t describe('groupTemplateGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -36,7 +36,7 @@ describe('groupTemplateGet', () => { describe('groupTemplatePut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/template/routingDetails.test.ts b/tests/api/template/routingDetails.test.ts index b20bcfc..448e3b2 100644 --- a/tests/api/template/routingDetails.test.ts +++ b/tests/api/template/routingDetails.test.ts @@ -20,7 +20,7 @@ import { RoutingDetailsGet as RoutingDetailsGetResponse } from '../../../src/api describe('routingDetailsPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -38,7 +38,7 @@ describe('routingDetailsPost', () => { describe('routingDetailsPut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -56,7 +56,7 @@ describe('routingDetailsPut', () => { describe('routingDetailsGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/template/template.test.ts b/tests/api/template/template.test.ts index 007b187..705877f 100644 --- a/tests/api/template/template.test.ts +++ b/tests/api/template/template.test.ts @@ -16,7 +16,7 @@ import { TemplatePost as TemplatePostResponse } from '../../../src/api/template/ describe('templatePost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/user/emailVerify.test.ts b/tests/api/user/emailVerify.test.ts index b8d559d..8a4a5b8 100644 --- a/tests/api/user/emailVerify.test.ts +++ b/tests/api/user/emailVerify.test.ts @@ -16,7 +16,7 @@ import { EmailVerifyPut as EmailVerifyPutResponse } from '../../../src/api/user/ describe('emailVerifyPut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/user/initial.test.ts b/tests/api/user/initial.test.ts index ba7ed0e..8f827a8 100644 --- a/tests/api/user/initial.test.ts +++ b/tests/api/user/initial.test.ts @@ -18,7 +18,7 @@ import { InitialPut as InitialPutResponse } from '../../../src/api/user/response describe('initialGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const initialGet = new InitialGet(); @@ -33,7 +33,7 @@ describe('initialGet', () => { describe('initialPut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/user/resetPassword.test.ts b/tests/api/user/resetPassword.test.ts index e77b805..dbed827 100644 --- a/tests/api/user/resetPassword.test.ts +++ b/tests/api/user/resetPassword.test.ts @@ -16,7 +16,7 @@ import { ResetPasswordPost as ResetPasswordPostResponse } from '../../../src/api describe('resetPasswordPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/user/user.test.ts b/tests/api/user/user.test.ts index e7f50ff..baafec4 100644 --- a/tests/api/user/user.test.ts +++ b/tests/api/user/user.test.ts @@ -20,7 +20,7 @@ import { UserGet as UserGetResponse } from '../../../src/api/user/response/userG describe('userPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -42,7 +42,7 @@ describe('userPost', () => { describe('userPut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -64,7 +64,7 @@ describe('userPut', () => { describe('userGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const userGet = new UserGet(); diff --git a/tests/api/webhook/subscription.test.ts b/tests/api/webhook/subscription.test.ts index c677bb0..3f603af 100644 --- a/tests/api/webhook/subscription.test.ts +++ b/tests/api/webhook/subscription.test.ts @@ -22,7 +22,7 @@ import { SubscriptionDelete as SubscriptionDeleteResponse } from '../../../src/a describe('subscriptionPost', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -44,7 +44,7 @@ describe('subscriptionPost', () => { describe('subscriptionGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const subscriptionGet = new SubscriptionGet(); @@ -59,7 +59,7 @@ describe('subscriptionGet', () => { describe('subscriptionPut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -81,7 +81,7 @@ describe('subscriptionPut', () => { describe('subscriptionDelete', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/webhookV2/callback.test.ts b/tests/api/webhookV2/callback.test.ts index 2efbe21..14edb59 100644 --- a/tests/api/webhookV2/callback.test.ts +++ b/tests/api/webhookV2/callback.test.ts @@ -16,7 +16,7 @@ import { CallbackGet as CallbackGetResponse } from '../../../src/api/webhookV2/r describe('callbackGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/webhookV2/callbacksAll.test.ts b/tests/api/webhookV2/callbacksAll.test.ts index f8e6b38..950290b 100644 --- a/tests/api/webhookV2/callbacksAll.test.ts +++ b/tests/api/webhookV2/callbacksAll.test.ts @@ -16,7 +16,7 @@ import { CallbacksAllGet as CallbacksAllGetResponse } from '../../../src/api/web describe('callbacksAllGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/webhookV2/eventSubscription.test.ts b/tests/api/webhookV2/eventSubscription.test.ts index e016da1..8c08545 100644 --- a/tests/api/webhookV2/eventSubscription.test.ts +++ b/tests/api/webhookV2/eventSubscription.test.ts @@ -20,7 +20,7 @@ import { EventSubscriptionDelete as EventSubscriptionDeleteResponse } from '../. describe('eventSubscriptionGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -38,7 +38,7 @@ describe('eventSubscriptionGet', () => { describe('eventSubscriptionPut', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); @@ -60,7 +60,7 @@ describe('eventSubscriptionPut', () => { describe('eventSubscriptionDelete', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const faker = new Faker(); diff --git a/tests/api/webhookV2/eventSubscriptionAll.test.ts b/tests/api/webhookV2/eventSubscriptionAll.test.ts index 2f4f127..2f86a2f 100644 --- a/tests/api/webhookV2/eventSubscriptionAll.test.ts +++ b/tests/api/webhookV2/eventSubscriptionAll.test.ts @@ -15,7 +15,7 @@ import { EventSubscriptionAllGet as EventSubscriptionAllGetResponse } from '../. describe('eventSubscriptionAllGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const eventSubscriptionAllGet = new EventSubscriptionAllGet(); diff --git a/tests/api/webhookV2/eventSubscriptionsCallbacksAll.test.ts b/tests/api/webhookV2/eventSubscriptionsCallbacksAll.test.ts index b340607..017cabc 100644 --- a/tests/api/webhookV2/eventSubscriptionsCallbacksAll.test.ts +++ b/tests/api/webhookV2/eventSubscriptionsCallbacksAll.test.ts @@ -15,7 +15,7 @@ import { EventSubscriptionsCallbacksAllGet as EventSubscriptionsCallbacksAllGetR describe('eventSubscriptionsCallbacksAllGet', () => { it('Should return correct response', async () => { - const sdk = await new Sdk().authenticate(); + const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' }); const expectationReader = new ExpectationReader(); const client = sdk.getClient(); const eventSubscriptionsCallbacksAllGet = new EventSubscriptionsCallbacksAllGet(); From fe355f45daf650f439a225769c10e699a04ce3bf Mon Sep 17 00:00:00 2001 From: Vasyl Kravets Date: Fri, 6 Mar 2026 16:49:24 +0200 Subject: [PATCH 2/2] Reverted method naming changes --- src/core/apiClient.ts | 2 +- src/core/config/config.ts | 6 +++--- src/core/sdk.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/apiClient.ts b/src/core/apiClient.ts index b1da708..2496da5 100644 --- a/src/core/apiClient.ts +++ b/src/core/apiClient.ts @@ -145,7 +145,7 @@ export class ApiClient { const isBasicAuth = request.getAuthMethod() === 'basic'; const contentType = request.getContentType(); const authValue = isBasicAuth - ? `Basic ${this.config.getBasicToken()}` + ? `Basic ${this.config.getApiBasicToken()}` : `Bearer ${this.bearerToken}`; const headers: Record = { diff --git a/src/core/config/config.ts b/src/core/config/config.ts index 13d071c..13513b4 100644 --- a/src/core/config/config.ts +++ b/src/core/config/config.ts @@ -50,15 +50,15 @@ export class Config { return this.apiHost; } - public getBasicToken(): string { + public getApiBasicToken(): string { return this.basicToken; } - public getUsername(): string { + public getApiUsername(): string { return this.username; } - public getPassword(): string { + public getApiPassword(): string { return this.password; } diff --git a/src/core/sdk.ts b/src/core/sdk.ts index 76e5c11..ea2ea3f 100644 --- a/src/core/sdk.ts +++ b/src/core/sdk.ts @@ -14,7 +14,7 @@ import { TokenPost as TokenResponse } from '../api/auth/response/tokenPost'; import { SdkParameters } from '../types/sdkParameters'; export class Sdk { - private readonly API_VERSION = '2026-01-19'; + private readonly API_VERSION = '2026-01-30'; private readonly GRANT_TYPE_PASSWORD = 'password'; @@ -32,7 +32,7 @@ export class Sdk { this.apiClient = new ApiClient(this.config, this.config.getApiKey()); } - public async authenticate(username = this.config.getUsername(), password = this.config.getPassword()): Promise { + public async authenticate(username = this.config.getApiUsername(), password = this.config.getApiPassword()): Promise { if (username) { this.config.setUsername(username); } @@ -41,7 +41,7 @@ export class Sdk { this.config.setPassword(password); } - const request = new TokenPost(this.config.getUsername(), this.config.getPassword(), this.GRANT_TYPE_PASSWORD); + const request = new TokenPost(this.config.getApiUsername(), this.config.getApiPassword(), this.GRANT_TYPE_PASSWORD); const response = await this.apiClient.send(request); this.apiClient.setBearerToken(response.access_token);