Merge branch 'dillon/44-customer-satisfaction-feedback-project-b' into 'master'

Preparation for help menu

See merge request CIEFWorldwideSdnBhd/shipping-portal!175
This commit is contained in:
Dillon Ngo
2023-10-15 17:16:57 +00:00
33 changed files with 283 additions and 61 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Classes\Exceptions;
use App\Classes\ValueObjects\Constants\HttpStatus;
use Illuminate\Support\Facades\Log;
final class ConnectionErrorException extends ServiceApiException {
public function __construct(?string $message = null, ?string $exceptionMessage = null, ?string $payload = null, ?string $exceptionTrace = null) {
Log::error($message. ": ". $exceptionMessage);
if($payload){
Log::error('Payload: '.$payload);
}
if($exceptionTrace){
Log::error($exceptionTrace);
}
parent::__construct($message ?? 'A connection error has occurred. Please check application logs for more information.',
HttpStatus::SERVER_ERROR);
}
}
@@ -75,7 +75,8 @@ class UpdateNextQuestionQALogic extends AbstractControllerLogic
/** /**
* @param Request $request * @param Request $request
* @return JsonResponse * @return JsonResponse
* @throws ErrorException * @throws MalformedRequestException
* @throws ResourceNotFoundException
*/ */
public function logic(Request $request) : JsonResponse public function logic(Request $request) : JsonResponse
{ {
@@ -25,6 +25,14 @@ class DeleteAnswerQAProcessor
$this->listsHelpMenuUserAnswerSelected = $listsHelpMenuUserAnswerSelected; $this->listsHelpMenuUserAnswerSelected = $listsHelpMenuUserAnswerSelected;
} }
/**
* @param int $userId
* @param int $questionId
* @param Request $request
* @return void
* @throws ResourceNotFoundException
*/
public function execute($userId, $questionId, $request){ public function execute($userId, $questionId, $request){
if ($request->has('isPrevious')) { if ($request->has('isPrevious')) {
//Get current and previous question's answer //Get current and previous question's answer
@@ -23,7 +23,7 @@ class FetchFirstQuestionQAProcessor
public function execute(Request $request){ public function execute(Request $request){
try { try {
$query = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1]); $query = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => $request->route('set_id')]);
return $query; return $query;
} catch (\Exception $exception){ } catch (\Exception $exception){
throw new ErrorException($exception->getMessage(), $exception->getCode()); throw new ErrorException($exception->getMessage(), $exception->getCode());
@@ -38,6 +38,7 @@ class FetchNextQuestionQAProcessor
$nextQuestionNumber = 0; $nextQuestionNumber = 0;
$nextNestedQuestion = 0; $nextNestedQuestion = 0;
$nextMainQuestion= 0; $nextMainQuestion= 0;
$questionnaireSetId = 0;
$currentQuestion = $request->question; $currentQuestion = $request->question;
$questionType = QAType::DEFAULT; $questionType = QAType::DEFAULT;
$returnQuestion = null; $returnQuestion = null;
@@ -48,7 +49,9 @@ class FetchNextQuestionQAProcessor
$questionType = $currentQuestion['question_type']; $questionType = $currentQuestion['question_type'];
$nextNestedQuestion = $currentQuestion['next_nested_question']; $nextNestedQuestion = $currentQuestion['next_nested_question'];
$nextMainQuestion = $currentQuestion['next_main_question']; $nextMainQuestion = $currentQuestion['next_main_question'];
$questionnaireSetId = $currentQuestion['questionnaire_set_id'];
} }
if ($request->has('answerObj')) { if ($request->has('answerObj')) {
$nextQuestionNumber = $request->answerObj['next_question_number']; $nextQuestionNumber = $request->answerObj['next_question_number'];
} }
@@ -58,7 +61,7 @@ class FetchNextQuestionQAProcessor
$previousAnswer = $this->listsHelpMenuUserAnswerSelected->execute(['user_id' => $userId, 'order_by' => (object)['column' => 'id','DESC' => true]])[0]; $previousAnswer = $this->listsHelpMenuUserAnswerSelected->execute(['user_id' => $userId, 'order_by' => (object)['column' => 'id','DESC' => true]])[0];
//Get previous question //Get previous question
$previousQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1, 'id' => $previousAnswer['question_id']]); $previousQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => $questionnaireSetId, 'id' => $previousAnswer['question_id']]);
$returnQuestion = $previousQuestion; $returnQuestion = $previousQuestion;
} }
else{ else{
@@ -79,11 +82,11 @@ class FetchNextQuestionQAProcessor
$returnQuestion = null; $returnQuestion = null;
} }
else if($question_number != 0){ else if($question_number != 0){
$nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1, 'question_number' => $question_number]); $nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => $questionnaireSetId, 'question_number' => $question_number]);
$returnQuestion = $nextQuestion; $returnQuestion = $nextQuestion;
} }
else if (array_key_exists('id', $request->input('question'))) { else if (array_key_exists('id', $request->input('question'))) {
$nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1, 'id_next' => $questionId, 'next_main_question' => null]); $nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => $questionnaireSetId, 'id_next' => $questionId, 'next_main_question' => null]);
$returnQuestion = $nextQuestion; $returnQuestion = $nextQuestion;
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class ConvertsPerfexCRMLeadToCustomer class ConvertsPerfexCRMLeadToCustomer
@@ -27,8 +28,13 @@ class ConvertsPerfexCRMLeadToCustomer
Log::error('ConvertsPerfexCRMLeadToCustomer: '.$response); Log::error('ConvertsPerfexCRMLeadToCustomer: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), $email, $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class CreatesPerfexCRMCustomer class CreatesPerfexCRMCustomer
@@ -30,8 +31,13 @@ class CreatesPerfexCRMCustomer
Log::error('CreatesPerfexCRMCustomer: '.$response); Log::error('CreatesPerfexCRMCustomer: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), $companyName, $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -5,6 +5,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject; use App\Classes\Modules\PerfexCRM\DataTransferObjects\CustomerContactObject;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class CreatesPerfexCRMCustomerContact class CreatesPerfexCRMCustomerContact
@@ -37,8 +38,13 @@ class CreatesPerfexCRMCustomerContact
Log::error('CreatesPerfexCRMCustomerContact: '.$response); Log::error('CreatesPerfexCRMCustomerContact: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class CreatesPerfexCRMCustomerProject class CreatesPerfexCRMCustomerProject
@@ -36,8 +37,13 @@ class CreatesPerfexCRMCustomerProject
Log::error('CreatesPerfexCRMCustomerProject: '.$response); Log::error('CreatesPerfexCRMCustomerProject: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePerfexCRMObject; use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePerfexCRMObject;
@@ -56,8 +57,13 @@ class CreatesPerfexCRMInvoice
Log::error('CreatesPerfexCRMInvoice: '.$response); Log::error('CreatesPerfexCRMInvoice: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject; use App\Classes\Modules\PerfexCRM\DataTransferObjects\InvoicePaymentPerfexCRMObject;
@@ -36,8 +37,13 @@ class CreatesPerfexCRMInvoicePayment
Log::error('CreatesPerfexCRMInvoicePayment: '.$response); Log::error('CreatesPerfexCRMInvoicePayment: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject; use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateLeadPerfexCRMObject;
@@ -43,8 +44,13 @@ class CreatesPerfexCRMLead
Log::error('CreatesPerfexCRMLead: '.$response); Log::error('CreatesPerfexCRMLead: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server ' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class CreatesPerfexCRMMilestone class CreatesPerfexCRMMilestone
@@ -39,8 +40,13 @@ class CreatesPerfexCRMMilestone
Log::error('CreatesPerfexCRMMilestone: '.$response); Log::error('CreatesPerfexCRMMilestone: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class CreatesPerfexCRMSupportTicket class CreatesPerfexCRMSupportTicket
@@ -36,9 +37,15 @@ class CreatesPerfexCRMSupportTicket
Log::error($response); Log::error($response);
return null; return null;
} }
}catch(\Exception $exception){ }
$error = 'Support Ticket creation failed: ' . $exception->getMessage(); catch(\Illuminate\Http\Client\ConnectionException $exception){
Log::error($error.'\nPayload to create ticket: '.json_encode($data)); $error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
$error = 'Support Ticket creation failed';
Log::error($error. ": ". $exception->getMessage());
Log::error('Payload: '.json_encode($data));
throw new MalformedRequestException($error); throw new MalformedRequestException($error);
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields; use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject; use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
@@ -60,8 +61,13 @@ class CreatesPerfexCRMTask
Log::error('CreatesPerfexCRMTask: '.$response); Log::error('CreatesPerfexCRMTask: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class FetchesPerfexCRMCustomer class FetchesPerfexCRMCustomer
@@ -27,8 +28,15 @@ class FetchesPerfexCRMCustomer
Log::error('FetchesPerfexCRMCustomer: '.$response); Log::error('FetchesPerfexCRMCustomer: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), $email, $exception->getTraceAsString());
}
catch(\Exception $exception){
$error = 'Unable to get correct response from Perfex CRM server: ' . $exception->getMessage();
Log::error($error);
throw new MalformedRequestException($error);
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class FetchesPerfexCRMInvoice class FetchesPerfexCRMInvoice
@@ -29,7 +30,12 @@ class FetchesPerfexCRMInvoice
Log::error('FetchesPerfexCRMInvoice: '.$response); Log::error('FetchesPerfexCRMInvoice: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage()); throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class FetchesPerfexCRMLead class FetchesPerfexCRMLead
@@ -27,7 +28,12 @@ class FetchesPerfexCRMLead
Log::error('FetchesPerfexCRMLead: '.$response); Log::error('FetchesPerfexCRMLead: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), $email, $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage()); throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class FetchesPerfexCRMMilestone class FetchesPerfexCRMMilestone
@@ -33,8 +34,13 @@ class FetchesPerfexCRMMilestone
Log::error('FetchesPerfexCRMMilestone: '.$response); Log::error('FetchesPerfexCRMMilestone: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class FetchesPerfexCRMProject class FetchesPerfexCRMProject
@@ -33,8 +34,13 @@ class FetchesPerfexCRMProject
Log::error('FetchesPerfexCRMProject: '.$response); Log::error('FetchesPerfexCRMProject: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\General\Helper; use App\Classes\General\Helper;
@@ -47,8 +48,13 @@ class FetchesPerfexCRMTask
Helper::debugLogger($response); Helper::debugLogger($response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields; use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
use App\Classes\General\Helper; use App\Classes\General\Helper;
@@ -41,8 +42,13 @@ class UpdatesPerfexCRMCustomer
// Helper::debugLogger($response); // Helper::debugLogger($response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class UpdatesPerfexCRMInvoice class UpdatesPerfexCRMInvoice
@@ -63,7 +64,12 @@ class UpdatesPerfexCRMInvoice
Log::error('UpdatesPerfexCRMInvoice: '.$response); Log::error('UpdatesPerfexCRMInvoice: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage()); throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields; use App\Classes\ValueObjects\Constants\PerfexCRMCustomFields;
@@ -44,7 +45,12 @@ class UpdatesPerfexCRMLead
Log::error('UpdatesPerfexCRMLead: '.$response); Log::error('UpdatesPerfexCRMLead: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage()); throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class UpdatesPerfexCRMProject class UpdatesPerfexCRMProject
@@ -36,7 +37,12 @@ class UpdatesPerfexCRMProject
Log::error('UpdatesPerfexCRMProject: '.$response); Log::error('UpdatesPerfexCRMProject: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage()); throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
@@ -4,6 +4,7 @@ namespace App\Classes\Modules\PerfexCRM\Services;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Classes\Exceptions\MalformedRequestException; use App\Classes\Exceptions\MalformedRequestException;
use App\Classes\Exceptions\ConnectionErrorException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class UpdatesPerfexCRMTask class UpdatesPerfexCRMTask
@@ -41,8 +42,13 @@ class UpdatesPerfexCRMTask
Log::error('UpdatesPerfexCRMTask: '.$response); Log::error('UpdatesPerfexCRMTask: '.$response);
return null; return null;
} }
}catch(\Exception $exception){ }
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server' . $exception->getMessage()); catch(\Illuminate\Http\Client\ConnectionException $exception){
$error = 'Failed to connect to CRM';
throw new ConnectionErrorException($error, $exception->getMessage(), "", $exception->getTraceAsString());
}
catch(\Exception $exception){
throw new MalformedRequestException('Unable to get correct response from Perfex CRM server: ' . $exception->getMessage());
} }
} }
} }
@@ -0,0 +1,68 @@
<template>
<div class="parentContainer">
<div class="floating-button">
<button class="requestModal round-button" data-type="helpMenu">
<i class="fa fa-info"></i>
<span class="beta-label">Beta</span>
</button>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="helpMenu">
<help-menu-form-component></help-menu-form-component>
</modal-component>
</div>
</div>
</template>
<script>
export default {
};
</script>
<style scoped>
.floating-button {
position: fixed;
z-index: 9999;
bottom: 95px;
right: 24px;
}
.round-button {
width: 60px;
height: 60px;
background-color: #007bff;
color: white;
border: none;
border-radius: 50%;
font-size: 24px;
cursor: pointer;
outline: none;
}
.round-button:hover {
background-color: #0056b3;
}
.beta-label {
position: absolute;
top: 44px;
left: 88%;
transform: translateX(-50%);
background-color: #ffee00;
color: black;
padding: 0px 4px;
border-radius: 5px;
font-size: 11px;
}
@media (max-height: 600px) {
.floating-button {
bottom: 85px;
right: 14px;
}
.round-button {
width: 54px;
height: 54px;
}
}
</style>
@@ -77,16 +77,6 @@
<script> <script>
import { required } from "vuelidate/lib/validators"; import { required } from "vuelidate/lib/validators";
export default { export default {
props: {
data:{
type: Object,
required: true
},
module_type: {
type: String,
required: true
}
},
data(){ data(){
return { return {
section: 'helpMenuForm', section: 'helpMenuForm',
@@ -132,7 +122,7 @@
}, },
methods: { methods: {
fetchFirstQuestion(){ fetchFirstQuestion(){
this.submit(route('api.helpmenu.first.question'), 'get', this.section, false, false); this.submit(route('api.helpmenu.first.question', 4), 'get', this.section, false, false);
}, },
successHandler(response){ successHandler(response){
this.$store.dispatch('completeList', {'name': this.section, 'data': []}); this.$store.dispatch('completeList', {'name': this.section, 'data': []});
@@ -144,7 +134,8 @@
} }
}, },
errorHandler(error){ errorHandler(error){
this.error = error.message; // this.error = error.message;
this.error = 'We are sorry, something went wrong. Please contact us via live chat.';
}, },
submitForm(direction) { submitForm(direction) {
this.parameters = {} this.parameters = {}
@@ -173,7 +164,7 @@
else{ else{
if(this.question.is_end){ if(this.question.is_end){
if(this.question.question_type === 5){ if(this.question.question_type === 5){
this.submit(this.route('api.helpmenu.next.question'), 'post', this.section, true, true); this.submit(this.route('api.helpmenu.next.question'), 'post', this.section, false, false);
this.closeModal(); this.closeModal();
this.reset(); this.reset();
} }
@@ -192,7 +183,7 @@
} }
} }
else{ else{
this.submit(this.route('api.helpmenu.next.question'), 'post', this.section, true, true); this.submit(this.route('api.helpmenu.next.question'), 'post', this.section, false, false);
} }
} }
} }
@@ -200,7 +191,7 @@
this.formTouched = false; this.formTouched = false;
this.parameters.question = this.question; this.parameters.question = this.question;
this.parameters.isPrevious = true; this.parameters.isPrevious = true;
this.submit(this.route('api.helpmenu.next.question'), 'post', this.section, true, true); this.submit(this.route('api.helpmenu.next.question'), 'post', this.section, false, false);
} }
}, },
reset() { reset() {
@@ -30,7 +30,7 @@
<change-order-number-form-component :section="section" :data="order"></change-order-number-form-component> <change-order-number-form-component :section="section" :data="order"></change-order-number-form-component>
</modal-component> </modal-component>
<!-- <modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="helpMenu"> <!-- <modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="helpMenu">
<help-menu-form-component module_type="Order" :data="order"></help-menu-form-component> <help-menu-form-component></help-menu-form-component>
</modal-component> --> </modal-component> -->
</div> </div>
</div> </div>
@@ -30,7 +30,7 @@
<change-order-number-form-component :section="section" :data="order"></change-order-number-form-component> <change-order-number-form-component :section="section" :data="order"></change-order-number-form-component>
</modal-component> </modal-component>
<!-- <modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="helpMenu"> <!-- <modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="helpMenu">
<help-menu-form-component module_type="Order" :data="order"></help-menu-form-component> <help-menu-form-component></help-menu-form-component>
</modal-component> --> </modal-component> -->
</div> </div>
</div> </div>
@@ -99,6 +99,7 @@
</div> </div>
</div> </div>
@include('partials.footer') @include('partials.footer')
<!-- @include('partials.helpmenu') -->
</div> </div>
</div> </div>
@@ -0,0 +1 @@
<help-menu-component></help-menu-component>
+1 -1
View File
@@ -3,7 +3,7 @@
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
Route::group(['prefix' => 'helpmenu', 'as' => 'helpmenu.', 'namespace' => 'HelpMenu'], function () { Route::group(['prefix' => 'helpmenu', 'as' => 'helpmenu.', 'namespace' => 'HelpMenu'], function () {
Route::get('/question', 'FetchQuestionQAController@fetch')->name('first.question'); Route::get('/question/{set_id}', 'FetchQuestionQAController@fetch')->name('first.question');
Route::post('/question', 'UpdateNextQuestionQAController@fetch')->name('next.question'); Route::post('/question', 'UpdateNextQuestionQAController@fetch')->name('next.question');
Route::post('/generate', 'GenerateFeedbackUrlController@generate')->name('feedback.url.generate'); Route::post('/generate', 'GenerateFeedbackUrlController@generate')->name('feedback.url.generate');
Route::get('/list', 'ListQuestionsAnswersQAController@list')->name('list.questions.answers'); Route::get('/list', 'ListQuestionsAnswersQAController@list')->name('list.questions.answers');