Exemple #1
0
    def post_business(payload):
        body = request.get_json()
        id = body.get('id', None)
        name = body.get('name', None)
        address = body.get('address', None)
        phone = body.get('phone', None)
        cif = body.get('cif', None)
        email = body.get('email', None)

        try:
            if id is None:
                business = Business(name=name,
                                    address=address,
                                    phone=phone,
                                    cif=cif,
                                    email=email)
            else:
                business = Business(id=id,
                                    name=name,
                                    address=address,
                                    phone=phone,
                                    cif=cif,
                                    email=email)
            business.insert()
        except:
            abort(422)

        return jsonify({
            'success': True,
            'business': business.long(),
            'status': 200
        }), 200