/**
 * Generate a download link for an activation record.
 *
 * @internal
 *
 * @since 1.0
 *
 * @param Activation $activation
 *
 * @return string
 */
function generate_download_link(Activation $activation)
{
    $now = make_date_time();
    $interval = new \DateInterval('P1D');
    /**
     * Filter the expiration interval for a download link.
     *
     * @since 1.0
     *
     * @param \DateInterval $interval
     * @param Activation    $activation
     */
    $filtered = apply_filters('itelic_download_link_expiration_interval', $interval, $activation);
    if ($filtered instanceof \DateInterval) {
        $interval = $filtered;
    }
    $expires = $now->add($interval);
    $args = generate_download_query_args($activation, $expires);
    $download_ep = Dispatch::get_url('download');
    $link = add_query_arg($args, $download_ep);
    /**
     * Filters the download link for an activation.
     *
     * Download links are specific to activations, not products.
     * This allows for pausing releases, and pre-release tracks.
     *
     * If you are going to override the download link, you need
     * to be able dynamically serve the download based on the current
     * state of the releases, and the activation track.
     *
     * @since 1.0
     *
     * @param string     $link
     * @param Activation $activation
     */
    $link = apply_filters('itelic_generate_download_link', $link, $activation);
    return $link;
}