<?php

namespace Blazemedia\Affiliation\Rendering\DirectLink;

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

        $link = str_replace( '&amp;', '&', $link );

        $attributes = AttributesFactory::get( $platform, $link );

        return [

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