<?php

namespace Blazemedia\Affiliation\Rendering;

trait DirectLinkParams
{
    
    /**
     * Ricava i parametri per i link inseriti direttamente in pagina
     *
     * @param string $marketPlace
     * @param string $link
     * @return array
     */
    function getDirectLinkParams( $marketPlace, $link ) {

        $attributes = new DirectLinkAttributes( $marketPlace );

        return [

            'format'     => $this->format,
            'format_id'  => 0,
            'link_id'    => 0,
            'extra'      => urlencode( json_encode( [
                'id'             => 0,
                'title'          => $attributes->label,
                'link'           => urlencode( $link ),
                'subject'        => $attributes->label,
                'subject_code'   => $attributes->code,
                'program'        => $attributes->label,
                'program_suffix' => $attributes->suffix,
                'theme'          => $attributes->label,
                'theme_code'     => $attributes->code,
                'platform'       => $attributes->label,
                "platform_code"  => $attributes->code,
                'tracking_policy' => 'variable',
                'tracking_id' =>  ''
            ] ) )
        ];
    }
}
