<?php

namespace Blazemedia\DriveKIntegrator\AdminUserInterface\Buttons;

use Blazemedia\DriveKIntegrator\API\CachedApi;

/* 
 *  Bottone e UI per la creazione degli shortcode dei modelli Drivek
 */
class DriveKModelButton extends Button {

    function __construct() { 
        
        /** 
         * Set the name of the plugin 
         * >> drivek_model_button.js
         * 
         * and the name of the ajax endpoint to call into plugin
         * >> drivek_model_button_action
         */
        parent::__construct( 'drivek_model_button', 'drivek_model_button_action' , 'dialog-DriveKModelButton.html');       
    }


    public function addFieldsToDialog() : array { 

        
        //$brands = json_decode( CachedApi::getInstance()->get(DRIVEK_MODELS_API.'brands/'), true );
        //$models = json_decode( CachedApi::getInstance()->get(DRIVEK_MODELS_API.'models/'), true );

        $brands = [ 'audi', 'bmw', 'mercedes', 'volvo' ];
        
        return [
            [
                'name'=> 'brands',
                'value' => json_encode($brands)
            ],        
            [
                'name'  => 'home_url',
                'value' => get_home_url()
            ],
        ];
    }

    
}