def build_request_body(type, id, attributes=None, relationships=None):
    """Build a request body  object.

    A body JSON object is used for any of the ``update`` or ``create``
    methods on :class:`Resource` subclasses. In normal library use you
    should not have to use this function directly.

    Args:

        type(string): The resource type for the attribute
        id(uuid): The id of the object to update. This may be ``None``

    Keyword Args:

        attributes(dict): A JSON dictionary of the attributes to set
        relationships(dict) A JSON dictionary of relationships to set

    Returns:

        A valid attribute dictionary. Often used in the ``update`` or
            ``create`` :class:`Resource`` methods.

    """
    result = {
        "data": {
            "type": type
        }
    }
    data = result['data']
    if attributes is not None:
        data['attributes'] = attributes
    if relationships is not None:
        data['relationships'] = relationships
    if id is not None:
        data['id'] = id
    return result