Use Parcel2Go public API scope by default
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 1m1s
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 1m1s
This commit is contained in:
@@ -15,11 +15,27 @@ class ShippingController extends Controller
|
||||
{
|
||||
abort_unless($request->user()->role === 'admin', 403);
|
||||
try {
|
||||
$account = $parcel2Go->fetch('me/detail');
|
||||
$balance = $parcel2Go->fetch('me/prepay/balance');
|
||||
$orders = $parcel2Go->fetch('me/orders/detail');
|
||||
$account = [];
|
||||
$balance = [];
|
||||
$orders = [];
|
||||
$profileAvailable = $parcel2Go->hasScope('my-profile');
|
||||
$profileNotice = null;
|
||||
|
||||
return view('shipping', compact('account', 'balance', 'orders') + [
|
||||
if ($profileAvailable) {
|
||||
try {
|
||||
$account = $parcel2Go->fetch('me/detail');
|
||||
$balance = $parcel2Go->fetch('me/prepay/balance');
|
||||
$orders = $parcel2Go->fetch('me/orders/detail');
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
$profileNotice = 'Parcel2Go connected, but account history is unavailable. Check that this client has my-profile access.';
|
||||
}
|
||||
} else {
|
||||
$parcel2Go->verifyCredentials();
|
||||
$profileNotice = 'Parcel2Go connected for quotes and collections. Add my-profile access in Parcel2Go to show account history and labels.';
|
||||
}
|
||||
|
||||
return view('shipping', compact('account', 'balance', 'orders', 'profileAvailable', 'profileNotice') + [
|
||||
'quotes' => $request->session()->get('shipping_quotes', []),
|
||||
'collectionDates' => $request->session()->get('shipping_collection_dates', []),
|
||||
'selectedService' => $request->session()->get('shipping_selected_service'),
|
||||
@@ -31,6 +47,8 @@ class ShippingController extends Controller
|
||||
|
||||
return view('shipping', [
|
||||
'account' => [], 'balance' => [], 'orders' => [],
|
||||
'profileAvailable' => false,
|
||||
'profileNotice' => null,
|
||||
'quotes' => $request->session()->get('shipping_quotes', []),
|
||||
'collectionDates' => $request->session()->get('shipping_collection_dates', []),
|
||||
'selectedService' => $request->session()->get('shipping_selected_service'),
|
||||
|
||||
Reference in New Issue
Block a user