def METHOD_NAME(
    self,
    integration_type: IntegrationType,
    application: Application,
    before=None,
    **kwargs
) -> Integration:
    """
    Creates a new integration for an application.
    :param integration_type: The type of the integration.
    :param application: The application the integration exists in.
    :param before: The integration before which we want to create the integration.
        If not provided, the integration is added as last one.
    :param kwargs: Additional attributes of the integration.
    :raises CannotCalculateIntermediateOrder: If it's not possible to find an
        intermediate order. The full order of the integration of the application
        must be recalculated in this case before calling this method again.
    :return: The created integration.
    """
    application_type = application_type_registry.get_by_model(
        application.specific_class
    )
    if not application_type.supports_integrations:
        raise ApplicationOperationNotSupported()
    if before:
        order = Integration.get_unique_order_before_integration(before)
    else:
        order = Integration.get_last_order(application)
    shared_allowed_fields = ["type", "name"]
    allowed_values = extract_allowed(
        kwargs, shared_allowed_fields + integration_type.allowed_fields
    )
    model_class = cast(Integration, integration_type.model_class)
    integration = model_class(
        application=application, order=order, **allowed_values
    )
    integration.save()
    return integration