Jake Vanderwerf
2026-08-28 a9654f00c8fbc9934289d761843ddd071025013f
inc/rest/routes/ReferralRoutes.php
@@ -134,7 +134,7 @@
         'treated' => $this->actionUpdateStatus($request, 'treated'),
         'remove' => $this->actionRemove($request),
         'resend' => $this->actionResend($request),
         default => $this->error('Invalid action', 'invalid_action', 400)
         default => $this->error('Invalid action', 'invalid_action')
      };
   }
@@ -164,7 +164,7 @@
      }
      if (empty($sanitized_invitations)) {
         return $this->error('No valid invitations provided', 'no_invitations', 400);
         return $this->error('No valid invitations provided', 'no_invitations',);
      }
      $operationID = sanitize_text_field($request->get_param('id'));
@@ -193,7 +193,7 @@
      $referral_id = $request->get_param('referral_id');
      if (!$referral_id) {
         return $this->error('referral_id required', 'missing_id', 400);
         return $this->error('referral_id required', 'missing_id');
      }
      [$success, $message] = Referrals::getInstance()->updateStatus($referral_id, $status);
@@ -215,7 +215,7 @@
   {
      $referral_id = $request->get_param('referral_id');
      if (!$referral_id) {
         return $this->error('referral_id required', 'missing_id', 400);
         return $this->error('referral_id required', 'missing_id');
      }
      $result = Referrals::getInstance()->removeReferral($referral_id, get_current_user_id());
@@ -234,7 +234,7 @@
   {
      $referral_id = $request->get_param('referral_id');
      if (!$referral_id) {
         return $this->error('referral_id required', 'missing_id', 400);
         return $this->error('referral_id required', 'missing_id');
      }
      $result = Referrals::getInstance()->resendInvitation($referral_id, get_current_user_id());
@@ -261,7 +261,7 @@
      $code = Referrals::getInstance()->getUserReferralCode($user_id);
      if (is_wp_error($code)) {
         return $this->error($code->get_error_message(), 'code_error', 400);
         return $this->error($code->get_error_message(), 'code_error');
      }
      return $this->success([
@@ -279,7 +279,7 @@
      $code = strtoupper(sanitize_text_field($request->get_param('code')??''));
      if (empty($code)) {
         return $this->error('Code required', 'missing_code', 400);
         return $this->error('Code required', 'missing_code');
      }
      $referrer = Referrals::getInstance()->getUserByReferralCode($code);
@@ -384,13 +384,13 @@
   public function handleClientUpload(WP_REST_Request $request): WP_REST_Response
   {
      if (empty($_FILES['file'])) {
         return $this->error('No file uploaded', 'no_file', 400);
         return $this->error('No file uploaded', 'no_file');
      }
      $file = $_FILES['file'];
      if ($file['error'] !== UPLOAD_ERR_OK) {
         return $this->error('File upload error: ' . $file['error'], 'upload_error', 400);
         return $this->error('File upload error: ' . $file['error'], 'upload_error');
      }
      // Validate file type
@@ -400,12 +400,12 @@
      finfo_close($finfo);
      if (!in_array($mime_type, $allowed_types) && !in_array($file['type'], $allowed_types)) {
         return $this->error('File must be a CSV', 'invalid_file_type', 400);
         return $this->error('File must be a CSV', 'invalid_file_type');
      }
      // Validate file size (10MB max)
      if ($file['size'] > 10 * 1024 * 1024) {
         return $this->error('File size exceeds 10MB limit', 'file_too_large', 400);
         return $this->error('File size exceeds 10MB limit', 'file_too_large');
      }
      // Import using JaneAppClientImporter
@@ -445,13 +445,13 @@
   public function handleSalesUpload(WP_REST_Request $request): WP_REST_Response
   {
      if (empty($_FILES['file'])) {
         return $this->error('No file uploaded', 'no_file', 400);
         return $this->error('No file uploaded', 'no_file');
      }
      $file = $_FILES['file'];
      if ($file['error'] !== UPLOAD_ERR_OK) {
         return $this->error('File upload error: ' . $file['error'], 'upload_error', 400);
         return $this->error('File upload error: ' . $file['error'], 'upload_error');
      }
      // Validate file type
@@ -461,12 +461,12 @@
      finfo_close($finfo);
      if (!in_array($mime_type, $allowed_types) && !in_array($file['type'], $allowed_types)) {
         return $this->error('File must be a CSV', 'invalid_file_type', 400);
         return $this->error('File must be a CSV', 'invalid_file_type');
      }
      // Validate file size (10MB max)
      if ($file['size'] > 10 * 1024 * 1024) {
         return $this->error('File size exceeds 10MB limit', 'file_too_large', 400);
         return $this->error('File size exceeds 10MB limit', 'file_too_large');
      }
      // Import using JaneAppSalesImporter