import json


def save_files_tmp(data, file_format: str, file_name: str):
    """
    # SAVE FILES ON TEMPORARY

    Save files on `./tmp` to upload more easily into the storage.

    Parameters
    ----------
    data
        The information to be saved on the storage.
    file_format : str
        The type of format that will define the process for saving and/or encoding. Such as `parquet` or `json`.
    zone : str
        The zone that will be saved the data, such as `raw`, `trusted`, and `analytics`.
    """
    
    if file_format == 'parquet':
        args = {'coerce_timestamps':'ms','allow_truncated_timestamps':True}   
        file_path_tmp = f'./tmp/{file_name}.parquet'
        data.to_parquet(file_path_tmp, engine='pyarrow', index=False, **args)
    elif file_format == 'json':
        file_path_tmp = f'./tmp/{file_name}.json'
        with open(file_path_tmp, 'w') as file:
            json.dump(data, file)
    else:
        print("===> The format isn't json neither parquet to save.")
        return

    return file_path_tmp