src/utils.py
def build_callback_url(request, urlname, message):
    """
    Build Twilio callback url for confirming message delivery status

    :type message: OutgoingSMS
    """
    location = reverse(urlname, kwargs={"pk": message.pk})

    callback_domain = getattr(settings, "TWILIO_CALLBACK_DOMAIN", None)
    if callback_domain:
        url = "{}://{}{}".format(
            "https" if getattr(settings, "TWILIO_CALLBACK_USE_HTTPS", False) else "http",
            callback_domain,
            location
        )

    elif request is not None:
        url = request.build_absolute_uri(location)
    else:
        raise ValueError(
            "Unable to build callback url. Configure TWILIO_CALLBACK_DOMAIN "
            "or pass request object to function call"
        )
    return url
def build_callback_url(request, urlname, message):
    location = reverse(urlname, kwargs={"pk": message.pk})

    callback_domain = getattr(settings, "TWILIO_CALLBACK_DOMAIN", None)
    if callback_domain:
        url = "{}://{}{}".format(
            "https" if getattr(settings, "TWILIO_CALLBACK_USE_HTTPS", False) else "http",
            callback_domain,
            location
        )

    elif request is not None:
        url = request.build_absolute_uri(location)
    else:
        raise ValueError(
            "Unable to build callback url. Configure TWILIO_CALLBACK_DOMAIN "
            "or pass request object to function call"
        )
    return url
def build_callback_url ( request , urlname , message ) : location = reverse ( urlname , kwargs = { "pk" : message . pk } ) callback_domain = getattr ( settings , "TWILIO_CALLBACK_DOMAIN" , None ) if callback_domain : url = "{}://{}{}" . format ( "https" if getattr ( settings , "TWILIO_CALLBACK_USE_HTTPS" , False ) else "http" , callback_domain , location ) elif request is not None : url = request . build_absolute_uri ( location ) else : raise ValueError ( "Unable to build callback url. Configure TWILIO_CALLBACK_DOMAIN " "or pass request object to function call" ) return url
Build Twilio callback url for confirming message delivery status

    :type message: OutgoingSMS
Build Twilio callback url for confirming message delivery status