def put_resource(id):
    json = request.get_json()

    if not isinstance(json, dict):
        return wrong_type("resource object", type(json))

    validation_errors = validate_resource(request.method, json, id)

    if validation_errors:
        errors = {"errors": validation_errors}
        return utils.standardize_response(payload=errors, status_code=422)
    return update_resource(id, request.get_json(), db)
Example #2
0
def post_resources():
    json = request.get_json()

    if not isinstance(json, list):
        return wrong_type("list of resources objects", type(json))

    validation_errors = validate_resource_list(request.method, json)

    if validation_errors:
        return utils.standardize_response(payload=validation_errors, status_code=422)

    return create_resources(json, db)