Skip to content

Commit bbff72b

Browse files
committed
some adjusts
1 parent 5e51023 commit bbff72b

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

components/ikas/sources/common/base.mjs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ export default {
88
customResponse: false,
99
},
1010
db: "$.service.db",
11+
alert: {
12+
type: "alert",
13+
alertType: "warning",
14+
content: "Please note that you can have only one webhook of each type at the same time, any change will overwrite the current webhook configuration.",
15+
},
16+
},
17+
methods: {
18+
_getWebhookId() {
19+
return this.db.get("webhookId");
20+
},
21+
_setWebhookId(webhookId) {
22+
return this.db.set("webhookId", webhookId);
23+
},
1124
},
1225
hooks: {
1326
async activate() {
@@ -30,10 +43,10 @@ export default {
3043
}`,
3144
},
3245
});
33-
this.db.set("webhookId", data.saveWebhook[0].id);
46+
this._setWebhookId(data.saveWebhook[0].id);
3447
},
3548
async deactivate() {
36-
const webhookId = this.db.get("webhookId");
49+
const webhookId = this._getWebhookId();
3750
if (webhookId) {
3851
await this.ikas.makeRequest({
3952
data: {
@@ -46,9 +59,11 @@ export default {
4659
},
4760
},
4861
async run({ body }) {
62+
const data = JSON.parse(body.data);
63+
4964
this.$emit(body, {
5065
id: body.id,
51-
summary: this.getSummary(body),
66+
summary: this.getSummary(data),
5267
ts: Date.parse(body.createdAt),
5368
});
5469
},

components/ikas/sources/new-customer-instant/new-customer-instant.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export default {
1414
getScope() {
1515
return "store/customer/created";
1616
},
17-
getSummary(body) {
18-
const data = JSON.parse(body.data);
17+
getSummary(data) {
1918
return `New customer created with Id: ${data.id}.`;
2019
},
2120
},

components/ikas/sources/new-order-instant/new-order-instant.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export default {
1414
getScope() {
1515
return "store/order/created";
1616
},
17-
getSummary(body) {
18-
const data = JSON.parse(body.data);
17+
getSummary(data) {
1918
return `New order created with Id: ${data.id}.`;
2019
},
2120
},

components/ikas/sources/new-product-instant/new-product-instant.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ export default {
1414
getScope() {
1515
return "store/product/created";
1616
},
17-
getSummary(body) {
18-
const data = JSON.parse(body.data);
17+
getSummary(data) {
1918
return `New product created with Id: ${data.id}.`;
2019
},
2120
},

0 commit comments

Comments
 (0)