diff --git a/package-lock.json b/package-lock.json index 553b966..def409f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2803,9 +2803,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001434", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001434.tgz", - "integrity": "sha512-aOBHrLmTQw//WFa2rcF1If9fa3ypkC1wzqqiKHgfdrXTWcU8C4gKVZT77eQAPWN1APys3+uQ0Df07rKauXGEYA==", + "version": "1.0.30001492", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001492.tgz", + "integrity": "sha512-2efF8SAZwgAX1FJr87KWhvuJxnGJKOnctQa8xLOskAXNXq8oiuqgl6u1kk3fFpsp3GgvzlRjiK1sl63hNtFADw==", "dev": true, "funding": [ { @@ -2815,6 +2815,10 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ] }, @@ -9164,9 +9168,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001434", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001434.tgz", - "integrity": "sha512-aOBHrLmTQw//WFa2rcF1If9fa3ypkC1wzqqiKHgfdrXTWcU8C4gKVZT77eQAPWN1APys3+uQ0Df07rKauXGEYA==", + "version": "1.0.30001492", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001492.tgz", + "integrity": "sha512-2efF8SAZwgAX1FJr87KWhvuJxnGJKOnctQa8xLOskAXNXq8oiuqgl6u1kk3fFpsp3GgvzlRjiK1sl63hNtFADw==", "dev": true }, "chalk": { diff --git a/src/Constants.js b/src/Constants.js index d28fbf4..1e71b15 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -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', + }, + }, }; diff --git a/src/entities/Notification.js b/src/entities/Notification.js index 1a5c841..399647d 100644 --- a/src/entities/Notification.js +++ b/src/entities/Notification.js @@ -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', }, }); } @@ -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) { @@ -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); } } diff --git a/test/factories/notification.js b/test/factories/notification.js index 6c80576..9b968f8 100644 --- a/test/factories/notification.js +++ b/test/factories/notification.js @@ -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, diff --git a/test/specs/entities/Notification.spec.js b/test/specs/entities/Notification.spec.js index 5bdd6bf..5d93ce8 100644 --- a/test/specs/entities/Notification.spec.js +++ b/test/specs/entities/Notification.spec.js @@ -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', () => { @@ -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', () => { diff --git a/test/specs/services/NotificationService.spec.js b/test/specs/services/NotificationService.spec.js index fef1fe0..601524b 100644 --- a/test/specs/services/NotificationService.spec.js +++ b/test/specs/services/NotificationService.spec.js @@ -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); @@ -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); }); @@ -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); @@ -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); }); @@ -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); @@ -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); }); }); @@ -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); @@ -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);