Enhance CurrencyController with detailed method documentation and new functionalities
- Added comprehensive PHPDoc comments to all methods in the CurrencyController for better code clarity and maintainability. - Introduced new methods: `getAllRates`, `getCurrentRates`, `getGoldRates`, `getCurrencyRateByName`, and `getGoldRateByName` to improve data retrieval from JSON files. - Ensured all methods return appropriate JSON responses, enhancing the API's usability. These changes improve the overall documentation and functionality of the CurrencyController, facilitating better management of financial data.
This commit is contained in:
@@ -7,9 +7,16 @@ use App\Jobs\FetchGoldRates;
|
|||||||
use App\Jobs\MergeCurrencyAndGoldRates;
|
use App\Jobs\MergeCurrencyAndGoldRates;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class CurrencyController
|
||||||
|
*
|
||||||
|
* This controller handles the fetching and returning of currency and gold rates.
|
||||||
|
*/
|
||||||
class CurrencyController extends Controller
|
class CurrencyController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Dispatches all jobs to fetch currency and gold rates synchronously.
|
||||||
|
*/
|
||||||
public function runAllFetchs()
|
public function runAllFetchs()
|
||||||
{
|
{
|
||||||
FetchCurrencyRates::dispatchSync();
|
FetchCurrencyRates::dispatchSync();
|
||||||
@@ -17,6 +24,11 @@ class CurrencyController extends Controller
|
|||||||
MergeCurrencyAndGoldRates::dispatchSync();
|
MergeCurrencyAndGoldRates::dispatchSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all merged currency rates from a JSON file.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
public function getAllRates()
|
public function getAllRates()
|
||||||
{
|
{
|
||||||
// Job'ı çalıştır
|
// Job'ı çalıştır
|
||||||
@@ -36,6 +48,11 @@ class CurrencyController extends Controller
|
|||||||
return response()->json(['error' => 'Veri bulunamadı'], 404);
|
return response()->json(['error' => 'Veri bulunamadı'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the current currency rates from a JSON file.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
public function getCurrentRates()
|
public function getCurrentRates()
|
||||||
{
|
{
|
||||||
// JSON dosyasından oku
|
// JSON dosyasından oku
|
||||||
@@ -49,6 +66,11 @@ class CurrencyController extends Controller
|
|||||||
return response()->json(['error' => 'Veri bulunamadı'], 404);
|
return response()->json(['error' => 'Veri bulunamadı'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the current gold rates from a JSON file.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
public function getGoldRates()
|
public function getGoldRates()
|
||||||
{
|
{
|
||||||
// JSON dosyasından oku
|
// JSON dosyasından oku
|
||||||
@@ -62,6 +84,12 @@ class CurrencyController extends Controller
|
|||||||
return response()->json(['error' => 'Veri bulunamadı'], 404);
|
return response()->json(['error' => 'Veri bulunamadı'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the currency rate by its name from a JSON file.
|
||||||
|
*
|
||||||
|
* @param string $currencyName
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
public function getCurrencyRateByName($currencyName)
|
public function getCurrencyRateByName($currencyName)
|
||||||
{
|
{
|
||||||
// JSON dosyasından oku
|
// JSON dosyasından oku
|
||||||
@@ -77,6 +105,12 @@ class CurrencyController extends Controller
|
|||||||
return response()->json(['error' => 'Data not found'], 404);
|
return response()->json(['error' => 'Data not found'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the gold rate by its name from a JSON file.
|
||||||
|
*
|
||||||
|
* @param string $goldName
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
public function getGoldRateByName($goldName)
|
public function getGoldRateByName($goldName)
|
||||||
{
|
{
|
||||||
// JSON dosyasından oku
|
// JSON dosyasından oku
|
||||||
|
|||||||
Reference in New Issue
Block a user