<?php

use App\Http\Controllers\Api\OrdersController;
use App\Http\Controllers\Api\ProductsController;
use App\Http\Controllers\Api\DashboardController;
use App\Http\Controllers\Api\SyncController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group([
    'middleware' => ['auth.shopify'],
], function ($router) {
    // SAP related endpoints
    Route::post('/sap-prices-sync', [SyncController::class, 'pricesSync']);
    Route::post('/sap-sync', [SyncController::class, 'completeSync']);
    Route::post('/sap-check-product-data', [SyncController::class, 'sapCheckProductData']);
    Route::post('/sap-orders-status-check', [SyncController::class, 'sapOrdersStatusCheck']);

    //Shopify related endpoints
    Route::post('/shopify-products-sync', [SyncController::class, 'shopifyProductsSync']);
    Route::post('/shopify-prices-sync', [SyncController::class, 'shopifyPricesSync']);
    Route::post('/shopify-product-sync', [SyncController::class, 'shopifyProductSync']);
    Route::post('/shopify-collections-sync', [SyncController::class, 'shopifyCollectionsSync']);
    Route::post('/shopify-order-update', [SyncController::class, 'shopifyUpdateOrder']);
    Route::post('/shopify-sync-order', [SyncController::class, 'shopifyOrderSync']);
    Route::post('/shopify-replace-images', [SyncController::class, 'shopifyReplaceImages']);

    Route::post('/copy-product-contents', [SyncController::class, 'copyProductContents']);

    // Integration Dashboard API
    Route::get('/dashboard/orders', [OrdersController::class, 'listOrders']);

    Route::get('/dashboard/worker/status', [DashboardController::class, 'getWorkerStatus']);
    Route::get('/dashboard/orders/status', [OrdersController::class, 'getStatus']);
    Route::post('/dashboard/orders/action/{action}', [OrdersController::class, 'doAction']);
    Route::get('/dashboard/cron-tasks', [DashboardController::class, 'getCronTasks']);
    Route::post('/dashboard/cron-tasks', [DashboardController::class, 'setCronTasks']);
    Route::get('/dashboard/products', [ProductsController::class, 'listProducts']);
    Route::post('/dashboard/products/action/{action}', [ProductsController::class, 'doAction']);
    Route::post('/dashboard/products/info', [ProductsController::class, 'getProductSapInfo']);
    Route::post('/dashboard/products/sap-sync', [ProductsController::class, 'syncSapProduct']);
    Route::get('/dashboard/categories', [ProductsController::class, 'getCategories']);

});
