Skip to content
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
16 changes: 10 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,15 @@ export default {
ENDPOINT_PATH: 'bundle',
ENDPOINT_OBTAIN_PATH: 'obtain',
},

Notification: {
ENDPOINT_PATH: 'notification',
Protocol: {
WEBHOOK: 'WEBHOOK',
},
Event: {
CREATE_LICENSEE: 'CREATE_LICENSEE',
CREATE_LICENSE: 'CREATE_LICENSE',
},
},
};
20 changes: 10 additions & 10 deletions src/entities/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export default class Notification extends BaseEntity {
number: 'string',
active: 'boolean',
name: 'string',
type: 'string',
protocol: 'string',
events: 'string',
payload: 'string',
url: 'string',
endpoint: 'string',
},
});
}
Expand Down Expand Up @@ -80,12 +80,12 @@ export default class Notification extends BaseEntity {
return this.getProperty('name', def);
}

setType(type) {
return this.setProperty('type', type);
setProtocol(type) {
return this.setProperty('protocol', type);
}

getType(def) {
return this.getProperty('type', def);
getProtocol(def) {
return this.getProperty('protocol', def);
}

setEvents(events) {
Expand All @@ -104,11 +104,11 @@ export default class Notification extends BaseEntity {
return this.getProperty('payload', def);
}

setURL(url) {
return this.setProperty('url', url);
setEndpoint(endpoint) {
return this.setProperty('endpoint', endpoint);
}

getURL(def) {
return this.getProperty('url', def);
getEndpoint(def) {
return this.getProperty('endpoint', def);
}
}
4 changes: 2 additions & 2 deletions test/factories/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export default factory((data = {}) => new Notification({
number: Math.random().toString(36).substr(2, 9),
name: faker.lorem.words(),
active: faker.datatype.boolean(),
type: Math.round(Math.random()) ? 'WEBHOOK' : 'EMAIL',
protocol: Math.round(Math.random()) ? 'WEBHOOK' : 'EMAIL',
events: faker.hacker.verb(),
payload: faker.lorem.sentence(),
url: faker.internet.url(),
endpoint: faker.internet.url(),
custom_property: faker.lorem.words(),

...data,
Expand Down
60 changes: 30 additions & 30 deletions test/specs/entities/Notification.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ describe('entities/Notification', () => {
expect(notification.active).toBe(true);
});

it('check "type" property setters/getters', () => {
notification.setProperty('type', 'WEBHOOK');
expect(notification.getProperty('type')).toBe('WEBHOOK');
expect(notification.getType()).toBe('WEBHOOK');
expect(notification.type).toBe('WEBHOOK');

notification.setType('EMAIL');
expect(notification.getProperty('type')).toBe('EMAIL');
expect(notification.getType()).toBe('EMAIL');
expect(notification.type).toBe('EMAIL');

notification.type = 'EMAIL';
expect(notification.getProperty('type')).toBe('EMAIL');
expect(notification.getType()).toBe('EMAIL');
expect(notification.type).toBe('EMAIL');
it('check "protocol" property setters/getters', () => {
notification.setProperty('protocol', 'WEBHOOK');
expect(notification.getProperty('protocol')).toBe('WEBHOOK');
expect(notification.getProtocol()).toBe('WEBHOOK');
expect(notification.protocol).toBe('WEBHOOK');

notification.setProtocol('EMAIL');
expect(notification.getProperty('protocol')).toBe('EMAIL');
expect(notification.getProtocol()).toBe('EMAIL');
expect(notification.protocol).toBe('EMAIL');

notification.protocol = 'EMAIL';
expect(notification.getProperty('protocol')).toBe('EMAIL');
expect(notification.getProtocol()).toBe('EMAIL');
expect(notification.protocol).toBe('EMAIL');
});

it('check "events" property setters/getters', () => {
Expand Down Expand Up @@ -109,21 +109,21 @@ describe('entities/Notification', () => {
expect(notification.payload).toBe('some-payload-2');
});

it('check "url" property setters/getters', () => {
notification.setProperty('url', 'https://example.com');
expect(notification.getProperty('url')).toBe('https://example.com');
expect(notification.getURL()).toBe('https://example.com');
expect(notification.url).toBe('https://example.com');

notification.setURL('https://example2.com');
expect(notification.getProperty('url')).toBe('https://example2.com');
expect(notification.getURL()).toBe('https://example2.com');
expect(notification.url).toBe('https://example2.com');

notification.url = 'https://example3.com';
expect(notification.getProperty('url')).toBe('https://example3.com');
expect(notification.getURL()).toBe('https://example3.com');
expect(notification.url).toBe('https://example3.com');
it('check "endpoint" property setters/getters', () => {
notification.setProperty('endpoint', 'https://example.com');
expect(notification.getProperty('endpoint')).toBe('https://example.com');
expect(notification.getEndpoint()).toBe('https://example.com');
expect(notification.endpoint).toBe('https://example.com');

notification.setEndpoint('https://example2.com');
expect(notification.getProperty('endpoint')).toBe('https://example2.com');
expect(notification.getEndpoint()).toBe('https://example2.com');
expect(notification.endpoint).toBe('https://example2.com');

notification.endpoint = 'https://example3.com';
expect(notification.getProperty('endpoint')).toBe('https://example3.com');
expect(notification.getEndpoint()).toBe('https://example3.com');
expect(notification.endpoint).toBe('https://example3.com');
});

it('check "custom-property" property setters/getters', () => {
Expand Down
22 changes: 11 additions & 11 deletions test/specs/services/NotificationService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('services/NotificationService', () => {
// configure mock for create request
mock.onPost(`${context.getBaseUrl()}/${Constants.Notification.ENDPOINT_PATH}`)
.reply(200, new Response(
new Item({ ...notification }, 'VendorNotification'),
new Item({ ...notification }, 'Notification'),
));

const entity = await NotificationService.create(context, notification);
Expand All @@ -38,10 +38,10 @@ describe('services/NotificationService', () => {
expect(entity.getProperty('number', null)).toBe(notification.number);
expect(entity.getProperty('name', null)).toBe(notification.name);
expect(entity.getProperty('active', null)).toBe(notification.active);
expect(entity.getProperty('type', null)).toBe(notification.type);
expect(entity.getProperty('protocol', null)).toBe(notification.protocol);
expect(entity.getProperty('events', null)).toBe(notification.events);
expect(entity.getProperty('payload', null)).toBe(notification.payload);
expect(entity.getProperty('url', null)).toBe(notification.url);
expect(entity.getProperty('endpoint', null)).toBe(notification.endpoint);
expect(entity.getProperty('custom_property', null)).toBe(notification.custom_property);
});

Expand All @@ -52,7 +52,7 @@ describe('services/NotificationService', () => {
// configure mock for get request
mock.onGet(`${context.getBaseUrl()}/${Constants.Notification.ENDPOINT_PATH}/${notification.number}`)
.reply(200, new Response(
new Item({ ...notification }, 'VendorNotification'),
new Item({ ...notification }, 'Notification'),
));

const entity = await NotificationService.get(context, notification.number);
Expand All @@ -61,10 +61,10 @@ describe('services/NotificationService', () => {
expect(entity.getProperty('number', null)).toBe(notification.number);
expect(entity.getProperty('name', null)).toBe(notification.name);
expect(entity.getProperty('active', null)).toBe(notification.active);
expect(entity.getProperty('type', null)).toBe(notification.type);
expect(entity.getProperty('protocol', null)).toBe(notification.protocol);
expect(entity.getProperty('events', null)).toBe(notification.events);
expect(entity.getProperty('payload', null)).toBe(notification.payload);
expect(entity.getProperty('url', null)).toBe(notification.url);
expect(entity.getProperty('endpoint', null)).toBe(notification.endpoint);
expect(entity.getProperty('custom_property', null)).toBe(notification.custom_property);
});

Expand All @@ -91,7 +91,7 @@ describe('services/NotificationService', () => {

// configure mock for list request
mock.onGet(`${context.getBaseUrl()}/${Constants.Notification.ENDPOINT_PATH}`)
.reply(200, new Response(notifications.map((v) => new Item(v, 'VendorNotification'))));
.reply(200, new Response(notifications.map((v) => new Item(v, 'Notification'))));

const list = await NotificationService.list(context);

Expand All @@ -103,10 +103,10 @@ describe('services/NotificationService', () => {
expect(entity.getProperty('number', null)).toBe(notification.number);
expect(entity.getProperty('name', null)).toBe(notification.name);
expect(entity.getProperty('active', null)).toBe(notification.active);
expect(entity.getProperty('type', null)).toBe(notification.type);
expect(entity.getProperty('protocol', null)).toBe(notification.protocol);
expect(entity.getProperty('events', null)).toBe(notification.events);
expect(entity.getProperty('payload', null)).toBe(notification.payload);
expect(entity.getProperty('url', null)).toBe(notification.url);
expect(entity.getProperty('endpoint', null)).toBe(notification.endpoint);
expect(entity.getProperty('custom_property', null)).toBe(notification.custom_property);
});
});
Expand Down Expand Up @@ -157,7 +157,7 @@ describe('services/NotificationService', () => {
// configure mock for get request
mock.onGet(`${context.getBaseUrl()}/${Constants.Notification.ENDPOINT_PATH}/${notification.number}`)
.reply(200, new Response(
new Item({ ...notification }, 'VendorNotification'),
new Item({ ...notification }, 'Notification'),
));

notification = await NotificationService.get(context, notification.number);
Expand All @@ -168,7 +168,7 @@ describe('services/NotificationService', () => {
// configure mock for update request
mock.onPost(`${context.getBaseUrl()}/${Constants.Notification.ENDPOINT_PATH}/${notification.number}`)
.reply(200, new Response(
new Item({ ...notification }, 'VendorNotification'),
new Item({ ...notification }, 'Notification'),
));

const updated = await NotificationService.update(context, notification.getProperty('number'), notification);
Expand Down