summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/lead.py
blob: 6ca9d419c6d42dff9258279c20e5565e06cd94a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from .. import controller
from odoo import http
from odoo.http import request

class Lead(controller.Controller):
    @http.route('/api/v1/lead', auth='public', methods=['POST', 'OPTIONS'], csrf=False)
    @controller.Controller.must_authorized()
    def create_lead(self, **kw):
        params = self.get_request_params(kw, {
            "name": ["required"],
            "contact_name": [],
            "email_from": [],
            "phone": [],
            "file_npwp": [],
            "file_nib": [],
            "file_tdp": [],
            "file_siup": [],
            "file_quotation": [],
            "description": []
        })

        if not params['valid']:
            return self.response(code=400, description=params)

        params['value']['user_id'] = 20

        lead = request.env['crm.lead'].create(params['value'])

        return self.response(True)

    @http.route('/api/v1/merchant', auth='public', methods=['POST', 'OPTIONS'], csrf=False)
    @controller.Controller.must_authorized()
    def create_merchant(self, **kw):
        params = self.get_request_params(kw, {
            "name": ["required"],
            "contact_name": [],
            "email_from": [],
            "phone": [],
            "file_npwp": [],
            "file_nib": [],
            "file_tdp": [],
            "file_siup": [],
            "file_quotation": [],
            "description": []
        })

        if not params['valid']:
            return self.response(code=400, description=params)

        # params['value']['user_id'] = 20

        # lead = request.env['crm.lead'].create(params['value'])

        return self.response(True)