def addText(text, endIndex, namedStyleType, requests):
    """Adds requests to add text at endIndex with the desired nameStyleType.
    Returns new endIndex.

    Args:
        text (String): text to add
        endIndex (int): Current endIndex of document. Location to add text to
        namedStyleType (String): desired namedStyleType of text
        requests (list): list of requests to append requests to

    Returns:
        int: new endIndex after adding text
    """
    # Finds new end index by incrementing endIndex by the length of the text
    # plus 1 for the automatically appended '\n'
    newEndIndex = endIndex + len(text) + 1
    # Appends requests to add text, and then request to change namedStyleType
    # as desired
    requests.extend([
        # Add text, including a '\n' at the previous line to create a new paragraph
        # Note that a '\n' will automatically be appended to the end of the text
        {
            'insertText': {
                'location': {
                    'index': endIndex - 1
                },
                'text': '\n' + text
            }
        },
        {
            'updateParagraphStyle': {
                'range': {
                    'startIndex': endIndex,
                    'endIndex': newEndIndex
                },
                'paragraphStyle': {
                    'namedStyleType': namedStyleType
                },
                'fields': 'namedStyleType'
            }
        }
    ])
    return newEndIndex