Get an OA version for a given DOI.

    .. note::

        Uses beta.dissem.in API.

    :param doi: A canonical DOI.
    :returns: The URL of the OA version of the given DOI, or ``None``.

    >>> get_oa_version('10.1209/0295-5075/111/40005')
    'http://arxiv.org/abs/1506.06690'

def get_oa_version(doi):
    """
    Get an OA version for a given DOI.

    .. note::

        Uses beta.dissem.in API.

    :param doi: A canonical DOI.
    :returns: The URL of the OA version of the given DOI, or ``None``.

    >>> get_oa_version('10.1209/0295-5075/111/40005')
    'http://arxiv.org/abs/1506.06690'
    """
    try:
        request = requests.get("%s%s" % (DISSEMIN_API, doi))
        request.raise_for_status()
        result = request.json()
        assert result["status"] == "ok"
        return result["paper"]["pdf_url"]
    except (AssertionError, ValueError, KeyError, RequestException):
        return None