Skip to content

Commit 9648ae9

Browse files
authored
Merge pull request #18 from notificationapi-com/7trSTLbA/3354-slack-frontend-sdk
Add Slack
2 parents 8eea56e + c4b0334 commit 9648ae9

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

lib/interfaces.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export type Channels =
6565
| 'SMS'
6666
| 'CALL'
6767
| 'PUSH'
68-
| 'WEB_PUSH';
68+
| 'WEB_PUSH'
69+
| 'SLACK';
6970

7071
export type BaseDeliveryOptions = 'off' | 'instant';
7172

@@ -126,6 +127,7 @@ export interface NotificationConfig {
126127
PUSH: PUSHDeliveryOptions;
127128
WEB_PUSH: WEB_PUSHDeliveryOptions;
128129
INAPP_WEB: InAppWebDeliveryOptions;
130+
SLACK: SlackDeliveryOptions;
129131
};
130132
}
131133

@@ -154,6 +156,7 @@ type SMSDeliveryOptions = EmailDeliveryOptions;
154156
type CALLDeliveryOptions = EmailDeliveryOptions;
155157
type PUSHDeliveryOptions = EmailDeliveryOptions;
156158
type WEB_PUSHDeliveryOptions = EmailDeliveryOptions;
159+
type SlackDeliveryOptions = EmailDeliveryOptions;
157160

158161
export interface InAppWebDeliveryOptions {
159162
defaultDeliveryOption: DeliveryOptionsForInappWeb;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@notificationapi/core",
3-
"version": "0.0.15",
3+
"version": "0.0.16",
44
"type": "module",
55
"main": "dist/main.js",
66
"types": "dist/main.d.ts",

tests/sdk.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,38 @@ describe('NotificationAPIClientSDK', () => {
273273
);
274274
});
275275

276+
test('updateDeliveryOption should support SLACK channel', async () => {
277+
const mockResponse = {
278+
json: jest.fn().mockResolvedValue({})
279+
};
280+
(global.fetch as jest.Mock).mockResolvedValue(mockResponse);
281+
282+
const sdk = NotificationAPIClientSDK.init({
283+
userId: 'testUser',
284+
clientId: 'testClient'
285+
});
286+
287+
await sdk.updateDeliveryOption({
288+
notificationId: 'testSlackNotification',
289+
channel: 'SLACK',
290+
delivery: 'hourly'
291+
});
292+
293+
expect(global.fetch).toHaveBeenCalledWith(
294+
expect.stringContaining('preferences'),
295+
expect.objectContaining({
296+
method: 'POST',
297+
body: JSON.stringify([
298+
{
299+
notificationId: 'testSlackNotification',
300+
channel: 'SLACK',
301+
delivery: 'hourly'
302+
}
303+
])
304+
})
305+
);
306+
});
307+
276308
test('identify should call api with correct parameters', async () => {
277309
const mockResponse = {
278310
json: jest.fn().mockResolvedValue({ preferences: [] })

0 commit comments

Comments
 (0)