Skip to content

Commit c697540

Browse files
authored
rename type to protocol, url to endpoint (#62)
1 parent 580102d commit c697540

File tree

6 files changed

+74
-59
lines changed

6 files changed

+74
-59
lines changed

package-lock.json

+10-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Constants.js

+11
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,15 @@ export default {
210210
ENDPOINT_PATH: 'bundle',
211211
ENDPOINT_OBTAIN_PATH: 'obtain',
212212
},
213+
214+
Notification: {
215+
ENDPOINT_PATH: 'notification',
216+
Protocol: {
217+
WEBHOOK: 'WEBHOOK',
218+
},
219+
Event: {
220+
CREATE_LICENSEE: 'CREATE_LICENSEE',
221+
CREATE_LICENSE: 'CREATE_LICENSE',
222+
},
223+
},
213224
};

src/entities/Notification.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ export default class Notification extends BaseEntity {
4848
number: 'string',
4949
active: 'boolean',
5050
name: 'string',
51-
type: 'string',
51+
protocol: 'string',
5252
events: 'string',
5353
payload: 'string',
54-
url: 'string',
54+
endpoint: 'string',
5555
},
5656
});
5757
}
@@ -80,12 +80,12 @@ export default class Notification extends BaseEntity {
8080
return this.getProperty('name', def);
8181
}
8282

