Skip to content

Commit 6520484

Browse files
authored
fix: custom email notification payload update (#51)
Signed-off-by: nitish <[email protected]>
1 parent 5948666 commit 6520484

File tree

6 files changed

+58
-28
lines changed

6 files changed

+58
-28
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "package-lock.json|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2023-08-31T07:38:15Z",
6+
"generated_at": "2023-09-26T04:27:01Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,9 @@ const res = await eventNotificationsService.replaceIntegration(params);
851851
},
852852
}
853853

854+
const htmlBody =
855+
'"Hi ,<br/>Certificate expiring in 90 days.<br/><br/>Please login to <a href="https: //cloud.ibm.com/security-compliance/dashboard">Security and Complaince dashboard</a> to find more information<br/>"';
856+
854857
let notificationID = "<notification-id>"
855858
let notificationSubject = "<notification-subject>"
856859
let notificationSeverity = "<notification-severity>"
@@ -870,6 +873,9 @@ const notificationCreateModel = {
870873
ibmenapnsbody: JSON.stringify(notificationApnsBodyModel),
871874
ibmensafaribody: JSON.stringify(notificationSafariBodymodel),
872875
ibmenhuaweibody: JSON.stringify(notificationHuaweiBodymodel),
876+
ibmenmailto: JSON.stringify(['[email protected]', '[email protected]']),
877+
ibmensubject: 'certificate expire',
878+
ibmenhtmlbody: htmlBody,
873879
ibmendefaultshort: 'short info',
874880
ibmendefaultlong: 'long info',
875881
specversion: '1.0',

event-notifications/v1.ts

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,23 +2441,14 @@ namespace EventNotificationsV1 {
24412441
/** The Message Template. */
24422442
name: string;
24432443
/** The type of template. */
2444-
type: CreateTemplateConstants.Type | string;
2444+
type: string;
24452445
/** Payload describing a template configuration. */
24462446
params: TemplateConfig;
24472447
/** The Template description. */
24482448
description?: string;
24492449
headers?: OutgoingHttpHeaders;
24502450
}
24512451

2452-
/** Constants for the `createTemplate` operation. */
2453-
export namespace CreateTemplateConstants {
2454-
/** The type of template. */
2455-
export enum Type {
2456-
SMTP_CUSTOM_NOTIFICATION = 'smtp_custom.notification',
2457-
SMTP_CUSTOM_INVITATION = 'smtp_custom.invitation',
2458-
}
2459-
}
2460-
24612452
/** Parameters for the `listTemplates` operation. */
24622453
export interface ListTemplatesParams {
24632454
/** Unique identifier for IBM Cloud Event Notifications instance. */
@@ -2491,21 +2482,12 @@ namespace EventNotificationsV1 {
24912482
/** Template description. */
24922483
description?: string;
24932484
/** The type of template. */
2494-
type?: UpdateTemplateConstants.Type | string;
2485+
type?: string;
24952486
/** Payload describing a template configuration. */
24962487
params?: TemplateConfig;
24972488
headers?: OutgoingHttpHeaders;
24982489
}
24992490

2500-
/** Constants for the `updateTemplate` operation. */
2501-
export namespace UpdateTemplateConstants {
2502-
/** The type of template. */
2503-
export enum Type {
2504-
SMTP_CUSTOM_NOTIFICATION = 'smtp_custom.notification',
2505-
SMTP_CUSTOM_INVITATION = 'smtp_custom.invitation',
2506-
}
2507-
}
2508-
25092491
/** Parameters for the `deleteTemplate` operation. */
25102492
export interface DeleteTemplateParams {
25112493
/** Unique identifier for IBM Cloud Event Notifications instance. */
@@ -3021,6 +3003,12 @@ namespace EventNotificationsV1 {
30213003
/** Default long text for the message. */
30223004
ibmendefaultlong: string;
30233005
/** The subject of the notification. */
3006+
ibmensubject?: string;
3007+
/** The email id string. */
3008+
ibmenmailto?: string;
3009+
/** The html body of notification. */
3010+
ibmenhtmlbody?: string;
3011+
/** The subject of the notification. */
30243012
subject?: string;
30253013
/** The payload for webhook notification. */
30263014
data?: JsonObject;
@@ -3323,7 +3311,7 @@ namespace EventNotificationsV1 {
33233311
name: string;
33243312
/** Template description. */
33253313
description: string;
3326-
/** template type. */
3314+
/** The type of template. */
33273315
type: string;
33283316
/** Subscription count. */
33293317
subscription_count: number;
@@ -3367,7 +3355,7 @@ namespace EventNotificationsV1 {
33673355
name: string;
33683356
/** Template description. */
33693357
description?: string;
3370-
/** Template type. */
3358+
/** The type of template. */
33713359
type: string;
33723360
/** Payload describing a template configuration. */
33733361
params: TemplateConfig;

examples/event-notifications.v1.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,8 @@ describe('EventNotificationsV1', () => {
20732073
const date = '2019-01-01T12:00:00.000Z';
20742074
const userId = 'userId';
20752075
const notificationsSouce = '1234-1234-sdfs-234:test';
2076+
const htmlBody =
2077+
'"Hi ,<br/>Certificate expiring in 90 days.<br/><br/>Please login to <a href="https: //cloud.ibm.com/security-compliance/dashboard">Security and Complaince dashboard</a> to find more information<br/>"';
20762078

20772079
// begin-send_notifications
20782080

@@ -2106,6 +2108,23 @@ describe('EventNotificationsV1', () => {
21062108
},
21072109
};
21082110

2111+
const notificationHuaweiBodyMessageDataModel = {
2112+
'android': {
2113+
'notification': {
2114+
'title': 'Alert message',
2115+
'body': 'Bob wants to play cricket',
2116+
},
2117+
'data': {
2118+
'name': 'Robert',
2119+
'description': 'notification for the cricket',
2120+
},
2121+
},
2122+
};
2123+
2124+
const notificationHuaweiBodyModel = {
2125+
message: notificationHuaweiBodyMessageDataModel,
2126+
};
2127+
21092128
const notificationCreateModel = {
21102129
instanceId,
21112130
ibmenseverity: notificationSeverity,
@@ -2115,9 +2134,13 @@ describe('EventNotificationsV1', () => {
21152134
type: typeValue,
21162135
time: date,
21172136
ibmenpushto: JSON.stringify(notificationFcmDevicesModel),
2137+
ibmenmailto: JSON.stringify(['[email protected]', '[email protected]']),
2138+
ibmensubject: 'certificate expire',
2139+
ibmenhtmlbody: htmlBody,
21182140
ibmenfcmbody: JSON.stringify(notificationFcmBodyModel),
21192141
ibmenapnsbody: JSON.stringify(notificationApnsBodyModel),
21202142
ibmensafaribody: JSON.stringify(notificationSafariBodymodel),
2143+
ibmenhuaweibody: JSON.stringify(notificationHuaweiBodyModel),
21212144
ibmendefaultshort: 'testString',
21222145
ibmendefaultlong: 'testString',
21232146
specversion: '1.0',

test/integration/event-notifications.v1.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,8 @@ describe('EventNotificationsV1_integration', () => {
24832483
const notificationSeverity = 'MEDIUM';
24842484
const typeValue = 'com.acme.offer:new';
24852485
const notificationsSouce = '1234-1234-sdfs-234:test';
2486+
const htmlBody =
2487+
'"Hi ,<br/>Certificate expiring in 90 days.<br/><br/>Please login to <a href="https: //cloud.ibm.com/security-compliance/dashboard">Security and Complaince dashboard</a> to find more information<br/>"';
24862488

24872489
const notificationCreateModel = {
24882490
instanceId,
@@ -2492,6 +2494,9 @@ describe('EventNotificationsV1_integration', () => {
24922494
ibmensourceid: sourceId,
24932495
type: typeValue,
24942496
time: '2019-01-01T12:00:00.000Z',
2497+
ibmenmailto: JSON.stringify(['[email protected]', '[email protected]']),
2498+
ibmensubject: 'certificate expire',
2499+
ibmenhtmlbody: htmlBody,
24952500
ibmenpushto: JSON.stringify(notificationFcmDevicesModel),
24962501
ibmenfcmbody: JSON.stringify(notificationFcmBodyModel),
24972502
ibmenapnsbody: JSON.stringify(notificationApnsBodyModel),
@@ -2541,6 +2546,8 @@ describe('EventNotificationsV1_integration', () => {
25412546
type: typeValue,
25422547
time: '2019-01-01T12:00:00.000Z',
25432548
ibmenpushto: JSON.stringify(notificationFcmDevicesModel),
2549+
ibmenmailto: JSON.stringify(['[email protected]', '[email protected]']),
2550+
ibmensubject: 'EventNotifiations Testing',
25442551
ibmenfcmbody: JSON.stringify(fcmOptions),
25452552
ibmenapnsbody: JSON.stringify(apnsOptions),
25462553
ibmensafaribody: JSON.stringify(notificationSafariBodymodel),

test/unit/event-notifications.v1.test.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ describe('EventNotificationsV1', () => {
129129
ibmensourceid: 'testString',
130130
ibmendefaultshort: 'testString',
131131
ibmendefaultlong: 'testString',
132+
ibmensubject: 'testString',
133+
ibmenmailto: 'testString',
134+
ibmenhtmlbody: 'testString',
132135
subject: 'testString',
133136
data: { foo: 'bar' },
134137
datacontenttype: 'application/json',
@@ -246,6 +249,9 @@ describe('EventNotificationsV1', () => {
246249
ibmensourceid: 'testString',
247250
ibmendefaultshort: 'testString',
248251
ibmendefaultlong: 'testString',
252+
ibmensubject: 'testString',
253+
ibmenmailto: 'testString',
254+
ibmenhtmlbody: 'testString',
249255
subject: 'testString',
250256
data: { foo: 'bar' },
251257
datacontenttype: 'application/json',
@@ -1434,7 +1440,7 @@ describe('EventNotificationsV1', () => {
14341440
// Construct the params object for operation createTemplate
14351441
const instanceId = 'testString';
14361442
const name = 'testString';
1437-
const type = 'smtp_custom.notification';
1443+
const type = 'testString';
14381444
const params = templateConfigModel;
14391445
const description = 'testString';
14401446
const createTemplateParams = {
@@ -1485,7 +1491,7 @@ describe('EventNotificationsV1', () => {
14851491
// parameters
14861492
const instanceId = 'testString';
14871493
const name = 'testString';
1488-
const type = 'smtp_custom.notification';
1494+
const type = 'testString';
14891495
const params = templateConfigModel;
14901496
const userAccept = 'fake/accept';
14911497
const userContentType = 'fake/contentType';
@@ -1626,9 +1632,9 @@ describe('EventNotificationsV1', () => {
16261632
const serviceUrl = eventNotificationsServiceOptions.url;
16271633
const path = '/v1/instances/testString/templates';
16281634
const mockPagerResponse1 =
1629-
'{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"templates":[{"id":"id","name":"name","description":"description","type":"smtp_custom.notification","subscription_count":18,"subscription_names":["subscription_names"],"updated_at":"2019-01-01T12:00:00.000Z"}],"limit":1}';
1635+
'{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"templates":[{"id":"id","name":"name","description":"description","type":"type","subscription_count":18,"subscription_names":["subscription_names"],"updated_at":"2019-01-01T12:00:00.000Z"}],"limit":1}';
16301636
const mockPagerResponse2 =
1631-
'{"total_count":2,"templates":[{"id":"id","name":"name","description":"description","type":"smtp_custom.notification","subscription_count":18,"subscription_names":["subscription_names"],"updated_at":"2019-01-01T12:00:00.000Z"}],"limit":1}';
1637+
'{"total_count":2,"templates":[{"id":"id","name":"name","description":"description","type":"type","subscription_count":18,"subscription_names":["subscription_names"],"updated_at":"2019-01-01T12:00:00.000Z"}],"limit":1}';
16321638

16331639
beforeEach(() => {
16341640
unmock_createRequest();
@@ -1780,7 +1786,7 @@ describe('EventNotificationsV1', () => {
17801786
const id = 'testString';
17811787
const name = 'testString';
17821788
const description = 'testString';
1783-
const type = 'smtp_custom.notification';
1789+
const type = 'testString';
17841790
const params = templateConfigModel;
17851791
const updateTemplateParams = {
17861792
instanceId,

0 commit comments

Comments
 (0)