Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accepting schedule as an ISO 8601 datetime string #23

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notificationapi-node-server-sdk",
"version": "0.18.0",
"version": "0.19.0",
"description": "NotificationAPI server-side library for Node.js",
"keywords": [
"notificationapi",
Expand Down
15 changes: 14 additions & 1 deletion src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
notificationapi.init(clientId, clientSecret);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const promise = notificationapi[func](params);

Check warning on line 65 in src/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Pull Request Pipeline

Function Call Object Injection Sink
expect(promise).toBeInstanceOf(Promise);
});

Expand All @@ -74,7 +74,7 @@
notificationapi.init(clientId, clientSecret);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
await notificationapi[func](params);

Check warning on line 77 in src/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Pull Request Pipeline

Function Call Object Injection Sink
expect(axiosMock.history.post).toHaveLength(1);
});

Expand All @@ -87,7 +87,7 @@
notificationapi.init(clientId, clientSecret);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
await notificationapi[func](params);

Check warning on line 90 in src/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Pull Request Pipeline

Function Call Object Injection Sink
expect(axiosMock.history.post).toHaveLength(1);
expect(axiosMock.history.post[0].headers['Authorization']).toEqual(
'Basic ' + cred
Expand All @@ -104,7 +104,7 @@
notificationapi.init(clientId, clientSecret);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
await notificationapi[func](params);

Check warning on line 107 in src/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Pull Request Pipeline

Function Call Object Injection Sink
expect(console.log).toHaveBeenCalledTimes(1);
});

Expand All @@ -118,7 +118,7 @@
notificationapi.init(clientId, clientSecret);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return notificationapi[func](params).catch(() => {

Check warning on line 121 in src/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Pull Request Pipeline

Function Call Object Injection Sink
expect(console.error).toHaveBeenCalledTimes(1);
});
});
Expand All @@ -133,7 +133,7 @@
notificationapi.init(clientId, clientSecret);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
expect(notificationapi[func](params)).rejects.toEqual(

Check warning on line 136 in src/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Pull Request Pipeline

Function Call Object Injection Sink
new Error('Request failed with status code 500')
);
});
Expand Down Expand Up @@ -247,7 +247,20 @@
'templateId'
);
});

test('includes schedule in the request body', async () => {
axiosMock.onPost(sendEndPointRegex).reply(200);
notificationapi.init(clientId, clientSecret);
const schedule = new Date().toISOString();
await notificationapi.send({
notificationId,
user,
schedule
});
expect(axiosMock.history.post).toHaveLength(1);
expect(JSON.parse(axiosMock.history.post[0].data).schedule).toEqual(
schedule
);
});
test('includes subNotificationId in the request body', async () => {
axiosMock.onPost(sendEndPointRegex).reply(200);
notificationapi.init(clientId, clientSecret);
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface SendRequest {
forceChannels?: Channels[];
/** It will be deprecated soon.*/
secondaryId?: string; //It will be deprecated soon
/**An ISO 8601 datetime string to schedule the notification for. For example, '2024-02-20T14:38:03.509Z' */
schedule?: string;
/** By default, notifications are sent using the default template of each channel. You can permanently change the default template from the dashboard. However, you can also use this parameter to force using a specific template. Optional.*/
templateId?: string;
/** The subNotificationId is used to specify further subcategories within a notification. Optional.*/
Expand Down
Loading