2.0.8 • Published 11 months ago

@kbabichau/uns-rest-integration-client v2.0.8

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

UnsRESTClient

The UnsRESTClient module is a Node.js package that provides an API for interacting with the Unified Notifications Service (UNS) REST API.

Installation

npm install @kbabichau/uns-rest-integration-client

Usage

To use UnsRESTClient, first import it at the top of your script:

import UnsRESTClient, { UnsEnvironment } from '@kbabichau/uns-rest-integration-client';

Then, create an instance of the UnsRESTClient class by passing a configuration object to its constructor:

const client = new UnsRESTClient({
  environment: UnsEnvironment.QA, // Specify the environment as `UnsEnvironment.QA` or `UnsEnvironment.Production`
  application: 'your-app-name',
  tenant: 'your-tenant-name',
  host: 'https://qa.endpoint.com',
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  unsClientId: 'uns-client-id'
});

Once you have an instance of the UnsRESTClient, you can use its sendEmail method to send email notifications:

const response = await client.sendEmail({
  template: 'your-email-template', // The name of your email template
  to: 'test123@gmail.com', // The email address of the recipient(s)
  cc: 'test456@gmail.com', // Optional: The email address of the person(s) to cc on the email
  data: { // The payload data for your email template
    firstName: 'John',
    lastName: 'Doe'
  }
});

This will send an email notification using the specified email template to the specified email address.

API

new UnsRESTClient(options)

Returns a new instance of the UnsRESTClient class. Takes an object with the following properties:

  • environment (UnsEnvironment) - The environment in which you're using UNS.
  • application (string) - The name of the application for whom the notification is being sent.
  • tenant (string) - The name of the tenant for whom the notification is being sent.
  • host (string) - The host URL for the UNS REST API.
  • unsClientId (string) - The client ID for your UNS application.
  • clientId (string) - The client ID for your application.
  • clientSecret (string) - The client secret for your application.

UnsRESTClient.sendEmail(payload)

Sends an email notification using the specified email template and recipient email address.

Takes an object with the following properties:

  • template (string) - The name of the email template being used.
  • to (string | string[]) - The email address of the recipient(s) of the email.
  • cc (string | string[] | undefined) - (optional) Additional email addresses to cc on the email.
  • data (object) - The data payload for the email.

Returns a Promise that resolves with the response object from UNS.

UnsEnvironment

An enum containing the possible environment types for the UnsRESTClient constructor. Possible values are QA and Production.

License

MIT

2.0.7

11 months ago

2.0.6

11 months ago

2.0.8

11 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago