<?php











namespace Amazon\Affiliate;







/**



 * Backend handler Class Admin



 *



 * @package Amazon\Affiliate



 */



class Admin {







    /**



     * Admin  constructor.



     */



    public function __construct() {



        $setting            = new Admin\Setting();



        $Productsearch      = new Admin\Productsearch();



        $ImportProducts     = new Admin\ImportProducts();



        $dashboard          = new Admin\Dashboard();



        $license_activation = new Admin\LicenseActivation();



        $products_search_without_api = new Admin\ProductsSearchWithoutApi();



        $product_import_by_url = new Admin\ProductImportByUrl();







        new Admin\Menu( $setting, $Productsearch, $dashboard, $products_search_without_api, $product_import_by_url );







        $this->dispatch_actions( $setting, $Productsearch, $ImportProducts, $dashboard, $license_activation, $products_search_without_api, $product_import_by_url );



    }







    /**



     * From action handler



     *



     * @param $setting



     */



    public function dispatch_actions( $setting, $Productsearch, $ImportProducts, $dashboard, $license_activation, $products_search_without_api, $product_import_by_url ) {



        //From action handler.



        add_action( 'admin_post_ams_wc_amazon_general_setting', array( $setting, 'general_amazon_setting_handler' ) );



        add_action( 'admin_post_ams-wc-general-setting', array( $setting, 'general_setting' ) );



        add_action( 'admin_post_ams_product_cron', array( $setting, 'general_ams_product_cron' ) );



        add_action( 'admin_post_ams_wc_product_cat_setting', array( $setting, 'product_cat_country_setting' ) );

       



        //Ajax action handler



        add_action( 'wp_ajax_search_products', array( $Productsearch, 'search_products' ) );



        add_action( 'wp_ajax_ams_product_import', array( $ImportProducts, 'product_import' ) );



        add_action( 'wp_ajax_ams_dashboard_info', array( $dashboard, 'dashboard_info' ) );



        add_action( 'wp_ajax_ams_license_activation', array( $license_activation, 'license_activation' ) );



        add_action( 'wp_ajax_ams_license_deactivated', array( $license_activation, 'deactivated_license_plugin' ) );



        add_action( 'wp_ajax_ams_test_api', array( $setting, 'test_api' ) );



        add_action( 'wp_ajax_search_products_without_api', array( $products_search_without_api, 'get_product_list' ) );



        add_action( 'wp_ajax_product_import_without_api', array( $products_search_without_api, 'product_import_without_api' ) );



        add_action( 'wp_ajax_ams_product_import_by_url', array( $product_import_by_url, 'product_import_by_url' ) ); 



    }



}