diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index ad026fe..2a6a0e3 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -16,12 +16,26 @@ class CurrencyController extends Controller { /** * Dispatches all jobs to fetch currency and gold rates synchronously. + * + * @return \Illuminate\Http\JsonResponse */ public function runAllFetchs() { - FetchCurrencyRates::dispatchSync(); - FetchGoldRates::dispatchSync(); - MergeCurrencyAndGoldRates::dispatchSync(); + try { + FetchCurrencyRates::dispatchSync(); + FetchGoldRates::dispatchSync(); + MergeCurrencyAndGoldRates::dispatchSync(); + + return response()->json([ + 'status' => 'success', + 'message' => 'All currency and gold rates have been successfully updated' + ]); + } catch (\Exception $e) { + return response()->json([ + 'status' => 'error', + 'message' => 'An error occurred while updating rates: ' . $e->getMessage() + ], 500); + } } /**