Skip to content

Commit

Permalink
Allow client requests to price api
Browse files Browse the repository at this point in the history
  • Loading branch information
riasvdv committed Aug 14, 2024
1 parent e3a3b4f commit 51188fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/Http/Api/Controllers/PriceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
namespace App\Http\Api\Controllers;

use App\Domain\Shop\Models\Purchasable;
use Illuminate\Http\Request;

class PriceController
{
public function __invoke(Purchasable $purchasable, string $ipOrCountryCode)
public function __invoke(Request $request, Purchasable $purchasable, ?string $ipOrCountryCode = null)
{
$ipOrCountryCode ??= $request->ip() ?? '';

$countryCode = strlen($ipOrCountryCode) === 2
? $ipOrCountryCode
: geoip($ipOrCountryCode)->iso_code;
Expand Down
2 changes: 1 addition & 1 deletion routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Route::post('activations/{activation:uuid}/version', UpdateCurrentVersionController::class);
Route::delete('activations/{activation:uuid}', DeleteActivationController::class);

Route::get('price/{purchasable}/{ipOrCountryCode}', PriceController::class);
Route::get('price/{purchasable}/{ipOrCountryCode?}', PriceController::class);
Route::get('bundle-price/{bundle}/{ipOrCountryCode}', BundlePriceController::class);


Expand Down

0 comments on commit 51188fe

Please sign in to comment.