@fleetbase/fleetops-engine 0.2.6 → 0.2.8

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.
Files changed (306) hide show
  1. package/.gitattributes +14 -0
  2. package/.php-cs-fixer.php +29 -0
  3. package/LICENSE.md +16 -4
  4. package/README.md +103 -13
  5. package/composer.json +85 -0
  6. package/extension.json +10 -0
  7. package/package.json +3 -3
  8. package/phpstan.neon.dist +8 -0
  9. package/phpunit.xml.dist +16 -0
  10. package/server/config/api.php +765 -0
  11. package/server/config/cache.stores.php +18 -0
  12. package/server/config/dompdf.php +242 -0
  13. package/server/config/fleetops.php +19 -0
  14. package/server/config/geocoder.php +108 -0
  15. package/server/data/globe.json +261 -0
  16. package/server/migrations/2023_04_27_053456_create_contacts_table.php +49 -0
  17. package/server/migrations/2023_04_27_053456_create_drivers_table.php +62 -0
  18. package/server/migrations/2023_04_27_053456_create_entities_table.php +67 -0
  19. package/server/migrations/2023_04_27_053456_create_fleet_drivers_table.php +39 -0
  20. package/server/migrations/2023_04_27_053456_create_fleets_table.php +47 -0
  21. package/server/migrations/2023_04_27_053456_create_fuel_reports_table.php +50 -0
  22. package/server/migrations/2023_04_27_053456_create_integrated_vendors_table.php +44 -0
  23. package/server/migrations/2023_04_27_053456_create_issues_table.php +53 -0
  24. package/server/migrations/2023_04_27_053456_create_orders_table.php +70 -0
  25. package/server/migrations/2023_04_27_053456_create_payloads_table.php +51 -0
  26. package/server/migrations/2023_04_27_053456_create_places_table.php +62 -0
  27. package/server/migrations/2023_04_27_053456_create_positions_table.php +46 -0
  28. package/server/migrations/2023_04_27_053456_create_proofs_table.php +44 -0
  29. package/server/migrations/2023_04_27_053456_create_purchase_rates_table.php +46 -0
  30. package/server/migrations/2023_04_27_053456_create_routes_table.php +40 -0
  31. package/server/migrations/2023_04_27_053456_create_service_areas_table.php +47 -0
  32. package/server/migrations/2023_04_27_053456_create_service_quote_items_table.php +42 -0
  33. package/server/migrations/2023_04_27_053456_create_service_quotes_table.php +47 -0
  34. package/server/migrations/2023_04_27_053456_create_service_rate_fees_table.php +45 -0
  35. package/server/migrations/2023_04_27_053456_create_service_rate_parcel_fees_table.php +47 -0
  36. package/server/migrations/2023_04_27_053456_create_service_rates_table.php +61 -0
  37. package/server/migrations/2023_04_27_053456_create_tracking_numbers_table.php +46 -0
  38. package/server/migrations/2023_04_27_053456_create_tracking_statuses_table.php +54 -0
  39. package/server/migrations/2023_04_27_053456_create_vehicles_table.php +84 -0
  40. package/server/migrations/2023_04_27_053456_create_vendors_table.php +56 -0
  41. package/server/migrations/2023_04_27_053456_create_waypoints_table.php +45 -0
  42. package/server/migrations/2023_04_27_053456_create_zones_table.php +46 -0
  43. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_companies_table.php +32 -0
  44. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_contacts_table.php +34 -0
  45. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_drivers_table.php +40 -0
  46. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_entities_table.php +40 -0
  47. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_fleet_drivers_table.php +34 -0
  48. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_fleets_table.php +36 -0
  49. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_fuel_reports_table.php +36 -0
  50. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_integrated_vendors_table.php +34 -0
  51. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_issues_table.php +38 -0
  52. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_orders_table.php +48 -0
  53. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_payloads_table.php +40 -0
  54. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_places_table.php +32 -0
  55. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_positions_table.php +36 -0
  56. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_proofs_table.php +34 -0
  57. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_purchase_rates_table.php +38 -0
  58. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_routes_table.php +34 -0
  59. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_areas_table.php +34 -0
  60. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_quote_items_table.php +32 -0
  61. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_quotes_table.php +38 -0
  62. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_rate_fees_table.php +32 -0
  63. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_rate_parcel_fees_table.php +32 -0
  64. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_rates_table.php +36 -0
  65. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_tracking_numbers_table.php +34 -0
  66. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_tracking_statuses_table.php +34 -0
  67. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_vehicles_table.php +36 -0
  68. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_vendors_table.php +40 -0
  69. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_waypoints_table.php +38 -0
  70. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_zones_table.php +34 -0
  71. package/server/migrations/2023_09_14_074512_update_vehicles_table.php +100 -0
  72. package/server/migrations/2023_09_14_074619_create_vehicle_devices_table.php +44 -0
  73. package/server/migrations/2023_09_26_071205_add_online_column_to_vehicles_table.php +32 -0
  74. package/server/migrations/2023_09_26_083957_create_fleet_vehicles_table.php +45 -0
  75. package/server/migrations/2023_09_27_023757_add_column_to_fleets_table.php +46 -0
  76. package/server/migrations/2023_10_05_074811_update_vehicle.php +42 -0
  77. package/server/resources/views/labels/default.php +165 -0
  78. package/server/src/Auth/Schemas/FleetOps.php +75 -0
  79. package/server/src/Casts/MultiPolygon.php +50 -0
  80. package/server/src/Casts/Point.php +109 -0
  81. package/server/src/Casts/Polygon.php +46 -0
  82. package/server/src/Console/Commands/DispatchAdhocOrders.php +137 -0
  83. package/server/src/Console/Commands/DispatchOrders.php +71 -0
  84. package/server/src/Console/Commands/TrackOrderDistanceAndTime.php +62 -0
  85. package/server/src/Events/DriverLocationChanged.php +174 -0
  86. package/server/src/Events/DriverSimulatedLocationChanged.php +183 -0
  87. package/server/src/Events/EntityDriverAssigned.php +36 -0
  88. package/server/src/Events/OrderCanceled.php +15 -0
  89. package/server/src/Events/OrderCompleted.php +15 -0
  90. package/server/src/Events/OrderDispatchFailed.php +42 -0
  91. package/server/src/Events/OrderDispatched.php +15 -0
  92. package/server/src/Events/OrderDriverAssigned.php +15 -0
  93. package/server/src/Events/OrderReady.php +15 -0
  94. package/server/src/Events/OrderStarted.php +15 -0
  95. package/server/src/Exceptions/IntegratedVendorException.php +18 -0
  96. package/server/src/Expansions/UserExpansion.php +63 -0
  97. package/server/src/Exports/ContactExport.php +56 -0
  98. package/server/src/Exports/DriverExport.php +61 -0
  99. package/server/src/Exports/FleetExport.php +53 -0
  100. package/server/src/Exports/PlaceExport.php +55 -0
  101. package/server/src/Exports/ServiceAreaExport.php +58 -0
  102. package/server/src/Exports/VehicleExport.php +57 -0
  103. package/server/src/Exports/VendorExport.php +57 -0
  104. package/server/src/Http/Controllers/Api/v1/ContactController.php +133 -0
  105. package/server/src/Http/Controllers/Api/v1/DriverController.php +691 -0
  106. package/server/src/Http/Controllers/Api/v1/EntityController.php +230 -0
  107. package/server/src/Http/Controllers/Api/v1/FleetController.php +146 -0
  108. package/server/src/Http/Controllers/Api/v1/LabelController.php +63 -0
  109. package/server/src/Http/Controllers/Api/v1/OrderController.php +1114 -0
  110. package/server/src/Http/Controllers/Api/v1/PayloadController.php +195 -0
  111. package/server/src/Http/Controllers/Api/v1/PlaceController.php +333 -0
  112. package/server/src/Http/Controllers/Api/v1/PurchaseRateController.php +199 -0
  113. package/server/src/Http/Controllers/Api/v1/ServiceAreaController.php +133 -0
  114. package/server/src/Http/Controllers/Api/v1/ServiceQuoteController.php +381 -0
  115. package/server/src/Http/Controllers/Api/v1/ServiceRateController.php +223 -0
  116. package/server/src/Http/Controllers/Api/v1/TrackingNumberController.php +146 -0
  117. package/server/src/Http/Controllers/Api/v1/TrackingStatusController.php +138 -0
  118. package/server/src/Http/Controllers/Api/v1/VehicleController.php +191 -0
  119. package/server/src/Http/Controllers/Api/v1/VendorController.php +159 -0
  120. package/server/src/Http/Controllers/Api/v1/ZoneController.php +146 -0
  121. package/server/src/Http/Controllers/FleetOpsController.php +13 -0
  122. package/server/src/Http/Controllers/Internal/v1/ContactController.php +69 -0
  123. package/server/src/Http/Controllers/Internal/v1/DriverController.php +261 -0
  124. package/server/src/Http/Controllers/Internal/v1/EntityController.php +15 -0
  125. package/server/src/Http/Controllers/Internal/v1/FleetController.php +152 -0
  126. package/server/src/Http/Controllers/Internal/v1/FleetOpsLookupController.php +80 -0
  127. package/server/src/Http/Controllers/Internal/v1/FuelReportController.php +15 -0
  128. package/server/src/Http/Controllers/Internal/v1/GeocoderController.php +96 -0
  129. package/server/src/Http/Controllers/Internal/v1/IntegratedVendorController.php +63 -0
  130. package/server/src/Http/Controllers/Internal/v1/IssueController.php +15 -0
  131. package/server/src/Http/Controllers/Internal/v1/LiveController.php +127 -0
  132. package/server/src/Http/Controllers/Internal/v1/MetricsController.php +75 -0
  133. package/server/src/Http/Controllers/Internal/v1/MorphController.php +77 -0
  134. package/server/src/Http/Controllers/Internal/v1/OrderConfigController.php +269 -0
  135. package/server/src/Http/Controllers/Internal/v1/OrderController.php +564 -0
  136. package/server/src/Http/Controllers/Internal/v1/PayloadController.php +15 -0
  137. package/server/src/Http/Controllers/Internal/v1/PlaceController.php +163 -0
  138. package/server/src/Http/Controllers/Internal/v1/ProofController.php +139 -0
  139. package/server/src/Http/Controllers/Internal/v1/PurchaseRateController.php +15 -0
  140. package/server/src/Http/Controllers/Internal/v1/RouteController.php +15 -0
  141. package/server/src/Http/Controllers/Internal/v1/ServiceAreaController.php +32 -0
  142. package/server/src/Http/Controllers/Internal/v1/ServiceQuoteController.php +345 -0
  143. package/server/src/Http/Controllers/Internal/v1/ServiceRateController.php +47 -0
  144. package/server/src/Http/Controllers/Internal/v1/SettingController.php +30 -0
  145. package/server/src/Http/Controllers/Internal/v1/TrackingNumberController.php +15 -0
  146. package/server/src/Http/Controllers/Internal/v1/TrackingStatusController.php +15 -0
  147. package/server/src/Http/Controllers/Internal/v1/VehicleController.php +65 -0
  148. package/server/src/Http/Controllers/Internal/v1/VehicleDeviceController.php +15 -0
  149. package/server/src/Http/Controllers/Internal/v1/VendorController.php +120 -0
  150. package/server/src/Http/Controllers/Internal/v1/ZoneController.php +15 -0
  151. package/server/src/Http/Filter/ContactFilter.php +86 -0
  152. package/server/src/Http/Filter/DriverFilter.php +148 -0
  153. package/server/src/Http/Filter/FleetFilter.php +108 -0
  154. package/server/src/Http/Filter/IntegratedVendorFilter.php +13 -0
  155. package/server/src/Http/Filter/OrderFilter.php +242 -0
  156. package/server/src/Http/Filter/PlaceFilter.php +111 -0
  157. package/server/src/Http/Filter/ServiceAreaFilter.php +13 -0
  158. package/server/src/Http/Filter/ServiceQuoteFilter.php +13 -0
  159. package/server/src/Http/Filter/ServiceRateFilter.php +33 -0
  160. package/server/src/Http/Filter/TrackingStatusFilter.php +43 -0
  161. package/server/src/Http/Filter/VehicleFilter.php +91 -0
  162. package/server/src/Http/Filter/VendorFilter.php +83 -0
  163. package/server/src/Http/Filter/ZoneFilter.php +13 -0
  164. package/server/src/Http/Requests/CancelOrderRequest.php +31 -0
  165. package/server/src/Http/Requests/CreateContactRequest.php +33 -0
  166. package/server/src/Http/Requests/CreateDriverRequest.php +55 -0
  167. package/server/src/Http/Requests/CreateEntityRequest.php +43 -0
  168. package/server/src/Http/Requests/CreateFleetRequest.php +32 -0
  169. package/server/src/Http/Requests/CreateOrderRequest.php +66 -0
  170. package/server/src/Http/Requests/CreatePayloadRequest.php +37 -0
  171. package/server/src/Http/Requests/CreatePlaceRequest.php +38 -0
  172. package/server/src/Http/Requests/CreatePurchaseRateRequest.php +33 -0
  173. package/server/src/Http/Requests/CreateServiceAreaRequest.php +35 -0
  174. package/server/src/Http/Requests/CreateServiceQuoteRequest.php +29 -0
  175. package/server/src/Http/Requests/CreateServiceRateRequest.php +56 -0
  176. package/server/src/Http/Requests/CreateTrackingNumberRequest.php +34 -0
  177. package/server/src/Http/Requests/CreateTrackingStatusRequest.php +42 -0
  178. package/server/src/Http/Requests/CreateVehicleRequest.php +32 -0
  179. package/server/src/Http/Requests/CreateVendorRequest.php +35 -0
  180. package/server/src/Http/Requests/CreateZoneRequest.php +35 -0
  181. package/server/src/Http/Requests/DecodeTrackingNumberQR.php +30 -0
  182. package/server/src/Http/Requests/DriverSimulationRequest.php +46 -0
  183. package/server/src/Http/Requests/Internal/AssignOrderRequest.php +31 -0
  184. package/server/src/Http/Requests/Internal/CreateDriverRequest.php +42 -0
  185. package/server/src/Http/Requests/Internal/FleetActionRequest.php +32 -0
  186. package/server/src/Http/Requests/Internal/UpdateDriverRequest.php +7 -0
  187. package/server/src/Http/Requests/QueryServiceQuotesRequest.php +41 -0
  188. package/server/src/Http/Requests/UpdateContactRequest.php +20 -0
  189. package/server/src/Http/Requests/UpdateDriverRequest.php +7 -0
  190. package/server/src/Http/Requests/UpdateEntityRequest.php +7 -0
  191. package/server/src/Http/Requests/UpdateFleetRequest.php +7 -0
  192. package/server/src/Http/Requests/UpdateOrderRequest.php +7 -0
  193. package/server/src/Http/Requests/UpdatePayloadRequest.php +7 -0
  194. package/server/src/Http/Requests/UpdatePlaceRequest.php +7 -0
  195. package/server/src/Http/Requests/UpdatePurchaseRateRequest.php +7 -0
  196. package/server/src/Http/Requests/UpdateServiceAreaRequest.php +29 -0
  197. package/server/src/Http/Requests/UpdateServiceQuoteRequest.php +29 -0
  198. package/server/src/Http/Requests/UpdateServiceRateRequest.php +29 -0
  199. package/server/src/Http/Requests/UpdateTrackingNumberRequest.php +7 -0
  200. package/server/src/Http/Requests/UpdateTrackingStatusRequest.php +32 -0
  201. package/server/src/Http/Requests/UpdateVehicleRequest.php +7 -0
  202. package/server/src/Http/Requests/UpdateVendorRequest.php +7 -0
  203. package/server/src/Http/Requests/UpdateZoneRequest.php +7 -0
  204. package/server/src/Http/Resources/Internal/v1/IntegratedVendorFacilitator.php +37 -0
  205. package/server/src/Http/Resources/Internal/v1/Vehicle.php +33 -0
  206. package/server/src/Http/Resources/Internal/v1/Waypoint.php +34 -0
  207. package/server/src/Http/Resources/v1/Contact.php +62 -0
  208. package/server/src/Http/Resources/v1/CurrentJob.php +36 -0
  209. package/server/src/Http/Resources/v1/DeletedResource.php +61 -0
  210. package/server/src/Http/Resources/v1/Driver.php +89 -0
  211. package/server/src/Http/Resources/v1/Entity.php +107 -0
  212. package/server/src/Http/Resources/v1/Fleet.php +60 -0
  213. package/server/src/Http/Resources/v1/FuelReport.php +67 -0
  214. package/server/src/Http/Resources/v1/Order.php +131 -0
  215. package/server/src/Http/Resources/v1/Payload.php +94 -0
  216. package/server/src/Http/Resources/v1/Place.php +84 -0
  217. package/server/src/Http/Resources/v1/Proof.php +36 -0
  218. package/server/src/Http/Resources/v1/PurchaseRate.php +77 -0
  219. package/server/src/Http/Resources/v1/ServiceArea.php +55 -0
  220. package/server/src/Http/Resources/v1/ServiceQuote.php +57 -0
  221. package/server/src/Http/Resources/v1/ServiceRate.php +94 -0
  222. package/server/src/Http/Resources/v1/ServiceRateFee.php +58 -0
  223. package/server/src/Http/Resources/v1/ServiceRateParcelFee.php +48 -0
  224. package/server/src/Http/Resources/v1/TrackingNumber.php +62 -0
  225. package/server/src/Http/Resources/v1/TrackingStatus.php +84 -0
  226. package/server/src/Http/Resources/v1/Vehicle.php +75 -0
  227. package/server/src/Http/Resources/v1/VehicleDevice.php +44 -0
  228. package/server/src/Http/Resources/v1/VehicleWithoutDriver.php +72 -0
  229. package/server/src/Http/Resources/v1/Vendor.php +72 -0
  230. package/server/src/Http/Resources/v1/Zone.php +60 -0
  231. package/server/src/Imports/OrdersImport.php +18 -0
  232. package/server/src/Integrations/Lalamove/Lalamove.php +678 -0
  233. package/server/src/Integrations/Lalamove/LalamoveDeliveryStop.php +97 -0
  234. package/server/src/Integrations/Lalamove/LalamoveMarket.php +123 -0
  235. package/server/src/Integrations/Lalamove/LalamoveServiceType.php +161 -0
  236. package/server/src/Jobs/SimulateDrivingRoute.php +81 -0
  237. package/server/src/Jobs/SimulateWaypointReached.php +79 -0
  238. package/server/src/Listeners/HandleOrderCanceled.php +46 -0
  239. package/server/src/Listeners/HandleOrderCreated.php +23 -0
  240. package/server/src/Listeners/HandleOrderDispatchFailed.php +35 -0
  241. package/server/src/Listeners/HandleOrderDispatched.php +108 -0
  242. package/server/src/Listeners/HandleOrderDriverAssigned.php +42 -0
  243. package/server/src/Listeners/HandleOrderReady.php +27 -0
  244. package/server/src/Listeners/HandleUserRemovedFromCompany.php +31 -0
  245. package/server/src/Models/Contact.php +239 -0
  246. package/server/src/Models/Driver.php +543 -0
  247. package/server/src/Models/Entity.php +416 -0
  248. package/server/src/Models/Fleet.php +203 -0
  249. package/server/src/Models/FleetDriver.php +73 -0
  250. package/server/src/Models/FleetVehicle.php +73 -0
  251. package/server/src/Models/FuelReport.php +125 -0
  252. package/server/src/Models/IntegratedVendor.php +219 -0
  253. package/server/src/Models/Issue.php +111 -0
  254. package/server/src/Models/Order.php +1132 -0
  255. package/server/src/Models/Payload.php +699 -0
  256. package/server/src/Models/Place.php +656 -0
  257. package/server/src/Models/Position.php +119 -0
  258. package/server/src/Models/Proof.php +94 -0
  259. package/server/src/Models/PurchaseRate.php +208 -0
  260. package/server/src/Models/Route.php +128 -0
  261. package/server/src/Models/ServiceArea.php +161 -0
  262. package/server/src/Models/ServiceQuote.php +207 -0
  263. package/server/src/Models/ServiceQuoteItem.php +46 -0
  264. package/server/src/Models/ServiceRate.php +953 -0
  265. package/server/src/Models/ServiceRateFee.php +96 -0
  266. package/server/src/Models/ServiceRateParcelFee.php +116 -0
  267. package/server/src/Models/TrackingNumber.php +310 -0
  268. package/server/src/Models/TrackingStatus.php +177 -0
  269. package/server/src/Models/Vehicle.php +452 -0
  270. package/server/src/Models/VehicleDevice.php +79 -0
  271. package/server/src/Models/Vendor.php +244 -0
  272. package/server/src/Models/Waypoint.php +226 -0
  273. package/server/src/Models/Zone.php +95 -0
  274. package/server/src/Notifications/OrderAssigned.php +140 -0
  275. package/server/src/Notifications/OrderCanceled.php +129 -0
  276. package/server/src/Notifications/OrderDispatchFailed.php +81 -0
  277. package/server/src/Notifications/OrderDispatched.php +173 -0
  278. package/server/src/Notifications/OrderPing.php +162 -0
  279. package/server/src/Notifications/OrderSplit.php +56 -0
  280. package/server/src/Observers/DriverObserver.php +34 -0
  281. package/server/src/Observers/OrderObserver.php +34 -0
  282. package/server/src/Observers/PayloadObserver.php +30 -0
  283. package/server/src/Observers/PlaceObserver.php +26 -0
  284. package/server/src/Observers/PurchaseRateObserver.php +61 -0
  285. package/server/src/Observers/ServiceAreaObserver.php +35 -0
  286. package/server/src/Observers/ServiceRateObserver.php +78 -0
  287. package/server/src/Observers/TrackingNumberObserver.php +44 -0
  288. package/server/src/Observers/UserObserver.php +20 -0
  289. package/server/src/Observers/VehicleObserver.php +66 -0
  290. package/server/src/Providers/EventServiceProvider.php +30 -0
  291. package/server/src/Providers/FleetOpsServiceProvider.php +94 -0
  292. package/server/src/Rules/ResolvablePoint.php +37 -0
  293. package/server/src/Scopes/DriverScope.php +21 -0
  294. package/server/src/Support/Algo.php +55 -0
  295. package/server/src/Support/DistanceMatrix.php +27 -0
  296. package/server/src/Support/Encoding/Polyline.php +168 -0
  297. package/server/src/Support/Flow.php +622 -0
  298. package/server/src/Support/Geocoding.php +216 -0
  299. package/server/src/Support/IntegratedVendors.php +287 -0
  300. package/server/src/Support/Metrics.php +305 -0
  301. package/server/src/Support/OSRM.php +191 -0
  302. package/server/src/Support/ParsePhone.php +21 -0
  303. package/server/src/Support/Utils.php +1145 -0
  304. package/server/src/Traits/HasTrackingNumber.php +185 -0
  305. package/server/src/routes.php +381 -0
  306. package/server/tests/Feature.php +5 -0
