-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
689 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { AbstractChannel } from './abstract-channel'; | ||
import { ContentType, IContent, ILoggerInstance, IClientOptions } from '../../types'; | ||
|
||
/** | ||
* Implementation of Email channel. | ||
*/ | ||
export class EmailChannel extends AbstractChannel { | ||
|
||
private supportedContents: ContentType[]; | ||
|
||
/** | ||
* Returns a new `EmailChannel` that is used to set the Email channel. | ||
* | ||
* @param token Zenvia platform token. | ||
* @param loggerInstance If you want, you can pass your log instance. | ||
*/ | ||
constructor(token: string, loggerInstance: ILoggerInstance, options: IClientOptions) { | ||
super(token, 'email', loggerInstance, options); | ||
this.supportedContents = ['email']; | ||
} | ||
|
||
protected contentSupportValidation(content: IContent): void | never { | ||
if (!this.supportedContents.includes(content.type)) { | ||
throw new Error(`Content of type ${content.type} is not supported in E-mail channel`); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { AbstractChannel } from './abstract-channel'; | ||
import { ContentType, IContent, ILoggerInstance, IClientOptions } from '../../types'; | ||
|
||
/** | ||
* Implementation of GBM channel. | ||
*/ | ||
export class GbmChannel extends AbstractChannel { | ||
|
||
private supportedContents: ContentType[]; | ||
|
||
/** | ||
* Returns a new `GbmChannel` that is used to set the GBM channel. | ||
* | ||
* @param token Zenvia platform token. | ||
* @param loggerInstance If you want, you can pass your log instance. | ||
*/ | ||
constructor(token: string, loggerInstance: ILoggerInstance, options: IClientOptions) { | ||
super(token, 'gbm', loggerInstance, options); | ||
this.supportedContents = ['text', 'file']; | ||
} | ||
|
||
protected contentSupportValidation(content: IContent): void | never { | ||
if (!this.supportedContents.includes(content.type)) { | ||
throw new Error(`Content of type ${content.type} is not supported in Google Business Messages channel`); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { AbstractChannel } from './abstract-channel'; | ||
import { ContentType, IContent, ILoggerInstance, IClientOptions } from '../../types'; | ||
|
||
/** | ||
* Implementation of Telegram channel. | ||
*/ | ||
export class TelegramChannel extends AbstractChannel { | ||
|
||
private supportedContents: ContentType[]; | ||
|
||
/** | ||
* Returns a new `TelegramChannel` that is used to set the Telegram channel. | ||
* | ||
* @param token Zenvia platform token. | ||
* @param loggerInstance If you want, you can pass your log instance. | ||
*/ | ||
constructor(token: string, loggerInstance: ILoggerInstance, options: IClientOptions) { | ||
super(token, 'telegram', loggerInstance, options); | ||
this.supportedContents = ['text', 'file']; | ||
} | ||
|
||
protected contentSupportValidation(content: IContent): void | never { | ||
if (!this.supportedContents.includes(content.type)) { | ||
throw new Error(`Content of type ${content.type} is not supported in Telegram channel`); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { AbstractContent } from './abstract-content'; | ||
import { IEmailContent, IFile } from '../../types'; | ||
|
||
/** | ||
* Implementation of email content. | ||
*/ | ||
export class EmailContent extends AbstractContent implements IEmailContent { | ||
|
||
subject: string; | ||
html?: string; | ||
text?: string; | ||
attachments?: IFile[]; | ||
cc?: string[]; | ||
bcc?: string[]; | ||
|
||
/** | ||
* Returns a new `EmailContent` that can be used to send audio, image, video, or document media to your customer. | ||
* | ||
* @param subject The subject of the e-mail to be sent. | ||
* @param html The content to be sent in HTML format. | ||
* @param text The content to be sent in plain text format. | ||
* @param attachments Files to be attached in the e-mail. | ||
*/ | ||
constructor(subject: string, attachments?: IFile[], html?: string, text?: string) { | ||
super('email'); | ||
this.subject = subject; | ||
this.html = html; | ||
this.text = text; | ||
this.attachments = attachments; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.