public function download($mediaId, $type, $filePath, $fileName)
    {
        $this->mediaId = $mediaId;
        $this->mediaType = $type;

        $this->getLogger()->info('Downloading media ID ' . $mediaId . ' and saving it in ' . $filePath . ' as ' . $fileName);
        $response = $this->doGet('/library/download/' . $this->mediaId . '/' . $this->mediaType);

        // Check if the directory exists, if not create it
        $this->getLogger()->debug('Checking if the directory exists');
        if (!file_exists($filePath)) {
            $this->getLogger()->debug('Creating directory to save files to ' . $filePath);
            mkdir($filePath, 0777, true);
        }
        // Save file to the directory with the provided name
        $file = fopen($filePath . $fileName, 'w');
        fwrite($file, $response);
        fclose($file);


        return true;
    }