<?php

/**
 * LinkFiliate Routes
 *
 * Defines and registers custom API routes for the LinkFiliate using the Haruncpi\WpApi library.
 *
 * @package LinkFiliate\Routes
 */

namespace LinkFiliate\Routes;

if (! defined('ABSPATH')) {
	exit;
}

use LinkFiliate\Libs\API\Route;


Route::prefix(
	LINKFILIATE_ROUTE_PREFIX,
	function (Route $route) {


		//Campaigns
		$route->get('/campaigns', [\LinkFiliate\App\Controllers\Campaign::class, 'get_all'], 'admin');
		$route->get('/campaign/get/{id}', [\LinkFiliate\App\Controllers\Campaign::class, 'get_by'], 'admin');
		$route->post('/campaign/create', [\LinkFiliate\App\Controllers\Campaign::class, 'create'], 'admin');
		$route->put('/campaign/update/{id}', [\LinkFiliate\App\Controllers\Campaign::class, 'update_by'], 'admin');
		$route->delete('/campaign/delete/{id}', [\LinkFiliate\App\Controllers\Campaign::class, 'delete_by'], 'admin');

		$route->get('/campaign/check-slug', [\LinkFiliate\App\Controllers\Campaign::class, 'check_slug'], 'admin');
		$route->get('/search-link', [\LinkFiliate\App\Controllers\Campaign::class, 'search_link'], 'admin');
		//Category
		$route->get('/category', [\LinkFiliate\App\Controllers\Category::class, 'get_all'], 'admin');
		$route->get('/category/get/{id}', [\LinkFiliate\App\Controllers\Category::class, 'get_by'], 'admin');
		$route->post('/category/create', [\LinkFiliate\App\Controllers\Category::class, 'create'], 'admin');
		$route->put('/category/update/{id}', [\LinkFiliate\App\Controllers\Category::class, 'update_by'], 'admin');
		$route->delete('/category/delete/{id}', [\LinkFiliate\App\Controllers\Category::class, 'delete_by'], 'admin');
		// Settings
		$route->get('/settings/general', [\LinkFiliate\App\Controllers\Settings::class, 'get_general'], 'admin');
		$route->put('/settings/general/update/', [\LinkFiliate\App\Controllers\Settings::class, 'general_update'], 'admin');

		$route->post('/clicklog', [\LinkFiliate\App\Controllers\Clicklog::class, 'get_all'], 'admin');

		// Overview
		$route->get('/overview/chart', [\LinkFiliate\App\Controllers\Overview::class, 'get_chart'], 'admin');
		$route->get('/overview/campaigns', [\LinkFiliate\App\Controllers\Overview::class, 'get_campaigns'], 'admin');
		$route->post('/reset-clicks', [\LinkFiliate\App\Controllers\Settings::class, 'reset_clicks'], 'admin');

		$route->get('/migrate/scan/{source}', [\LinkFiliate\App\Controllers\Migrate::class, 'scan'], 'admin');
		$route->post('/migrate/import/{source}', [\LinkFiliate\App\Controllers\Migrate::class, 'import'], 'admin');
		$route->post('/import-csv', [\LinkFiliate\App\Controllers\Import::class, 'csv'], 'admin');
	}
);
