@@ -5,7 +5,7 @@ import type {
55 MessageType ,
66} from './resources/message' ;
77import type { APIOTPMessage } from './resources/otp' ;
8- import type { WebhookEventType } from './resources/webhooks' ;
8+ import { WebhookEventType } from './resources/webhooks' ;
99
1010export interface WebhookBase <
1111 Type extends WebhookEventType ,
@@ -156,3 +156,67 @@ export type WebhookEvent =
156156 | WebhookMessageScheduledEvent
157157 | WebhookMessageFailedEvent
158158 | WebhookMessageCanceledEvent ;
159+
160+ /**
161+ * Checks whether the event is a {@link WebhookEventType.SMSOTP} or not
162+ * @param event The event data received from Rewrite
163+ */
164+ export function isWebhookSMSOTPEvent ( event : WebhookEvent ) {
165+ return event . type === WebhookEventType . SMSOTP ;
166+ }
167+
168+ /**
169+ * Checks whether the event is a {@link WebhookEventType.MessageSent} or not
170+ * @param event The event data received from Rewrite
171+ */
172+ export function isWebhookMessageSentEvent ( event : WebhookEvent ) {
173+ return event . type === WebhookEventType . MessageSent ;
174+ }
175+
176+ /**
177+ * Checks whether the event is a {@link WebhookEventType.MessageBatch} or not
178+ * @param event The event data received from Rewrite
179+ */
180+ export function isWebhookMessageBatchEvent ( event : WebhookEvent ) {
181+ return event . type === WebhookEventType . MessageBatch ;
182+ }
183+
184+ /**
185+ * Checks whether the event is a {@link WebhookEventType.MessageQueued} or not
186+ * @param event The event data received from Rewrite
187+ */
188+ export function isWebhookMessageQueuedEvent ( event : WebhookEvent ) {
189+ return event . type === WebhookEventType . MessageQueued ;
190+ }
191+
192+ /**
193+ * Checks whether the event is a {@link WebhookEventType.MessageDelivered} or not
194+ * @param event The event data received from Rewrite
195+ */
196+ export function isWebhookMessageDeliveredEvent ( event : WebhookEvent ) {
197+ return event . type === WebhookEventType . MessageDelivered ;
198+ }
199+
200+ /**
201+ * Checks whether the event is a {@link WebhookEventType.MessageScheduled} or not
202+ * @param event The event data received from Rewrite
203+ */
204+ export function isWebhookMessageScheduledEvent ( event : WebhookEvent ) {
205+ return event . type === WebhookEventType . MessageScheduled ;
206+ }
207+
208+ /**
209+ * Checks whether the event is a {@link WebhookEventType.MessageFailed} or not
210+ * @param event The event data received from Rewrite
211+ */
212+ export function isWebhookMessageFailedEvent ( event : WebhookEvent ) {
213+ return event . type === WebhookEventType . MessageFailed ;
214+ }
215+
216+ /**
217+ * Checks whether the event is a {@link WebhookEventType.MessageCanceled} or not
218+ * @param event The event data received from Rewrite
219+ */
220+ export function isWebhookMessageCanceledEvent ( event : WebhookEvent ) {
221+ return event . type === WebhookEventType . MessageCanceled ;
222+ }
0 commit comments