M3 Integration fixes
This commit is contained in:
@@ -28,33 +28,32 @@ class TwoShipAPIs extends Controller
|
||||
|
||||
if ($params === []) {
|
||||
$this->log($macpkr ?: '000000', $co, $whs, $user, 'X', 'No URL Parameters Sent');
|
||||
$result = response()->json(['code' => '405', 'status' => 'Error', 'message' => 'No URL Parameters Sent']);
|
||||
} else {
|
||||
try {
|
||||
$this->logRequest($macpkr, $co, $whs, $user);
|
||||
$orders = $this->aggregationOrders($macpkr, $co, $whs);
|
||||
$response = $this->callTwoShip($orders);
|
||||
$error = $this->responseError($response);
|
||||
|
||||
return response()->json(['code' => '405', 'status' => 'Error', 'message' => 'No URL Parameters Sent']);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->logRequest($macpkr, $co, $whs, $user);
|
||||
$orders = $this->aggregationOrders($macpkr, $co, $whs);
|
||||
$response = $this->callTwoShip($orders);
|
||||
$error = $this->responseError($response);
|
||||
if ($error !== '') {
|
||||
$this->log($macpkr, $co, $whs, $user, 'X', $response->status() . '-' . $error);
|
||||
|
||||
return response()->json(['code' => '405', 'status' => 'error', 'message' => 'Status: ' . $response->status() . '-' . $error]);
|
||||
if ($error !== '') {
|
||||
$this->log($macpkr, $co, $whs, $user, 'X', $response->status() . '-' . $error);
|
||||
$result = response()->json(['code' => '405', 'status' => 'error', 'message' => 'Status: ' . $response->status() . '-' . $error]);
|
||||
} else {
|
||||
$this->log($macpkr, $co, $whs, $user, '', $response->body());
|
||||
$this->markAggregationComplete($orders, $co, $whs);
|
||||
$result = response()->json(['code' => '200', 'status' => 'Success']);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
$message = str_contains($th->getMessage(), 'cURL error')
|
||||
? 'Curl Error: Communication with 2Ship Timed Out.'
|
||||
: '2Ship communication failed.';
|
||||
$this->log($macpkr, $co, $whs, $user, 'X', $message);
|
||||
$result = response()->json(['code' => '405', 'status' => 'error', 'message' => $message]);
|
||||
}
|
||||
|
||||
$this->log($macpkr, $co, $whs, $user, '', $response->body());
|
||||
$this->markAggregationComplete($orders, $co, $whs);
|
||||
|
||||
return response()->json(['code' => '200', 'status' => 'Success']);
|
||||
} catch (\Throwable $th) {
|
||||
$message = str_contains($th->getMessage(), 'cURL error')
|
||||
? 'Curl Error: Communication with 2Ship Timed Out.'
|
||||
: '2Ship communication failed.';
|
||||
$this->log($macpkr, $co, $whs, $user, 'X', $message);
|
||||
|
||||
return response()->json(['code' => '405', 'status' => 'error', 'message' => $message]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function configureTimeouts(): void
|
||||
|
||||
Reference in New Issue
Block a user