@fleetbase/fleetops-engine 0.4.10 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composer.json +2 -2
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/src/Notifications/OrderAssigned.php +21 -0
- package/server/src/Notifications/OrderCanceled.php +21 -0
- package/server/src/Notifications/OrderDispatchFailed.php +21 -0
- package/server/src/Notifications/OrderDispatched.php +23 -1
- package/server/src/Notifications/OrderPing.php +20 -0
- package/server/src/Support/DistanceMatrix.php +2 -2
- package/server/src/Support/Utils.php +3 -3
package/composer.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetbase/fleetops-api",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.12",
|
|
4
4
|
"description": "Fleet & Transport Management Extension for Fleetbase",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fleetbase-extension",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"require": {
|
|
24
24
|
"php": "^8.0",
|
|
25
|
-
"fleetbase/core-api": "^1.4.
|
|
25
|
+
"fleetbase/core-api": "^1.4.5",
|
|
26
26
|
"barryvdh/laravel-dompdf": "^2.0",
|
|
27
27
|
"brick/geo": "0.7.2",
|
|
28
28
|
"cknow/laravel-money": "^7.1",
|
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Notifications;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\FleetOps\Http\Resources\v1\Order as OrderResource;
|
|
5
6
|
use Fleetbase\FleetOps\Models\Order;
|
|
6
7
|
use Fleetbase\FleetOps\Support\Utils;
|
|
7
8
|
use Illuminate\Broadcasting\Channel;
|
|
@@ -77,6 +78,26 @@ class OrderAssigned extends Notification implements ShouldQueue
|
|
|
77
78
|
];
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Get notification as array.
|
|
83
|
+
*
|
|
84
|
+
* @return void
|
|
85
|
+
*/
|
|
86
|
+
public function toArray()
|
|
87
|
+
{
|
|
88
|
+
$order = new OrderResource($this->order);
|
|
89
|
+
|
|
90
|
+
return [
|
|
91
|
+
'title' => 'New order ' . $this->order->public_id . ' assigned!',
|
|
92
|
+
'body' => $this->order->isScheduled ? 'You have a new order scheduled for ' . $this->order->scheduled_at : 'You have a new order assigned, tap for details.',
|
|
93
|
+
'data' => [
|
|
94
|
+
'id' => $this->order->public_id,
|
|
95
|
+
'type' => 'order_assigned',
|
|
96
|
+
'order' => $order->toWebhookPayload(),
|
|
97
|
+
],
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
|
|
80
101
|
/**
|
|
81
102
|
* Get the mail representation of the notification.
|
|
82
103
|
*
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Notifications;
|
|
4
4
|
|
|
5
|
+
use Fleetbase\FleetOps\Http\Resources\v1\Order as OrderResource;
|
|
5
6
|
use Fleetbase\FleetOps\Models\Order;
|
|
6
7
|
use Fleetbase\FleetOps\Support\Utils;
|
|
7
8
|
use Illuminate\Broadcasting\Channel;
|
|
@@ -77,6 +78,26 @@ class OrderCanceled extends Notification implements ShouldQueue
|
|
|
77
78
|
];
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Get notification as array.
|
|
83
|
+
*
|
|
84
|
+
* @return void
|
|
85
|
+
*/
|
|
86
|
+
public function toArray()
|
|
87
|
+
{
|
|
88
|
+
$order = new OrderResource($this->order);
|
|
89
|
+
|
|
90
|
+
return [
|
|
91
|
+
'title' => 'Order ' . $this->order->public_id . ' was canceled',
|
|
92
|
+
'body' => 'Order ' . $this->order->public_id . ' has been canceled.',
|
|
93
|
+
'data' => [
|
|
94
|
+
'id' => $this->order->public_id,
|
|
95
|
+
'type' => 'order_canceled',
|
|
96
|
+
'order' => $order->toWebhookPayload(),
|
|
97
|
+
],
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
|
|
80
101
|
/**
|
|
81
102
|
* Get the mail representation of the notification.
|
|
82
103
|
*
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
namespace Fleetbase\FleetOps\Notifications;
|
|
4
4
|
|
|
5
5
|
use Fleetbase\FleetOps\Events\OrderDispatchFailed as OrderDispatchFailedEvent;
|
|
6
|
+
use Fleetbase\FleetOps\Http\Resources\v1\Order as OrderResource;
|
|
6
7
|
use Fleetbase\FleetOps\Models\Order;
|
|
7
8
|
use Fleetbase\FleetOps\Support\Utils;
|
|
8
9
|
use Illuminate\Broadcasting\Channel;
|
|
@@ -81,6 +82,26 @@ class OrderDispatchFailed extends Notification implements ShouldQueue
|
|
|
81
82
|
return ['mail'];
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Get notification as array.
|
|
87
|
+
*
|
|
88
|
+
* @return void
|
|
89
|
+
*/
|
|
90
|
+
public function toArray()
|
|
91
|
+
{
|
|
92
|
+
$order = new OrderResource($this->order);
|
|
93
|
+
|
|
94
|
+
return [
|
|
95
|
+
'title' => 'Order ' . $this->order->public_id . ' has dispatch has failed!',
|
|
96
|
+
'body' => $this->reason,
|
|
97
|
+
'data' => [
|
|
98
|
+
'id' => $this->order->public_id,
|
|
99
|
+
'type' => 'order_dispatch_failed',
|
|
100
|
+
'order' => $order->toWebhookPayload(),
|
|
101
|
+
],
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
|
|
84
105
|
/**
|
|
85
106
|
* Get the mail representation of the notification.
|
|
86
107
|
*
|
|
@@ -87,6 +87,28 @@ class OrderDispatched extends Notification implements ShouldQueue
|
|
|
87
87
|
new Channel('api.' . session('api_credential')),
|
|
88
88
|
new Channel('order.' . $this->order->uuid),
|
|
89
89
|
new Channel('order.' . $this->order->public_id),
|
|
90
|
+
new Channel('driver.' . data_get($this->order, 'driverAssigned.uuid')),
|
|
91
|
+
new Channel('driver.' . data_get($this->order, 'driverAssigned.public_id')),
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get notification as array.
|
|
97
|
+
*
|
|
98
|
+
* @return void
|
|
99
|
+
*/
|
|
100
|
+
public function toArray()
|
|
101
|
+
{
|
|
102
|
+
$order = new OrderResource($this->order);
|
|
103
|
+
|
|
104
|
+
return [
|
|
105
|
+
'title' => 'Order ' . $this->order->public_id . ' has been dispatched!',
|
|
106
|
+
'body' => 'An order has just been dispatched to you and is ready to be started.',
|
|
107
|
+
'data' => [
|
|
108
|
+
'id' => $this->order->public_id,
|
|
109
|
+
'type' => 'order_dispatched',
|
|
110
|
+
'order' => $order->toWebhookPayload(),
|
|
111
|
+
],
|
|
90
112
|
];
|
|
91
113
|
}
|
|
92
114
|
|
|
@@ -131,7 +153,7 @@ class OrderDispatched extends Notification implements ShouldQueue
|
|
|
131
153
|
{
|
|
132
154
|
$message = (new MailMessage())
|
|
133
155
|
->subject('Order ' . $this->order->public_id . ' has been dispatched!')
|
|
134
|
-
->line('
|
|
156
|
+
->line('An order has just been dispatched to you and is ready to be started.');
|
|
135
157
|
|
|
136
158
|
$message->action('View Details', Utils::consoleUrl('', ['shift' => 'fleet-ops/orders/view/' . $this->order->public_id]));
|
|
137
159
|
|
|
@@ -95,6 +95,26 @@ class OrderPing extends Notification implements ShouldQueue
|
|
|
95
95
|
];
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Get notification as array.
|
|
100
|
+
*
|
|
101
|
+
* @return void
|
|
102
|
+
*/
|
|
103
|
+
public function toArray()
|
|
104
|
+
{
|
|
105
|
+
$order = new OrderResource($this->order);
|
|
106
|
+
|
|
107
|
+
return [
|
|
108
|
+
'title' => 'New incoming order!',
|
|
109
|
+
'body' => $this->distance ? 'New order available for pickup about ' . Utils::formatMeters($this->distance, false) . ' away' : 'New order is available for pickup.',
|
|
110
|
+
'data' => [
|
|
111
|
+
'id' => $this->order->public_id,
|
|
112
|
+
'type' => 'order_ping',
|
|
113
|
+
'order' => $order->toWebhookPayload(),
|
|
114
|
+
],
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
|
|
98
118
|
/**
|
|
99
119
|
* Get the broadcastable representation of the notification.
|
|
100
120
|
*
|
|
@@ -17,9 +17,9 @@ namespace Fleetbase\FleetOps\Support;
|
|
|
17
17
|
class DistanceMatrix
|
|
18
18
|
{
|
|
19
19
|
public ?float $distance;
|
|
20
|
-
public ?
|
|
20
|
+
public ?float $time;
|
|
21
21
|
|
|
22
|
-
public function __construct(?float $distance, ?
|
|
22
|
+
public function __construct(?float $distance, ?float $time)
|
|
23
23
|
{
|
|
24
24
|
$this->distance = $distance;
|
|
25
25
|
$this->time = $time;
|
|
@@ -783,8 +783,8 @@ class Utils extends FleetbaseUtils
|
|
|
783
783
|
]
|
|
784
784
|
)->json();
|
|
785
785
|
|
|
786
|
-
$distance = data_get($response, 'rows.0.elements.0.distance.value');
|
|
787
|
-
$time = data_get($response, 'rows.0.elements.0.duration.value');
|
|
786
|
+
$distance = (float) data_get($response, 'rows.0.elements.0.distance.value', 0);
|
|
787
|
+
$time = (float) data_get($response, 'rows.0.elements.0.duration.value', 0);
|
|
788
788
|
|
|
789
789
|
$result = static::createObject(
|
|
790
790
|
[
|
|
@@ -812,7 +812,7 @@ class Utils extends FleetbaseUtils
|
|
|
812
812
|
$destination = static::getPointFromMixed($destination);
|
|
813
813
|
|
|
814
814
|
$distance = Utils::vincentyGreatCircleDistance($origin, $destination);
|
|
815
|
-
$time = round($distance / 100) * self::DRIVING_TIME_MULTIPLIER;
|
|
815
|
+
$time = (float) round($distance / 100) * self::DRIVING_TIME_MULTIPLIER;
|
|
816
816
|
|
|
817
817
|
return new DistanceMatrix($distance, $time);
|
|
818
818
|
}
|