<?php
/**
 * Caterpoint Module Configuration Example
 *
 * Add this configuration to your Yii2 application configuration file:
 * 
 * For a Yii2 basic app: config/web.php or config/console.php
 * For a Yii2 advanced app: backend/config/main.php or console/config/main.php
 */

return [
    'modules' => [
        'caterpoint' => [
            'class' => 'PortalPeople\caterpoint\Module',
            
            // REQUIRED: Caterpoint API endpoint
            'apiEndpoint' => 'https://cp3-bayley-test.caterpoint.co.uk/api',
            
            // REQUIRED: Caterpoint API authentication token
            'apiToken' => env('CATERPOINT_API_TOKEN', 'your-token-here'),
            
            // OPTIONAL: Request timeout in seconds (default: 30)
            'requestTimeout' => 30,
            
            // OPTIONAL: Maximum orders to fetch per API request (default: 100)
            'pollLimit' => 100,
            
            // OPTIONAL: Prefix for generated local order numbers (default: 'CP-')
            'orderNumberPrefix' => 'CP-',
            
            // OPTIONAL: File path for persistent cursor storage
            // Allows resuming imports after application restart
            'orderImportCursorFile' => '@runtime/caterpoint/order-import.cursor',
            
            // OPTIONAL: Status mapping from Caterpoint to your local system
            'statusMap' => [
                'pending' => 'Pending',
                'processing' => 'Processing',
                'confirmed' => 'Confirmed',
                'dispatched' => 'Dispatched',
                'delivered' => 'Delivered',
                'cancelled' => 'Cancelled',
            ],
            
            // OPTIONAL: Enable debug logging
            'debug' => env('YII_DEBUG', false),
        ],
    ],
];


/**
 * USAGE EXAMPLES
 * ==============
 * 
 * 1. Programmatic Import:
 *    
 *    $module = Yii::$app->getModule('caterpoint');
 *    $service = $module->createOrderImportService();
 *    
 *    $result = $service->run();
 *    echo "Imported: {$result['created']} new orders\n";
 *    echo "Updated: {$result['updated']} existing orders\n";
 * 
 * 
 * 2. Console Command (CLI):
 *    
 *    // Import orders
 *    php yii caterpoint/order-import
 *    
 *    // Preview import without persisting (dry run)
 *    php yii caterpoint/order-import --dry-run
 *    
 *    // Import max 50 orders
 *    php yii caterpoint/order-import --limit=50
 *    
 *    // Reset cursor and start from beginning
 *    php yii caterpoint/order-import --reset
 * 
 * 
 * 3. REST API Endpoints:
 *    
 *    // Trigger import via HTTP POST
 *    POST /api/caterpoint/orders/import
 *    Body: { "dryRun": false, "limit": 50 }
 *    
 *    // Get current import status
 *    GET /api/caterpoint/orders/status
 *    
 *    // Reset import cursor
 *    POST /api/caterpoint/orders/reset
 *    
 *    // Fetch raw orders from Caterpoint API
 *    GET /api/caterpoint/orders/fetch-raw?limit=100
 *    
 *    // Mark order as exported
 *    POST /api/caterpoint/orders/mark-exported?id=ORDER_ID
 */