@@ -0,0 +1,67 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+ use Grimzy\LaravelMysqlSpatial\Types\Point;
8
+
9
+ class FuelReport extends FleetbaseResource
10
+ {
11
+ /**
12
+ * Transform the resource into an array.
13
+ *
14
+ * @param \Illuminate\Http\Request $request
15
+ *
16
+ * @return array
17
+ */
18
+ public function toArray($request)
19
+ {
20
+ return array_merge(
21
+ $this->getInternalIds(),
22
+ [
23
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
24
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
25
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
26
+ 'driver_uuid' => $this->when(Http::isInternalRequest(), $this->driver_uuid),
27
+ 'vehicle_uuid' => $this->when(Http::isInternalRequest(), $this->vehicle_uuid),
28
+ 'driver_name' => $this->when(Http::isInternalRequest(), $this->driver_name),
29
+ 'vehicle_name' => $this->when(Http::isInternalRequest(), $this->vehicle_name),
30
+ 'vehicle' => $this->whenLoaded('vehicle', new Vehicle($this->vehicle)),
31
+ 'driver' => $this->whenLoaded('driver', new Driver($this->driver)),
32
+ 'odometer' => $this->odometer,
33
+ 'amount' => $this->amount,
34
+ 'currency' => $this->currency,
35
+ 'volume' => $this->volume,
36
+ 'metric_unit' => $this->metric_unit,
37
+ 'type' => $this->type,
38
+ 'location' => $this->location ?? new Point(0, 0),
39
+ 'updated_at' => $this->updated_at,
40
+ 'created_at' => $this->created_at,
41
+ ]
42
+ );
43
+ }
44
+
45
+ /**
46
+ * Transform the resource into an webhook payload.
47
+ *
48
+ * @return array
49
+ */
50
+ public function toWebhookPayload()
51
+ {
52
+ return [
53
+ 'id' => $this->public_id,
54
+ 'driver' => data_get($this, 'driver.public_id'),
55
+ 'vehicle' => data_get($this, 'vehicle.public_id'),
56
+ 'odometer' => $this->odometer,
57
+ 'amount' => $this->amount,
58
+ 'currency' => $this->currency,
59
+ 'volume' => $this->volume,
60
+ 'metric_unit' => $this->metric_unit,
61
+ 'type' => $this->type,
62
+ 'location' => $this->location ?? new Point(0, 0),
63
+ 'updated_at' => $this->updated_at,
64
+ 'created_at' => $this->created_at,
65
+ ];
66
+ }
67
+ }
@@ -0,0 +1,131 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\FleetOps\Support\Utils;
6
+ use Fleetbase\Http\Resources\FleetbaseResource;
7
+ use Fleetbase\Support\Http;
8
+ use Fleetbase\Support\Resolve;
9
+
10
+ class Order extends FleetbaseResource
11
+ {
12
+ /**
13
+ * Transform the resource into an array.
14
+ *
15
+ * @param \Illuminate\Http\Request $request
16
+ *
17
+ * @return array
18
+ */
19
+ public function toArray($request)
20
+ {
21
+ return [
22
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
25
+ 'internal_id' => $this->internal_id,
26
+ 'company_uuid' => $this->when(Http::isInternalRequest(), $this->company_uuid),
27
+ 'transaction_uuid' => $this->when(Http::isInternalRequest(), $this->transaction_uuid),
28
+ 'customer_uuid' => $this->when(Http::isInternalRequest(), $this->customer_uuid),
29
+ 'customer_type' => $this->when(Http::isInternalRequest(), $this->customer_type),
30
+ 'facilitator_uuid' => $this->when(Http::isInternalRequest(), $this->facilitator_uuid),
31
+ 'facilitator_type' => $this->when(Http::isInternalRequest(), $this->facilitator_type),
32
+ 'payload_uuid' => $this->when(Http::isInternalRequest(), $this->payload_uuid),
33
+ 'route_uuid' => $this->when(Http::isInternalRequest(), $this->route_uuid),
34
+ 'purchase_rate_uuid' => $this->when(Http::isInternalRequest(), $this->purchase_rate_uuid),
35
+ 'tracking_number_uuid' => $this->when(Http::isInternalRequest(), $this->tracking_number_uuid),
36
+ 'driver_assigned_uuid' => $this->when(Http::isInternalRequest(), $this->driver_assigned_uuid),
37
+ 'service_quote_uuid' => $this->when(Http::isInternalRequest(), $this->service_quote_uuid),
38
+ 'has_driver_assigned' => $this->when(Http::isInternalRequest(), $this->has_driver_assigned),
39
+ 'is_scheduled' => $this->when(Http::isInternalRequest(), $this->is_scheduled),
40
+ 'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)),
41
+ 'payload' => new Payload($this->payload),
42
+ 'facilitator' => $this->setFacilitatorType(Resolve::resourceForMorph($this->facilitator_type, $this->facilitator_uuid)),
43
+ 'driver_assigned' => new Driver($this->driverAssigned()->without(['jobs', 'currentJob', 'driverAssigned'])->first()),
44
+ 'tracking_number' => new TrackingNumber($this->trackingNumber),
45
+ 'tracking_statuses' => $this->whenLoaded('trackingStatuses', TrackingStatus::collection($this->trackingStatuses)),
46
+ 'purchase_rate' => new PurchaseRate($this->purchaseRate),
47
+ 'notes' => $this->notes,
48
+ 'type' => $this->type,
49
+ 'status' => $this->status,
50
+ 'pod_method' => $this->pod_method,
51
+ 'pod_required' => $this->pod_required ?? false,
52
+ 'adhoc' => $this->adhoc,
53
+ 'adhoc_distance' => (int) $this->getAdhocDistance(),
54
+ 'distance' => (int) $this->distance,
55
+ 'time' => (int) $this->time,
56
+ 'meta' => $this->meta ?? [],
57
+ 'dispatched_at' => $this->dispatched_at,
58
+ 'started_at' => $this->started_at,
59
+ 'scheduled_at' => $this->scheduled_at,
60
+ 'updated_at' => $this->updated_at,
61
+ 'created_at' => $this->created_at,
62
+ ];
63
+ }
64
+
65
+ /**
66
+ * Set the customer type for the given data array.
67
+ *
68
+ * @param array $resolved the input data array
69
+ *
70
+ * @return array the modified data array with the customer type set
71
+ */
72
+ public function setCustomerType($resolved)
73
+ {
74
+ if (empty($resolved)) {
75
+ return $resolved;
76
+ }
77
+
78
+ data_set($resolved, 'type', 'customer');
79
+ data_set($resolved, 'customer_type', 'customer-' . Utils::toEmberResourceType($this->customer_type));
80
+
81
+ return $resolved;
82
+ }
83
+
84
+ /**
85
+ * Set the facilitator type for the given data array.
86
+ *
87
+ * @param array $resolved the input data array
88
+ *
89
+ * @return array the modified data array with the facilitator type set
90
+ */
91
+ public function setFacilitatorType($resolved)
92
+ {
93
+ if (empty($resolved)) {
94
+ return $resolved;
95
+ }
96
+
97
+ data_set($resolved, 'type', 'facilitator');
98
+ data_set($resolved, 'facilitator_type', 'facilitator-' . Utils::toEmberResourceType($this->facilitator_type));
99
+
100
+ return $resolved;
101
+ }
102
+
103
+ /**
104
+ * Transform the resource into an webhook payload.
105
+ *
106
+ * @return array
107
+ */
108
+ public function toWebhookPayload()
109
+ {
110
+ return [
111
+ 'id' => $this->public_id,
112
+ 'internal_id' => $this->internal_id,
113
+ 'customer' => Resolve::resourceForMorph($this->customer_type, $this->customer_uuid),
114
+ 'payload' => new Payload($this->payload),
115
+ 'facilitator' => Resolve::resourceForMorph($this->facilitator_type, $this->facilitator_uuid),
116
+ 'driver_assigned' => new Driver($this->driverAssigned),
117
+ 'tracking_number' => new TrackingNumber($this->trackingNumber),
118
+ 'purchase_rate' => new PurchaseRate($this->purchaseRate),
119
+ 'notes' => $this->notes ?? '',
120
+ 'type' => $this->type ?? null,
121
+ 'status' => $this->status,
122
+ 'adhoc' => $this->adhoc,
123
+ 'meta' => $this->meta ?? [],
124
+ 'dispatched_at' => $this->dispatched_at,
125
+ 'started_at' => $this->started_at,
126
+ 'scheduled_at' => $this->scheduled_at,
127
+ 'updated_at' => $this->updated_at,
128
+ 'created_at' => $this->created_at,
129
+ ];
130
+ }
131
+ }
@@ -0,0 +1,94 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\FleetOps\Models\Waypoint;
6
+ use Fleetbase\Http\Resources\FleetbaseResource;
7
+ use Fleetbase\Support\Http;
8
+
9
+ class Payload extends FleetbaseResource
10
+ {
11
+ /**
12
+ * Transform the resource into an array.
13
+ *
14
+ * @param \Illuminate\Http\Request $request
15
+ *
16
+ * @return array
17
+ */
18
+ public function toArray($request)
19
+ {
20
+ return array_merge(
21
+ $this->getInternalIds(),
22
+ [
23
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
24
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
25
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
26
+ 'current_waypoint_uuid' => $this->when(Http::isInternalRequest(), $this->current_waypoint_uuid),
27
+ 'pickup_uuid' => $this->when(Http::isInternalRequest(), $this->pickup_uuid),
28
+ 'dropoff_uuid' => $this->when(Http::isInternalRequest(), $this->dropoff_uuid),
29
+ 'return_uuid' => $this->when(Http::isInternalRequest(), $this->return_uuid),
30
+ 'current_waypoint' => $this->when(!Http::isInternalRequest() && $this->currentWaypoint, data_get($this, 'currentWaypoint.public_id'), null),
31
+ 'pickup' => new Place($this->pickup),
32
+ 'dropoff' => new Place($this->dropoff),
33
+ 'return' => new Place($this->return),
34
+ 'waypoints' => $this->waypoints($this->waypoints),
35
+ 'entities' => Entity::collection($this->entities ?? []),
36
+ 'cod_amount' => $this->cod_amount ?? null,
37
+ 'cod_currency' => $this->cod_currency ?? null,
38
+ 'cod_payment_method' => $this->cod_payment_method ?? null,
39
+ 'meta' => $this->meta ?? [],
40
+ 'updated_at' => $this->updated_at,
41
+ 'created_at' => $this->created_at,
42
+ ]
43
+ );
44
+ }
45
+
46
+ /**
47
+ * Transform the resource into an webhook payload.
48
+ *
49
+ * @return array
50
+ */
51
+ public function toWebhookPayload()
52
+ {
53
+ return [
54
+ 'id' => $this->public_id,
55
+ 'pickup' => new Place($this->pickup),
56
+ 'dropoff' => new Place($this->dropoff),
57
+ 'return' => new Place($this->return),
58
+ 'waypoints' => static::waypoints($this->waypoints),
59
+ 'entities' => Entity::collection($this->entities ?? []),
60
+ 'cod_amount' => $this->cod_amount ?? null,
61
+ 'cod_currency' => $this->cod_currency ?? null,
62
+ 'cod_payment_method' => $this->cod_payment_method ?? null,
63
+ 'meta' => $this->meta ?? [],
64
+ 'updated_at' => $this->updated_at,
65
+ 'created_at' => $this->created_at,
66
+ ];
67
+ }
68
+
69
+ /**
70
+ * Returns the correct pickup resource if applicable.
71
+ *
72
+ * @param \Illuminate\Support\Collection $waypoints
73
+ *
74
+ * @return Illuminate\Http\Resources\Json\JsonResource|null
75
+ */
76
+ public function waypoints($waypoints)
77
+ {
78
+ if (empty($waypoints)) {
79
+ return [];
80
+ }
81
+
82
+ $waypoints = $waypoints->map(
83
+ function ($place) {
84
+ $waypoint = Waypoint::where(['payload_uuid' => $this->uuid, 'place_uuid' => $place->uuid])->without(['place'])->with(['trackingNumber'])->first();
85
+ $place->tracking_number = new TrackingNumber($waypoint->trackingNumber);
86
+ $place->order = $waypoint->order;
87
+
88
+ return $place;
89
+ }
90
+ )->sortBy('order');
91
+
92
+ return Place::collection($waypoints ?? []);
93
+ }
94
+ }
@@ -0,0 +1,84 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+ use Fleetbase\Support\Resolve;
8
+ use Grimzy\LaravelMysqlSpatial\Types\Point;
9
+
10
+ class Place extends FleetbaseResource
11
+ {
12
+ /**
13
+ * Transform the resource into an array.
14
+ *
15
+ * @param \Illuminate\Http\Request $request
16
+ *
17
+ * @return array
18
+ */
19
+ public function toArray($request)
20
+ {
21
+ return array_merge(
22
+ $this->getInternalIds(),
23
+ [
24
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
25
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
26
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
27
+ 'name' => $this->name,
28
+ 'location' => $this->location ?? new Point(0, 0),
29
+ 'address' => $this->address,
30
+ 'address_html' => $this->when(Http::isInternalRequest(), $this->address_html),
31
+ 'street1' => $this->street1 ?? null,
32
+ 'street2' => $this->street2 ?? null,
33
+ 'city' => $this->city ?? null,
34
+ 'province' => $this->province ?? null,
35
+ 'postal_code' => $this->postal_code ?? null,
36
+ 'neighborhood' => $this->neighborhood ?? null,
37
+ 'district' => $this->district ?? null,
38
+ 'building' => $this->building ?? null,
39
+ 'security_access_code' => $this->security_access_code ?? null,
40
+ 'country' => $this->country ?? null,
41
+ 'country_name' => $this->when(Http::isInternalRequest(), $this->country_name),
42
+ 'phone' => $this->phone ?? null,
43
+ 'owner' => $this->when(!Http::isInternalRequest(), Resolve::resourceForMorph($this->owner_type, $this->owner_uuid)),
44
+ 'tracking_number' => $this->whenLoaded('trackingNumber', $this->trackingNumber),
45
+ 'type' => $this->type ?? null,
46
+ 'meta' => $this->meta ?? [],
47
+ 'updated_at' => $this->updated_at,
48
+ 'created_at' => $this->created_at,
49
+ ]
50
+ );
51
+ }
52
+
53
+ /**
54
+ * Transform the resource into an webhook payload.
55
+ *
56
+ * @return array
57
+ */
58
+ public function toWebhookPayload()
59
+ {
60
+ return [
61
+ 'id' => $this->public_id,
62
+ 'internal_id' => $this->internal_id,
63
+ 'name' => $this->name,
64
+ 'latitude' => $this->latitude ?? null,
65
+ 'longitude' => $this->longitude ?? null,
66
+ 'street1' => $this->street1 ?? null,
67
+ 'street2' => $this->street2 ?? null,
68
+ 'city' => $this->city ?? null,
69
+ 'province' => $this->province ?? null,
70
+ 'postal_code' => $this->postal_code ?? null,
71
+ 'neighborhood' => $this->neighborhood ?? null,
72
+ 'district' => $this->district ?? null,
73
+ 'building' => $this->building ?? null,
74
+ 'security_access_code' => $this->security_access_code ?? null,
75
+ 'country' => $this->country ?? null,
76
+ 'phone' => $this->phone ?? null,
77
+ 'owner' => Resolve::resourceForMorph($this->owner_type, $this->owner_uuid),
78
+ 'type' => $this->type ?? null,
79
+ 'meta' => $this->meta ?? [],
80
+ 'updated_at' => $this->updated_at,
81
+ 'created_at' => $this->created_at,
82
+ ];
83
+ }
84
+ }
@@ -0,0 +1,36 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+
8
+ class Proof extends FleetbaseResource
9
+ {
10
+ /**
11
+ * Transform the resource into an array.
12
+ *
13
+ * @param \Illuminate\Http\Request $request
14
+ *
15
+ * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
16
+ */
17
+ public function toArray($request)
18
+ {
19
+ return array_merge(
20
+ $this->getInternalIds(),
21
+ [
22
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
25
+ 'subject_id' => $this->subject ? $this->subject->public_id : null,
26
+ 'order_id' => $this->order ? $this->order->public_id : null,
27
+ 'url' => $this->file_url,
28
+ 'remarks' => $this->remarks,
29
+ 'raw' => $this->raw_data,
30
+ 'data' => $this->data,
31
+ 'updated_at' => $this->updated_at,
32
+ 'created_at' => $this->created_at,
33
+ ]
34
+ );
35
+ }
36
+ }
@@ -0,0 +1,77 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\FleetOps\Support\Utils;
6
+ use Fleetbase\Http\Resources\FleetbaseResource;
7
+ use Fleetbase\Support\Http;
8
+
9
+ class PurchaseRate extends FleetbaseResource
10
+ {
11
+ /**
12
+ * Transform the resource into an array.
13
+ *
14
+ * @param \Illuminate\Http\Request $request
15
+ *
16
+ * @return array
17
+ */
18
+ public function toArray($request)
19
+ {
20
+ return array_merge(
21
+ $this->getInternalIds(),
22
+ [
23
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
24
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
25
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
26
+ 'service_quote' => $this->service_quote_id,
27
+ 'order' => $this->order_id,
28
+ 'customer' => $this->customer_id,
29
+ 'transaction' => $this->transaction_id,
30
+ 'amount' => $this->amount,
31
+ 'currency' => $this->currency,
32
+ 'status' => $this->status,
33
+ 'updated_at' => $this->updated_at,
34
+ 'created_at' => $this->created_at,
35
+ ]
36
+ );
37
+ }
38
+
39
+ /**
40
+ * Transform the resource into an webhook payload.
41
+ *
42
+ * @return array
43
+ */
44
+ public function toWebhookPayload()
45
+ {
46
+ return [
47
+ 'id' => $this->public_id,
48
+ 'service_quote' => $this->service_quote_id,
49
+ 'order' => $this->order_id,
50
+ 'customer' => $this->customer_id,
51
+ 'transaction' => $this->transaction_id,
52
+ 'amount' => $this->amount,
53
+ 'currency' => $this->currency,
54
+ 'status' => $this->status,
55
+ 'updated_at' => $this->updated_at,
56
+ 'created_at' => $this->created_at,
57
+ ];
58
+ }
59
+
60
+ /**
61
+ * Returns the correct service_quote resource if applicable.
62
+ *
63
+ * @return Illuminate\Http\Resources\Json\JsonResource|null
64
+ */
65
+ public function serviceQuote()
66
+ {
67
+ if (Utils::notEmpty($this->service_quote_uuid) && Utils::isEmpty($this->serviceQuote)) {
68
+ $this->load(['serviceArea']);
69
+ }
70
+
71
+ if (Utils::isEmpty($this->serviceQuote)) {
72
+ return null;
73
+ }
74
+
75
+ return new ServiceQuote($this->serviceQuote);
76
+ }
77
+ }
@@ -0,0 +1,55 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+
8
+ class ServiceArea extends FleetbaseResource
9
+ {
10
+ /**
11
+ * Transform the resource into an array.
12
+ *
13
+ * @param \Illuminate\Http\Request $request
14
+ *
15
+ * @return array
16
+ */
17
+ public function toArray($request)
18
+ {
19
+ return array_merge(
20
+ $this->getInternalIds(),
21
+ [
22
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
25
+ 'name' => $this->name,
26
+ 'type' => $this->type,
27
+ 'location' => $this->location,
28
+ 'border' => $this->border,
29
+ 'zones' => $this->whenLoaded('zones', Zone::collection($this->zones)),
30
+ 'status' => $this->status,
31
+ 'updated_at' => $this->updated_at,
32
+ 'created_at' => $this->created_at,
33
+ ]
34
+ );
35
+ }
36
+
37
+ /**
38
+ * Transform the resource into an webhook payload.
39
+ *
40
+ * @return array
41
+ */
42
+ public function toWebhookPayload()
43
+ {
44
+ return [
45
+ 'id' => $this->public_id,
46
+ 'name' => $this->name,
47
+ 'type' => $this->type,
48
+ 'location' => $this->location,
49
+ 'border' => $this->border,
50
+ 'status' => $this->status,
51
+ 'updated_at' => $this->updated_at,
52
+ 'created_at' => $this->created_at,
53
+ ];
54
+ }
55
+ }
@@ -0,0 +1,57 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+
8
+ class ServiceQuote extends FleetbaseResource
9
+ {
10
+ /**
11
+ * Transform the resource into an array.
12
+ *
13
+ * @param \Illuminate\Http\Request $request
14
+ *
15
+ * @return array
16
+ */
17
+ public function toArray($request)
18
+ {
19
+ return array_merge(
20
+ $this->getInternalIds(),
21
+ [
22
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
23
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
24
+ 'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
25
+ 'service_rate_uuid' => $this->when(Http::isInternalRequest(), $this->service_rate_uuid),
26
+ 'payload_uuid' => $this->when(Http::isInternalRequest(), $this->payload_uuid),
27
+ 'service_rate_name' => $this->when(Http::isInternalRequest(), data_get($this, 'serviceRate.name')),
28
+ 'service_rate' => $this->when(Http::isPublicRequest(), data_get($this, 'serviceRate.public_id')),
29
+ 'facilitator' => $this->when(Http::isPublicRequest(), data_get($this, 'integratedVendor.public_id')),
30
+ 'request_id' => $this->request_id,
31
+ 'amount' => $this->amount,
32
+ 'currency' => $this->currency,
33
+ 'updated_at' => $this->updated_at,
34
+ 'created_at' => $this->created_at,
35
+ ]
36
+ );
37
+ }
38
+
39
+ /**
40
+ * Transform the resource into an webhook payload.
41
+ *
42
+ * @return array
43
+ */
44
+ public function toWebhookPayload()
45
+ {
46
+ return [
47
+ 'id' => $this->public_id,
48
+ 'service_rate' => data_get($this, 'serviceRate.public_id'),
49
+ 'facilitator' => data_get($this, 'integratedVendor.public_id'),
50
+ 'request_id' => $this->request_id,
51
+ 'amount' => $this->amount,
52
+ 'currency' => $this->currency,
53
+ 'updated_at' => $this->updated_at,
54
+ 'created_at' => $this->created_at,
55
+ ];
56
+ }
57
+ }