"""Handlers for vendor agreement.""" from flask.typing import ResponseReturnValue from collaborator.api import app from collaborator.logic import vendor_agreement from collaborator.utils import handlers as utils from collaborator.utils.helpers import check_vendors_authorization from collaborator.utils.typing import ACCOUNT_TYPE_VENDOR, Account @app.route("/vendor-agreement", methods=["POST"]) @utils.fetch_authorized_resources def create_vendor_agreement(authorized_resources, user) -> ResponseReturnValue: """Create vendor agreement. Args: params (dict): dictionary with the body params of the request Returns: response with the created vendor agreement """ account_id = utils.get_vendor_id_from_request() check_vendors_authorization(authorized_resources, [account_id]) account = Account(type=ACCOUNT_TYPE_VENDOR, id=account_id) return vendor_agreement.create_vendor_agreement(account, user) @app.route("/vendor-agreement", methods=["GET"]) @utils.fetch_authorized_resources def get_vendor_agreement(authorized_resources, user) -> ResponseReturnValue: """Create vendor agreement. Returns: response with the requested vendor agreement """ account_id = utils.get_vendor_id_from_request() check_vendors_authorization(authorized_resources, [account_id]) account = Account(type=ACCOUNT_TYPE_VENDOR, id=account_id) return vendor_agreement.get_vendor_agreement(account)