Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .env.example

This file was deleted.

5 changes: 1 addition & 4 deletions .env.test.dist
Original file line number Diff line number Diff line change
@@ -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
68 changes: 35 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -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<Document>(documentGet);
const documentGet = new DocumentGetRequest('1b23ed1a6aaf4d3392ed0e88bc2bfafb2a3cf414');
const responseDocumentGet = await client.send<DocumentGetResponse>(documentGet);
console.log('response document get', responseDocumentGet);
```

### Examples
You can find more examples of API usage in the [`examples`](./examples) directory.
**Examples**

Find more API usage examples in the [`examples`](https://github.com/signnow/SignNowNodeSDK/tree/master/examples) directory.
2 changes: 1 addition & 1 deletion examples/document/documentDownloadGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DocumentDownloadGetRequest, DocumentDownloadGetResponse } from '@signno
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function documentDownloadGet(documentId: string): Promise<DocumentDownloadGetResponse> {
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);
Expand Down
2 changes: 1 addition & 1 deletion examples/document/documentFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FieldsGetResponse> {
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);
Expand Down
2 changes: 1 addition & 1 deletion examples/document/documentGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<DocumentGetResponse> {
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);
Expand Down
2 changes: 1 addition & 1 deletion examples/document/documentPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<DocumentPostResponse> {
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');
Expand Down
2 changes: 1 addition & 1 deletion examples/documentGroup/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DocumentGroupDeleteRequest, DocumentGroupDeleteResponse } from '@signno
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function deleteDocumentGroup(documentGroupId: string): Promise<DocumentGroupDeleteResponse> {
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);
Expand Down
2 changes: 1 addition & 1 deletion examples/documentGroup/downloadPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Buffer> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

const downloadDocumentGroup = new DownloadDocumentGroupPostRequest(
Expand Down
2 changes: 1 addition & 1 deletion examples/documentGroupInvite/documentGroupInvitePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GroupInvitePostRequest, GroupInvitePostResponse, InviteStepInviteAction
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function sendDocumentGroupInvite(): Promise<GroupInvitePostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DocumentGroupTemplatePost as DocumentGroupTemplatePostResponse } from '
import { Sdk } from '../../src/core/sdk';

export async function postDocumentGroupTemplate(): Promise<DocumentGroupTemplatePostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/documentInvite/cancelFreeFormPut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CancelFreeFormInvitePutRequest, CancelFreeFormInvitePutResponse } from
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function cancelFreeFormInvite(): Promise<CancelFreeFormInvitePutResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data:
Expand Down
4 changes: 2 additions & 2 deletions examples/documentInvite/fieldInvitePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { SendInvitePostRequest, SendInvitePostResponse, ToRequestAttribute } fro
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function sendFieldInvite(): Promise<SendInvitePostResponse> {
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
Expand Down
2 changes: 1 addition & 1 deletion examples/documentInvite/freeFormPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FreeFormInvitePostRequest, FreeFormInvitePostResponse } from '@signnow/
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function sendFreeFormInvite(): Promise<FreeFormInvitePostResponse> {
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';
Expand Down
2 changes: 1 addition & 1 deletion examples/documentInvite/signingLinkPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SigningLinkPostRequest, SigningLinkPostResponse } from '@signnow/api-cl
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function createSigningLink(): Promise<SigningLinkPostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddedEditor/documentEditorPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DocumentEmbeddedEditorLinkPostRequest, DocumentEmbeddedEditorLinkPostRe
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function createEmbeddedEditorLink(): Promise<DocumentEmbeddedEditorLinkPostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddedEditor/documentGroupEditorPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DocumentGroupEmbeddedEditorLinkPostRequest, DocumentGroupEmbeddedEditor
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function createDocumentGroupEmbeddedEditorLink(): Promise<DocumentGroupEmbeddedEditorLinkPostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddedInvite/embeddedDocumentGroupInvite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GroupInvitePostRequest, GroupInvitePostResponse, InviteRequestAttribute
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function createEmbeddedDocumentGroupInvite(): Promise<GroupInvitePostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddedInvite/embeddedDocumentInvite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DocumentInvitePostRequest, DocumentInvitePostResponse, InviteRequestAtt
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function createEmbeddedInvite(): Promise<DocumentInvitePostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddedSending/documentGroupSending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DocumentGroupEmbeddedSendingLinkPostRequest, DocumentGroupEmbeddedSendi
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function createEmbeddedDocumentGroupSending(): Promise<DocumentGroupEmbeddedSendingLinkPostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddedSending/documentSending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DocumentEmbeddedSendingLinkPostRequest, DocumentEmbeddedSendingLinkPost
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function createEmbeddedDocumentSending(): Promise<DocumentEmbeddedSendingLinkPostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data
Expand Down
2 changes: 1 addition & 1 deletion examples/template/bulkInvitePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BulkInvitePostRequest, TemplatePostRequest, BulkInvitePostResponse, Tem
import { Sdk } from '@signnow/api-client/core';

export async function postBulkInvite(): Promise<BulkInvitePostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/template/cloneTemplatePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CloneTemplatePostRequest, TemplatePostRequest, CloneTemplatePostRespons
import { Sdk } from '@signnow/api-client/core';

export async function postTemplateCopy(): Promise<CloneTemplatePostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/template/routingDetailsGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RoutingDetailsGetRequest, RoutingDetailsPostRequest, RoutingDetailsGetR
import { Sdk } from '@signnow/api-client/core';

export async function getRoutingDetails(): Promise<RoutingDetailsGetResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/template/routingDetailsPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RoutingDetailsPostRequest, RoutingDetailsPostResponse } from '@signnow/
import { Sdk } from '@signnow/api-client/core';

export async function postRoutingDetails(): Promise<RoutingDetailsPostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/template/routingDetailsPut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RoutingDetailsPutRequest, RoutingDetailsPutResponse } from '@signnow/ap
import { Sdk } from '@signnow/api-client/core';

export async function putRoutingDetails(): Promise<RoutingDetailsPutResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/template/templatePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TemplatePostRequest, TemplatePostResponse } from '@signnow/api-client/a
import { Sdk } from '@signnow/api-client/core';

export async function postTemplate(): Promise<TemplatePostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/user/userGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserGetResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

const userGetRequest = new UserGetRequest();
Expand Down
2 changes: 1 addition & 1 deletion examples/webhook/subscriptionGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SubscriptionGetRequest, SubscriptionGetResponse } from '@signnow/api-cl
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function getWebhookSubscriptions(): Promise<SubscriptionGetResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

const subscriptionRequest = new SubscriptionGetRequest();
Expand Down
2 changes: 1 addition & 1 deletion examples/webhook/subscriptionPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SubscriptionPostRequest, SubscriptionPostResponse } from '@signnow/api-
import { displayResultError, Sdk } from '@signnow/api-client/core';

export async function createWebhookSubscription(): Promise<SubscriptionPostResponse> {
const sdk = await new Sdk().authenticate();
const sdk = new Sdk({ apiKey: '{{API_KEY}}', basicToken: '{{BASIC_TOKEN}}' });
const client = sdk.getClient();

// Source data
Expand Down
Loading