| | |
| | | |
| | | 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; |
| | |
| | | */ |
| | | class ImporterRoutes extends Rest |
| | | { |
| | | use Instance; |
| | | /** |
| | | * Register REST routes |
| | | */ |
| | |
| | | // 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 |
| | |
| | | // 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 |