summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/voucher.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_api/controllers/api_v1/voucher.py')
-rw-r--r--indoteknik_api/controllers/api_v1/voucher.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/voucher.py b/indoteknik_api/controllers/api_v1/voucher.py
new file mode 100644
index 00000000..0990a1a0
--- /dev/null
+++ b/indoteknik_api/controllers/api_v1/voucher.py
@@ -0,0 +1,22 @@
+from .. import controller
+from odoo import http
+from odoo.http import request
+
+class Voucher(controller.Controller):
+ prefix = '/api/v1/'
+
+ @http.route(prefix + 'voucher', auth='public', methods=['GET', 'OPTIONS'])
+ @controller.Controller.must_authorized()
+ def get_vouchers(self, **kw):
+ code = kw.get('code')
+ visibility = 'public'
+
+ parameter = []
+ if code:
+ visibility = 'private'
+ parameter += [('code', '=', code)]
+
+ parameter += [('visibility', '=', visibility)]
+ vouchers = request.env['voucher'].get_active_voucher(parameter)
+ data = vouchers.res_format()
+ return self.response(data)