83-
setType(type) {
84-
return this.setProperty('type', type);
83+
setProtocol(type) {
84+
return this.setProperty('protocol', type);
8585
}
8686

87-
getType(def) {
88-
return this.getProperty('type', def);
87+
getProtocol(def) {
88+
return this.getProperty('protocol', def);
8989
}
9090

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

107-
setURL(url) {
108-
return this.setProperty('url', url);
107+
setEndpoint(endpoint) {
108+
return this.setProperty('endpoint', endpoint);
109109
}
110110

111-
getURL(def) {
112-
return this.getProperty('url', def);
111+
getEndpoint(def) {
112+
return this.getProperty('endpoint', def);
113113
}
114114
}

test/factories/notification.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export default factory((data = {}) => new Notification({
66
number: Math.random().toString(36).substr(2, 9),
77
name: faker.lorem.words(),
88
active: faker.datatype.boolean(),
9-
type: Math.round(Math.random()) ? 'WEBHOOK' : 'EMAIL',
9+
protocol: Math.round(Math.random()) ? 'WEBHOOK' : 'EMAIL',
1010
events: faker.hacker.verb(),
1111
payload: faker.lorem.sentence(),
12-
url: faker.internet.url(),
12+
endpoint: faker.internet.url(),
1313
custom_property: faker.lorem.words(),
1414

1515
...data,

test/specs/entities/Notification.spec.js

+30-30
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,21 @@ describe('entities/Notification', () => {
5858
expect(notification.active).toBe(true);
5959
});
6060

61-
it('check "type" property setters/getters', () => {
62-
notification.setProperty('type', 'WEBHOOK');
63-
expect(notification.getProperty('type')).toBe('WEBHOOK');
64-
expect(notification.getType()).toBe('WEBHOOK');
65-
expect(notification.type).toBe('WEBHOOK');
66-
67-
notification.setType('EMAIL');
68-
expect(notification.getProperty('type')).toBe('EMAIL');
69-
expect(notification.getType()).toBe('EMAIL');
70-
expect(notification.type).toBe('EMAIL');
71-
72-
notification.type = 'EMAIL';
73-
expect(notification.getProperty('type')).toBe('EMAIL');
74-
expect(notification.getType()).toBe('EMAIL');
75-
expect(notification.type).toBe('EMAIL');
61+
it('check "protocol" property setters/getters', () => {
62+
notification.setProperty('protocol', 'WEBHOOK');
63+
expect(notification.getProperty('protocol')).toBe('WEBHOOK');
64+
expect(notification.getProtocol()).toBe('WEBHOOK');
65+
expect(notification.protocol).toBe('WEBHOOK');
66+
67+
notification.setProtocol('EMAIL');
68+
expect(notification.getProperty('protocol')).toBe('EMAIL');
69+
expect(notification.getProtocol()).toBe('EMAIL');
70+
expect(notification.protocol).toBe('EMAIL');
71+
72+
notification.protocol = 'EMAIL';
73+
expect(notification.getProperty('protocol')).toBe('EMAIL');
74+
expect(notification.getProtocol()).toBe('EMAIL');
75+
expect(notification.protocol).toBe('EMAIL');
7676
});
7777

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

112-
it('check "url" property setters/getters', () => {
113-
notification.setProperty('url', 'https://example.com');
114-
expect(notification.getProperty('url')).toBe('https://example.com');
115-
expect(notification.getURL()).toBe('https://example.com');
116-
expect(notification.url).toBe('https://example.com');
117-
118-
notification.setURL('https://example2.com');
119-
expect(notification.getProperty('url')).toBe('https://example2.com');
120-
expect(notification.getURL()).toBe('https://example2.com');
121-
expect(notification.url).toBe('https://example2.com');
122-
123-
notification.url = 'https://example3.com';
124-
expect(notification.getProperty('url')).toBe('https://example3.com');
125-
expect(notification.getURL()).toBe('https://example3.com');
126-
expect(notification.url).toBe('https://example3.com');
112+
it('check "endpoint" property setters/getters', () => {
113+
notification.setProperty('endpoint', 'https://example.com');
114+
expect(notification.getProperty('endpoint')).toBe('https://example.com');
115+
expect(notification.getEndpoint()).toBe('https://example.com');
116+
expect(notification.endpoint).toBe('https://example.com');
117+
118+
notification.setEndpoint('https://example2.com');
119+
expect(notification.getProperty('endpoint')).toBe('https://example2.com');
120+
expect(notification.getEndpoint()).toBe('https://example2.com');
121+
expect(notification.endpoint).toBe('https://example2.com');
122+
123+
notification.endpoint = 'https://example3.com';
124+
expect(notification.getProperty('endpoint')).toBe('https://example3.com');
125+
expect(notification.getEndpoint()).toBe('https://example3.com');
126+
expect(notification.endpoint).toBe('https://example3.com');
127127
});
128128

129129
it('check "custom-property" property setters/getters', () => {

test/specs/services/NotificationService.spec.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('services/NotificationService', () => {
2929
// configure mock for create request
3030
mock.onPost(`${context.getBaseUrl()}/${Constants.Notification.ENDPOINT_PATH}`)
3131
.reply(200, new Response(
32-
new Item({ ...notification }, 'VendorNotification'),
32+
new Item({ ...notification }, 'Notification'),
3333
));
3434

3535
const entity = await NotificationService.create(context, notification);
@@ -38,10 +38,10 @@ describe('services/NotificationService', () => {
3838
expect(entity.getProperty('number', null)).toBe(notification.number);
3939
expect(entity.getProperty('name', null)).toBe(notification.name);
4040
expect(entity.getProperty('active', null)).toBe(notification.active);
41-
expect(entity.getProperty('type', null)).toBe(notification.type);
41+
expect(entity.getProperty('protocol', null)).toBe(notification.protocol);
4242
expect(entity.getProperty('events', null)).toBe(notification.events);
4343
expect(entity.getProperty('payload', null)).toBe(notification.payload);
44-
expect(entity.getProperty('url', null)).toBe(notification.url);
44+
expect(entity.getProperty('endpoint', null)).toBe(notification.endpoint);
4545
expect(entity.getProperty('custom_property', null)).toBe(notification.custom_property);
4646
});
4747

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

5858
const entity = await NotificationService.get(context, notification.number);
@@ -61,10 +61,10 @@ describe('services/NotificationService', () => {
6161
expect(entity.getProperty('number', null)).toBe(notification.number);
6262
expect(entity.getProperty('name', null)).toBe(notification.name);
6363
expect(entity.getProperty('active', null)).toBe(notification.active);
64-
expect(entity.getProperty('type', null)).toBe(notification.type);
64+
expect(entity.getProperty('protocol', null)).toBe(notification.protocol);
6565
expect(entity.getProperty('events', null)).toBe(notification.events);
6666
expect(entity.getProperty('payload', null)).toBe(notification.payload);
67-
expect(entity.getProperty('url', null)).toBe(notification.url);
67+
expect(entity.getProperty('endpoint', null)).toBe(notification.endpoint);
6868
expect(entity.getProperty('custom_property', null)).toBe(notification.custom_property);
6969
});
7070

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

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

9696
const list = await NotificationService.list(context);
9797

@@ -103,10 +103,10 @@ describe('services/NotificationService', () => {
103103
expect(entity.getProperty('number', null)).toBe(notification.number);
104104
expect(entity.getProperty('name', null)).toBe(notification.name);
105105
expect(entity.getProperty('active', null)).toBe(notification.active);
106-
expect(entity.getProperty('type', null)).toBe(notification.type);
106+
expect(entity.getProperty('protocol', null)).toBe(notification.protocol);
107107
expect(entity.getProperty('events', null)).toBe(notification.events);
108108
expect(entity.getProperty('payload', null)).toBe(notification.payload);
109-
expect(entity.getProperty('url', null)).toBe(notification.url);
109+
expect(entity.getProperty('endpoint', null)).toBe(notification.endpoint);
110110
expect(entity.getProperty('custom_property', null)).toBe(notification.custom_property);
111111
});
112112
});
@@ -157,7 +157,7 @@ describe('services/NotificationService', () => {
157157
// configure mock for get request
158158
mock.onGet(`${context.getBaseUrl()}/${Constants.Notification.ENDPOINT_PATH}/${notification.number}`)
159159
.reply(200, new Response(
160-
new Item({ ...notification }, 'VendorNotification'),
160+
new Item({ ...notification }, 'Notification'),
161161
));
162162

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

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

0 commit comments

Comments
 (0)