Skip to content

Commit

Permalink
refactor: Copied Provider ts files and base structure [No Changes made]
Browse files Browse the repository at this point in the history
  • Loading branch information
Gal Tidhar committed Apr 25, 2024
1 parent f266c5d commit fa2ae74
Show file tree
Hide file tree
Showing 144 changed files with 69 additions and 13 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// eslint-disable-next-line import/first
import { NetCoreProvider } from './netcore.provider';
import axios from 'axios';
import { IEmailBody } from 'netcore';
import { IEmailOptions } from '@novu/stateless';
import { IEmailBody } from '../types/netcore/netcore-types';

jest.mock('axios');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
IEmailEventBody,
EmailEventStatusEnum,
} from '@novu/stateless';
import { IEmailBody, IEmailResponse } from 'netcore';
import axios, { AxiosInstance } from 'axios';
import { IEmailBody, IEmailResponse } from '../types/netcore/netcore-types';

export enum NetCoreStatusEnum {
OPENED = 'open',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ import {
SmsEventStatusEnum,
ISMSEventBody,
} from '@novu/stateless';
import {
SmsParams,
MessageChannel,
SmsJsonResponse,
AnyObject,
} from '../types/sms';
import { SmsParams, MessageChannel, SmsJsonResponse } from '../types/sms';

if (!globalThis.fetch) {
// eslint-disable-next-line global-require
globalThis.fetch = require('node-fetch');
}

Expand Down Expand Up @@ -44,11 +38,19 @@ export class TermiiSmsProvider implements ISmsProvider {
api_key: this.config.apiKey,
};

const opts: AnyObject = {
const headers: HeadersInit = {
'Content-Type': 'application/json',
};
const opts: RequestInit = {
agent: undefined,
cache: undefined,
credentials: undefined,
mode: undefined,
redirect: undefined,
referrerPolicy: undefined,
signal: undefined,
method: 'POST',
headers: {
'Content-Type': ['application/json'],
},
headers: headers,
body: JSON.stringify(params),
};

Expand Down
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions packages/providers/src/types/netcore/netcore-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
export interface IRecipient {
name?: string;
email: string;
}

export interface IContent {
type: 'html' | 'amp';
value: string;
}

export interface IAttachment {
name: string;
content: string;
}

export interface IPersonalizations {
attributes?: Record<string, string>;
to?: IRecipient[];
cc?: Pick<IRecipient, 'email'>[];
bcc?: Pick<IRecipient, 'email'>[];
token_to?: string;
token_cc?: string;
attachments?: IAttachment[];
headers?: Record<string, unknown>;
}

export interface ISettings {
open_track?: boolean;
click_track?: boolean;
unsubscribe_track?: boolean;
ip_pool?: string;
}

export interface IEmailBody {
from: IRecipient;
reply_to?: string;
subject: string;
template_id?: number;
tags?: string[];
content: IContent[];
attachments?: IAttachment[];
personalizations?: IPersonalizations[];
settings?: ISettings;
bcc?: Pick<IRecipient, 'email'>[];
schedule?: number;
}

export interface IEmailResponse {
data: {
message_id: string;
};
message: string;
status: string;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit fa2ae74

Please sign in to comment.