public static function getInstance() { if (!self::$_instance instanceof self) { self::$_instance = new self(MODULE_EM_API_TOKEN, MODULE_EM_SHOP_TOKEN, EasymarketingHelper::getWebsiteURL()); } return self::$_instance; }
function setAPIEndpoints() { $website_url = EasymarketingHelper::getWebsiteURL(); $website_api_url = EasymarketingHelper::getWebsiteURL(true); if (MODULE_EM_ROOT_CATEGORY > 0) { $test_pid = xtc_db_fetch_array(xtc_db_query("SELECT ptc.products_id FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc LEFT JOIN " . TABLE_PRODUCTS . " p ON p.products_id = ptc.products_id WHERE ptc.categories_id = '" . (int) MODULE_EM_ROOT_CATEGORY . "' AND p.products_status = 1 ORDER BY ptc.products_id LIMIT 1")); } else { $test_pid = xtc_db_fetch_array(xtc_db_query("SELECT products_id FROM " . TABLE_PRODUCTS . " WHERE products_status = 1 ORDER BY products_id LIMIT 1")); } $params = array('website_url' => $website_url, 'access_token' => MODULE_EM_API_TOKEN, 'shop_token' => MODULE_EM_SHOP_TOKEN, 'categories_api_endpoint' => $website_api_url . 'api/easymarketing/categories.php', 'shop_category_root_id' => MODULE_EM_ROOT_CATEGORY, 'products_api_endpoint' => $website_api_url . 'api/easymarketing/products.php', 'product_by_id_api_endpoint' => $website_api_url . 'api/easymarketing/products.php', 'best_products_api_endpoint' => $website_api_url . 'api/easymarketing/bestseller.php', 'new_products_api_endpoint' => $website_api_url . 'api/easymarketing/products.php', 'shopsystem_info_api_endpoint' => $website_api_url . 'api/easymarketing/shopsystem_info.php', 'api_setup_test_single_product_id' => $test_pid['products_id']); $response = APIClient::getInstance()->performRequest('configure_endpoints', $params, 'POST'); if ($response['status'] == 200) { xtc_db_query("UPDATE " . TABLE_CONFIGURATION . " SET configuration_value = '1' WHERE configuration_key = 'MODULE_EM_CONFIGURE_ENDPOINTS_STATUS'"); } }