coren-contact-bridge-sdk
v1.0.4
Published
Lib to call contact bridge of coren
Downloads
2
Readme
Welcome to coren-contact-bridge-sdk 👋
This library provides a set of functionalities for handling email parameters, templates, and sending emails
Getting start
Install package. You can use the package manager of your preference. (npm, yarn, pnpm and etc.)
pnpm add coren-contact-bridge-sdk
Import lib
import { ContactBridgeSdk } from 'coren-contact-bridge-sdk';
- Stage =
process.env.STAGE | 'dev
- Tenant =
process.env.TENANT | 'core'
- Region =
process.env.REGION | 'us-east-2'
- Email Params Table =
${Stage}_${Tenant}_email_params
- Email Templates bucket =
${Stage}-${Tenant}-coren-email-templates-${Region}
AWS Interfaces
export interface S3Interface {
download(key: string): Promise<Buffer>;
}
export interface DynamoDbInterface {
get<T>(key: GetCommandInput['Key']): Promise<T>;
}
export interface SESInterface {
sendEmail(input: SendEmailCommandInput): Promise<SendEmailCommandOutput>;
}
Constructor
type ContactBridgeSdkConstructorParams = {
s3: S3Interface;
ses: SESInterface;
dynamo: DynamoDbInterface;
};
GetTemplate
This feature aims to retrieve the template stored in the S3 bucket.
Input:
{ template_path: string; }
Output:
string;
ParseTemplate
This feature aims to parse the template with given properties.
Input:
{ template: string; properties?: Record<string, unknown>; }
Output:
string;
SendEmail
This feature aims to send email with SES.
Input:
{ from?: string; to: Array<string>; subject: string; body: string; }
Output:
void;
GetEmailParams
This feature aims to get email params
Input:
{ name: string; }
Output:
{ name: string; template: string; subject: string; images_url: Record<string, string>; }
GetAndParseEmailParams
This feature aims to get email params and parse the body with the template
Input:
{ name: string; properties?: Record<string,unknown> }
Output:
{ name: string; body: string; subject: string; }