import json
import requests


def metadata_post_request(file_name, metadata, auth_parameter, url):
    """
    Used to structure and make the post request for metadata to Zenodo.

    Parameters
    ----------
    file_name : str
        The name of the file to be created.
    metadata : dict
        The PresQT metadata file to be created.
    auth_parameter : dict
        The Zenodo authentication parameter.
    url : str
        The url to issue the post request.

    Returns
    -------
    The status code of the request.
    """
    # Prepare the request values
    data = {'name': file_name}
    metadata_bytes = json.dumps(metadata, indent=4).encode('utf-8')
    files = {'file': metadata_bytes}

    # Make the request
    response = requests.post(url, params=auth_parameter, data=data, files=files)

    return response.status_code