Jake Vanderwerf
2026-08-28 5b50afdcafd150186ea5c7b0e1cad98065590b35
inc/rest/routes/ImporterRoutes.php
@@ -4,11 +4,11 @@
use JVBase\importers\JaneAppClientImporter;
use JVBase\importers\JaneAppSalesImporter;
use JVBase\Instance;
use JVBase\rest\Rest;
use JVBase\rest\Route;
use WP_REST_Request;
use WP_REST_Response;
use WP_Error;
if (!defined('ABSPATH')) {
   exit;
@@ -21,6 +21,7 @@
 */
class ImporterRoutes extends Rest
{
   use Instance;
   /**
    * Register REST routes
    */
@@ -33,7 +34,8 @@
            'options' => 'string', // JSON string of options
         ])
         ->auth('admin')
         ->rateLimit(3, 300); // 3 imports per 5 minutes
         ->rateLimit(3, 300)
         ->register(); // 3 imports per 5 minutes
      // Sales import endpoint
      Route::for('jane/import-sales')
@@ -42,14 +44,16 @@
            'options' => 'string', // JSON string of options
         ])
         ->auth('admin')
         ->rateLimit(3, 300); // 3 imports per 5 minutes
         ->rateLimit(3, 300)
         ->register(); // 3 imports per 5 minutes
      // Get import status
      Route::for(Route::pattern('jane/import-status/{id}'))
         ->get([$this, 'getImportStatus'])
         ->arg('id', 'string|required')
         ->auth('admin')
         ->rateLimit(30, 60);
         ->rateLimit(30)
         ->register();
   }
   /**
@@ -71,14 +75,14 @@
      // Get uploaded file
      $files = $request->get_file_params();
      if (empty($files['file'])) {
         return $this->error('No file uploaded', 'no_file', 400);
         return $this->error('No file uploaded', 'no_file');
      }
      $file = $files['file'];
      // Validate file type
      if (!$this->isValidCSV($file)) {
         return $this->error('Invalid file type. Please upload a CSV file.', 'invalid_file', 400);
         return $this->error('Invalid file type. Please upload a CSV file.', 'invalid_file');
      }
      // Get and parse options
@@ -135,14 +139,14 @@
      // Get uploaded file
      $files = $request->get_file_params();
      if (empty($files['file'])) {
         return $this->error('No file uploaded', 'no_file', 400);
         return $this->error('No file uploaded', 'no_file');
      }
      $file = $files['file'];
      // Validate file type
      if (!$this->isValidCSV($file)) {
         return $this->error('Invalid file type. Please upload a CSV file.', 'invalid_file', 400);
         return $this->error('Invalid file type. Please upload a CSV file.', 'invalid_file');
      }
      // Get and parse options