mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat: Add LMI API integration for fetching sales data
- Integrate LMI API to fetch current sales data using the provided API key. - Update SaleController to use Http facade for making API requests. - Modify services configuration to include LMI API key.
This commit is contained in:
@@ -3,19 +3,20 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class SaleController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$sales = Cache::remember('sales_data', 60 * 60 * 8, static function () {
|
||||
$shopData = json_decode(
|
||||
file_get_contents('https://rico-vz.github.io/shop-depr-temp/download.json'),
|
||||
true
|
||||
);
|
||||
$salesData = array_filter($shopData, static fn ($collection) => $collection['path'] === '/event/sales');
|
||||
$lmi_api_key = config('services.lmi.api_key');
|
||||
|
||||
return reset($salesData)['dynamicCollection']['discountedProductsByProductType'] ?? [];
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => 'Bearer ' . $lmi_api_key,
|
||||
])->get('https://lmi.orianna.dev/api/lol-sales');
|
||||
|
||||
return $response->json();
|
||||
});
|
||||
|
||||
return view('sales.index', ['sales' => $sales]);
|
||||
|
||||
Reference in New Issue
Block a user