summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/promotion.py
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2022-11-03 15:34:12 +0700
committerIT Fixcomart <it@fixcomart.co.id>2022-11-03 15:34:12 +0700
commit4aa474f3ced6681a1dfd5ec48806eb690e31c3d8 (patch)
treed1dfdaea2768c47e3a53b4fed59223082cbe9481 /indoteknik_api/controllers/api_v1/promotion.py
parent76ccac9630b60ca3774eb83fb13f1a89ee3cabf1 (diff)
Rest API Promotion
Diffstat (limited to 'indoteknik_api/controllers/api_v1/promotion.py')
-rw-r--r--indoteknik_api/controllers/api_v1/promotion.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/promotion.py b/indoteknik_api/controllers/api_v1/promotion.py
new file mode 100644
index 00000000..8e66e543
--- /dev/null
+++ b/indoteknik_api/controllers/api_v1/promotion.py
@@ -0,0 +1,31 @@
+from .. import controller
+from odoo import http
+from odoo.http import request
+import ast
+
+
+class Promotion(controller.Controller):
+ prefix = '/api/v1/'
+
+ @http.route(prefix + 'promotion/<id>', auth='public', methods=['GET'])
+ def get_product_by_id(self, **kw):
+ if not self.authenticate():
+ return self.response(code=401, description='Unauthorized')
+
+ base_url = request.env['ir.config_parameter'].get_param('web.base.url')
+ id = kw.get('id')
+ if not id:
+ return self.response(code=400, description='id is required')
+
+ data = {}
+ id = int(id)
+ coupon_program = request.env['coupon.program'].search([('id', '=', id)])
+ if coupon_program:
+ data = {
+ 'banner': base_url + 'api/image/coupon.program/x_studio_banner_promo/' + str(coupon_program.id) if coupon_program.x_studio_banner_promo else '',
+ 'image': base_url + 'api/image/coupon.program/x_studio_image_promo/' + str(coupon_program.id) if coupon_program.x_studio_image_promo else '',
+ 'name': coupon_program.name,
+ }
+
+ return self.response(data)
+ \ No newline at end of file