summaryrefslogtreecommitdiff
path: root/fixco_api/controllers/api_v1/webhook_ginee.py
diff options
context:
space:
mode:
Diffstat (limited to 'fixco_api/controllers/api_v1/webhook_ginee.py')
-rw-r--r--fixco_api/controllers/api_v1/webhook_ginee.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/fixco_api/controllers/api_v1/webhook_ginee.py b/fixco_api/controllers/api_v1/webhook_ginee.py
new file mode 100644
index 0000000..dbb8bcd
--- /dev/null
+++ b/fixco_api/controllers/api_v1/webhook_ginee.py
@@ -0,0 +1,33 @@
+from odoo import http
+import json
+import logging
+from datetime import datetime
+
+_logger = logging.getLogger(__name__)
+
+class WebhookController(http.Controller):
+ @http.route('/webhook/order', type='json', auth='public', methods=['POST'], csrf=False)
+ def handle_webhook(self):
+ data = http.request.jsonrequest
+ _logger.info("Data webhook diterima: %s", data)
+
+ try:
+ # Simpan data JSON ke model webhook.ginee
+ webhook_record = http.request.env['webhook.ginee'].create({
+ 'json_ginee': json.dumps(data) # Konversi dict ke string JSON
+ })
+
+ _logger.info("Data berhasil disimpan dengan ID: %s", webhook_record.id)
+
+ return {
+ 'status': 'success',
+ 'message': 'Webhook berhasil diproses',
+ 'record_id': webhook_record.id
+ }
+
+ except Exception as e:
+ _logger.error("Gagal memproses webhook: %s", str(e))
+ return {
+ 'status': 'error',
+ 'message': str(e)
+ } \ No newline at end of file