commit fb8713337339749196dcce3a78a69a9b9d6c91ca
parent e1c8683890a309c1be83e41adcc5205d83f69950
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date: Thu, 21 Nov 2024 09:38:34 +0100
adding webhook for the categories
Diffstat:
1 file changed, 36 insertions(+), 6 deletions(-)
diff --git a/src/backenddb/merchant-0013.sql b/src/backenddb/merchant-0013.sql
@@ -57,7 +57,12 @@ BEGIN
-- INSERT case: Add a webhook for category addition
IF TG_OP = 'INSERT' THEN
FOR webhook IN
- SELECT * FROM merchant_webhook
+ SELECT webhook_serial,
+ merchant_serial,
+ url,
+ http_method,
+ body_template
+ FROM merchant_webhook
WHERE event_type = 'category_added'
AND merchant_serial = my_merchant_serial
LOOP
@@ -94,7 +99,12 @@ BEGIN
-- UPDATE case: Add a webhook for category update
IF TG_OP = 'UPDATE' THEN
FOR webhook IN
- SELECT * FROM merchant_webhook
+ SELECT webhook_serial,
+ merchant_serial,
+ url,
+ http_method,
+ body_template
+ FROM merchant_webhook
WHERE event_type = 'category_updated'
AND merchant_serial = my_merchant_serial
LOOP
@@ -139,7 +149,12 @@ BEGIN
-- DELETE case: Add a webhook for category deletion
IF TG_OP = 'DELETE' THEN
FOR webhook IN
- SELECT * FROM merchant_webhook
+ SELECT webhook_serial,
+ merchant_serial,
+ url,
+ http_method,
+ body_template
+ FROM merchant_webhook
WHERE event_type = 'category_deleted'
AND merchant_serial = my_merchant_serial
LOOP
@@ -195,7 +210,12 @@ BEGIN
-- INSERT case: Notify webhooks for inventory addition
IF TG_OP = 'INSERT' THEN
FOR webhook IN
- SELECT * FROM merchant_webhook
+ SELECT webhook_serial,
+ merchant_serial,
+ url,
+ http_method,
+ body_template
+ FROM merchant_webhook
WHERE event_type = 'inventory_added'
AND merchant_serial = my_merchant_serial
LOOP
@@ -268,7 +288,12 @@ BEGIN
-- UPDATE case: Notify webhooks for inventory update
IF TG_OP = 'UPDATE' THEN
FOR webhook IN
- SELECT * FROM merchant_webhook
+ SELECT webhook_serial,
+ merchant_serial,
+ url,
+ http_method,
+ body_template
+ FROM merchant_webhook
WHERE event_type = 'inventory_updated'
AND merchant_serial = my_merchant_serial
LOOP
@@ -380,7 +405,12 @@ BEGIN
-- DELETE case: Notify webhooks for inventory deletion
IF TG_OP = 'DELETE' THEN
FOR webhook IN
- SELECT * FROM merchant_webhook
+ SELECT webhook_serial,
+ merchant_serial,
+ url,
+ http_method,
+ body_template
+ FROM merchant_webhook
WHERE event_type = 'inventory_deleted'
AND merchant_serial = my_merchant_serial
LOOP